From b6850f88a1de68599e48e2c08b996d96eed5ea33 Mon Sep 17 00:00:00 2001 From: take-cheeze Date: Thu, 6 Dec 2018 11:47:17 +0900 Subject: Support lock file for git. --- lib/mruby/build.rb | 12 ++++++++++-- lib/mruby/build/command.rb | 30 +++++++++++++++++++----------- lib/mruby/build/load_gems.rb | 30 ++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index e2d9fc41e..ae17d372c 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -45,7 +45,7 @@ module MRuby include Rake::DSL include LoadGems attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir - attr_reader :libmruby_objs, :gems, :toolchains + attr_reader :libmruby_objs, :gems, :toolchains, :locks attr_writer :enable_bintest, :enable_test alias libmruby libmruby_objs @@ -70,7 +70,7 @@ module MRuby @file_separator = '/' @build_dir = "#{build_dir}/#{@name}" - @gem_clone_dir = "#{build_dir}/mrbgems" + @gem_clone_dir = "#{@build_dir}/repos" @cc = Command::Compiler.new(self, %w(.c)) @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp)) @objc = Command::Compiler.new(self, %w(.m)) @@ -92,6 +92,10 @@ module MRuby @enable_test = false @toolchains = [] + @locks = MRUBY_CONFIG_LOCK['builds'][@name] if MRUBY_CONFIG_LOCK['builds'] + @locks ||= {} + @enable_lock = true + MRuby.targets[@name] = self end @@ -118,6 +122,10 @@ module MRuby @enable_debug = true end + def disable_lock + @enable_lock = false + end + def disable_cxx_exception if @cxx_exception_enabled or @cxx_abi_enabled raise "cxx_exception already enabled" diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 694b4a24c..e3dc0d78c 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -243,15 +243,16 @@ module MRuby class Command::Git < Command attr_accessor :flags - attr_accessor :clone_options, :pull_options, :checkout_options + attr_accessor :clone_options, :pull_options, :checkout_options, :reset_options def initialize(build) super @command = 'git' @flags = %w[] @clone_options = "clone %{flags} %{url} %{dir}" - @pull_options = "pull" - @checkout_options = "checkout %{checksum_hash}" + @pull_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' pull" + @checkout_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' checkout %{checksum_hash}" + @reset_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' reset %{checksum_hash}" end def run_clone(dir, url, _flags = []) @@ -260,19 +261,26 @@ module MRuby end def run_pull(dir, url) - root = Dir.pwd - Dir.chdir dir _pp "GIT PULL", url, dir.relative_path - _run pull_options - Dir.chdir root + _run pull_options, { :repo_dir => dir } end def run_checkout(dir, checksum_hash) - root = Dir.pwd - Dir.chdir dir _pp "GIT CHECKOUT", checksum_hash - _run checkout_options, { :checksum_hash => checksum_hash } - Dir.chdir root + _run checkout_options, { :checksum_hash => checksum_hash, :repo_dir => dir } + end + + def run_reset_hard(dir, checksum_hash) + _pp "GIT RESET", checksum_hash + _run reset_options, { :checksum_hash => checksum_hash, :repo_dir => dir } + end + + def commit_hash(dir) + `#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --verify HEAD`.strip + end + + def current_branch(dir) + `#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --abbrev-ref HEAD`.strip end end diff --git a/lib/mruby/build/load_gems.rb b/lib/mruby/build/load_gems.rb index 723be6ffc..481f91a94 100644 --- a/lib/mruby/build/load_gems.rb +++ b/lib/mruby/build/load_gems.rb @@ -83,11 +83,18 @@ module MRuby # by default the 'master' branch is used branch = params[:branch] ? params[:branch] : 'master' + lock = @locks[url] if @enable_lock + if File.exist?(gemdir) if $pull_gems git.run_pull gemdir, url - else - gemdir + # Jump to the top of the branch + git.run_checkout(gemdir, branch) + git.run_reset_hard gemdir, "origin/#{branch}" + elsif params[:checksum_hash] + git.run_reset_hard(gemdir, params[:checksum_hash]) + elsif lock + git.run_reset_hard(gemdir, lock['commit']) end else options = [params[:options]] || [] @@ -96,14 +103,21 @@ module MRuby options << "--depth 1" unless params[:checksum_hash] FileUtils.mkdir_p "#{gem_clone_dir}" git.run_clone gemdir, url, options - end - if params[:checksum_hash] # Jump to the specified commit - git.run_checkout gemdir, params[:checksum_hash] - else - # Jump to the top of the branch - git.run_checkout gemdir, branch if $pull_gems + if params[:checksum_hash] + git.run_reset_hard gemdir, params[:checksum_hash] + elsif lock + git.run_reset_hard gemdir, lock['commit'] + end + end + + if @enable_lock + @locks[url] = { + 'url' => url, + 'branch' => git.current_branch(gemdir), + 'commit' => git.commit_hash(gemdir), + } end gemdir << "/#{params[:path]}" if params[:path] -- cgit v1.2.3 From 73bb144ef0dcf1f3dc4e721e0fd2d557f18cfe07 Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 19 Apr 2019 14:27:12 -0400 Subject: Fixes the twiddle wakka comparison algorithm to support passing only a major number --- lib/mruby/gem.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb index ce2e01ab1..95c1d4bc3 100644 --- a/lib/mruby/gem.rb +++ b/lib/mruby/gem.rb @@ -267,16 +267,18 @@ module MRuby # ~> compare algorithm # # Example: + # ~> 2 means >= 2.0.0 and < 3.0.0 # ~> 2.2 means >= 2.2.0 and < 3.0.0 - # ~> 2.2.0 means >= 2.2.0 and < 2.3.0 + # ~> 2.2.2 means >= 2.2.2 and < 2.3.0 def twiddle_wakka_ok?(other) gr_or_eql = (self <=> other) >= 0 - still_minor = (self <=> other.skip_minor) < 0 - gr_or_eql and still_minor + still_major_or_minor = (self <=> other.skip_major_or_minor) < 0 + gr_or_eql and still_major_or_minor end - def skip_minor + def skip_major_or_minor a = @ary.dup + a << 0 if a.size == 1 # ~> 2 can also be represented as ~> 2.0 a.slice!(-1) a[-1] = a[-1].succ a -- cgit v1.2.3 From d5c8868346b49e2b2228cb8733398d88f744985b Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Fri, 17 May 2019 17:59:24 +0900 Subject: Add support for CC="gcc --option ..." again If $rake_root_fiber is used, sh runs command in another Fiber. If command is ran in another Fiber, "rescue RuntimEerror" can't rescue exception for system(...) failure. How to reproduce: $ CC="gcc -std=gnu99" ./minirake (in /home/kou/work/ruby/mruby.kou) CC mrbgems/mruby-compiler/core/codegen.c -> build/test/mrbgems/mruby-compiler/core/codegen.o sh: 1: gcc -std=gnu99: not found rake aborted! Command Failed: ["gcc -std=gnu99" -g -std=gnu99 ...] --- lib/mruby/build/command.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 0f18e0e62..0fa4746da 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -30,10 +30,13 @@ module MRuby def _run(options, params={}) return sh command + ' ' + ( options % params ) if NotFoundCommands.key? @command begin + fiber, $rake_root_fiber = $rake_root_fiber, nil sh build.filename(command) + ' ' + ( options % params ) rescue RuntimeError NotFoundCommands[@command] = true _run options, params + ensure + $rake_root_fiber = fiber end end end -- cgit v1.2.3 From 8d37a3575b9d6e7648967c675395bd176b360b77 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 17 May 2019 22:37:45 +0900 Subject: Revert "Add support for CC="gcc --option ..." again" This reverts commit d5c8868346b49e2b2228cb8733398d88f744985b. --- lib/mruby/build/command.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 0fa4746da..0f18e0e62 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -30,13 +30,10 @@ module MRuby def _run(options, params={}) return sh command + ' ' + ( options % params ) if NotFoundCommands.key? @command begin - fiber, $rake_root_fiber = $rake_root_fiber, nil sh build.filename(command) + ' ' + ( options % params ) rescue RuntimeError NotFoundCommands[@command] = true _run options, params - ensure - $rake_root_fiber = fiber end end end -- cgit v1.2.3 From b7bc03aa18f3cc5eac0bbd6690e24062df9fe837 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 17 May 2019 22:38:07 +0900 Subject: Stop wrapping the filename by double quotes; ref #4440 --- lib/mruby/build.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 016b32b3e..887a5518e 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -255,7 +255,7 @@ EOS if name.is_a?(Array) name.flatten.map { |n| filename(n) } else - '"%s"' % name.gsub('/', file_separator) + name.gsub('/', file_separator) end end @@ -263,7 +263,7 @@ EOS if name.is_a?(Array) name.flatten.map { |n| cygwin_filename(n) } else - '"%s"' % `cygpath -w "#{filename(name)}"`.strip + `cygpath -w "#{filename(name)}"`.strip end end -- cgit v1.2.3 From 66909dfe8650e242ed96c26e576498d290ece347 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Thu, 11 Jul 2019 23:56:45 +0900 Subject: Consider `-MP` flag specified when parsing `.d` file `-MP` flag is used in `tasks/toolchains/android.rake`. --- lib/mruby/build/command.rb | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index 0f18e0e62..d4354225e 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -127,13 +127,40 @@ module MRuby end private + + # + # === Example of +.d+ file + # + # ==== Without -MP compiler flag + # + # /build/host/src/array.o: \ + # /src/array.c \ + # /include/mruby/common.h \ + # /include/mruby/value.h \ + # /src/value_array.h + # + # ==== With -MP compiler flag + # + # /build/host/src/array.o: \ + # /src/array.c \ + # /include/mruby/common.h \ + # /include/mruby/value.h \ + # /src/value_array.h + # + # /include/mruby/common.h: + # + # /include/mruby/value.h: + # + # /src/value_array.h: + # def get_dependencies(file) file = file.ext('d') unless File.extname(file) == '.d' + deps = [] if File.exist?(file) - File.read(file).gsub("\\\n ", "").scan(/^\S+:\s+(.+)$/).flatten.map {|s| s.split(' ') }.flatten - else - [] - end + [ MRUBY_CONFIG ] + File.foreach(file){|line| deps << $1 if /^ +(.*?)(?: *\\)?$/ =~ line} + deps.uniq! + end + deps << MRUBY_CONFIG end end -- cgit v1.2.3 From 16e4657acdacfd99bd649d50b44a748d86a31861 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Fri, 12 Jul 2019 18:35:20 +0900 Subject: Lazy load `tasks/toolchains/*.rake` --- lib/mruby/build.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 887a5518e..d9d52948b 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -22,7 +22,6 @@ module MRuby def initialize(name, &block) @name, @initializer = name.to_s, block - MRuby::Toolchain.toolchains ||= {} MRuby::Toolchain.toolchains[@name] = self end @@ -30,13 +29,8 @@ module MRuby conf.instance_exec(conf, params, &@initializer) end - def self.load - Dir.glob("#{MRUBY_ROOT}/tasks/toolchains/*.rake").each do |file| - Kernel.load file - end - end + self.toolchains = {} end - Toolchain.load class Build class << self @@ -196,10 +190,15 @@ EOS end def toolchain(name, params={}) - tc = Toolchain.toolchains[name.to_s] - fail "Unknown #{name} toolchain" unless tc + name = name.to_s + tc = Toolchain.toolchains[name] || begin + path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake" + fail "Unknown #{name} toolchain" unless File.exist?(path) + load path + Toolchain.toolchains[name] + end tc.setup(self, params) - @toolchains.unshift name.to_s + @toolchains.unshift name end def primary_toolchain -- cgit v1.2.3 From 1868fd453d70009fd4a895b09c236fb8fc653d6c Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Thu, 8 Aug 2019 22:12:25 +0900 Subject: Remove monkey patches for Ruby 1.9 or earlier --- lib/mruby-core-ext.rb | 39 --------------------------------------- 1 file changed, 39 deletions(-) (limited to 'lib') diff --git a/lib/mruby-core-ext.rb b/lib/mruby-core-ext.rb index 08e6f6148..8c985f147 100644 --- a/lib/mruby-core-ext.rb +++ b/lib/mruby-core-ext.rb @@ -16,45 +16,6 @@ class String def relative_path relative_path_from(Dir.pwd) end - - # Compatible with 1.9 on 1.8 - unless (sprintf("%{a}", :a => 1) rescue false) - def %(params) - if params.is_a?(Hash) - str = self.clone - params.each do |k, v| - str.gsub!("%{#{k}}") { v } - end - str - else - if params.is_a?(Array) - sprintf(self, *params) - else - sprintf(self, params) - end - end - end - end -end - -class Symbol - # Compatible with 1.9 on 1.8 - unless method_defined?(:to_proc) - def to_proc - proc { |obj, *args| obj.send(self, *args) } - end - end -end - -module Enumerable - # Compatible with 1.9 on 1.8 - unless method_defined?(:each_with_object) - def each_with_object(memo) - return to_enum :each_with_object, memo unless block_given? - each { |obj| yield obj, memo } - memo - end - end end $pp_show = true -- cgit v1.2.3 From a86f8f26a2c22bf393938509471c977f7e364497 Mon Sep 17 00:00:00 2001 From: take-cheeze Date: Thu, 22 Aug 2019 02:43:00 +0900 Subject: Separate repos directory and build directory closes #4652 --- lib/mruby/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 90943f3b1..98b9b368d 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -64,7 +64,7 @@ module MRuby @file_separator = '/' @build_dir = "#{build_dir}/#{@name}" - @gem_clone_dir = "#{@build_dir}/repos" + @gem_clone_dir = "#{build_dir}/repos/#{@name}" @cc = Command::Compiler.new(self, %w(.c)) @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp)) @objc = Command::Compiler.new(self, %w(.m)) -- cgit v1.2.3 From e312842a1866a551c0b73bdf21f52ad94d25152a Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Thu, 22 Aug 2019 21:40:01 +0900 Subject: Refine processing for gem lock file - Defer YAML library and lock file loading until needed. - Don't write empty parts into lock file. - Extract code to read/write lock file to `MRuby::Lockfile`. - `MRuby::Lockfile.disable` disables the use of lock file. --- Rakefile | 22 ++----------- lib/mruby/build.rb | 15 ++++++--- lib/mruby/build/load_gems.rb | 6 ++-- lib/mruby/lockfile.rb | 73 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 28 deletions(-) create mode 100644 lib/mruby/lockfile.rb (limited to 'lib') diff --git a/Rakefile b/Rakefile index 6d8382f74..298ef8020 100644 --- a/Rakefile +++ b/Rakefile @@ -8,10 +8,10 @@ MRUBY_BUILD_HOST_IS_OPENBSD = RUBY_PLATFORM.include?('openbsd') $LOAD_PATH << File.join(MRUBY_ROOT, "lib") # load build systems -require 'yaml' require "mruby-core-ext" require "mruby/build" require "mruby/gem" +require "mruby/lockfile" # load configuration file MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb" @@ -125,25 +125,7 @@ task :all => depfiles do MRuby.each_target do print_build_summary end - - require 'mruby/source' - - locks_result = { - 'mruby_version' => { - 'version' => MRuby::Source::MRUBY_VERSION, - 'release_no' => MRuby::Source::MRUBY_RELEASE_NO - }, - 'builds' => {} - } - if File.exist? "#{MRUBY_ROOT}/.git" - locks_result['mruby_version']['git_commit'] = `git --git-dir '#{MRUBY_ROOT}/.git' --work-tree '#{MRUBY_ROOT}' rev-parse --verify HEAD`.strip - end - - MRuby.each_target do - locks_result['builds'][name] = locks - end - - File.write MRUBY_CONFIG_LOCK_FILE, YAML.dump(locks_result) + MRuby::Lockfile.write end desc "run all mruby tests" diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 98b9b368d..ecc343360 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -39,7 +39,7 @@ module MRuby include Rake::DSL include LoadGems attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir - attr_reader :libmruby_objs, :gems, :toolchains, :locks + attr_reader :libmruby_objs, :gems, :toolchains attr_writer :enable_bintest, :enable_test alias libmruby libmruby_objs @@ -84,11 +84,8 @@ module MRuby @cxx_abi_enabled = false @enable_bintest = false @enable_test = false - @toolchains = [] - - @locks = MRUBY_CONFIG_LOCK['builds'][@name] if MRUBY_CONFIG_LOCK['builds'] - @locks ||= {} @enable_lock = true + @toolchains = [] MRuby.targets[@name] = self end @@ -120,6 +117,10 @@ module MRuby @enable_lock = false end + def lock_enabled? + Lockfile.enabled? && @enable_lock + end + def disable_cxx_exception if @cxx_exception_enabled or @cxx_abi_enabled raise "cxx_exception already enabled" @@ -233,6 +234,10 @@ EOS gem :core => 'mruby-bin-mrbc' end + def locks + Lockfile.build(@name) + end + def mrbcfile return @mrbcfile if @mrbcfile diff --git a/lib/mruby/build/load_gems.rb b/lib/mruby/build/load_gems.rb index 481f91a94..7f2c7202b 100644 --- a/lib/mruby/build/load_gems.rb +++ b/lib/mruby/build/load_gems.rb @@ -83,7 +83,7 @@ module MRuby # by default the 'master' branch is used branch = params[:branch] ? params[:branch] : 'master' - lock = @locks[url] if @enable_lock + lock = locks[url] if lock_enabled? if File.exist?(gemdir) if $pull_gems @@ -112,8 +112,8 @@ module MRuby end end - if @enable_lock - @locks[url] = { + if lock_enabled? + locks[url] = { 'url' => url, 'branch' => git.current_branch(gemdir), 'commit' => git.commit_hash(gemdir), diff --git a/lib/mruby/lockfile.rb b/lib/mruby/lockfile.rb new file mode 100644 index 000000000..ce1442a89 --- /dev/null +++ b/lib/mruby/lockfile.rb @@ -0,0 +1,73 @@ +autoload :YAML, 'yaml' + +module MRuby + autoload :Source, 'mruby/source' + + class Lockfile + class << self + def enable + @enabled = true + end + + def disable + @enabled = false + end + + def enabled? + @enabled + end + + def build(target_name) + instance.build(target_name) + end + + def write + instance.write if enabled? + end + + def instance + @instance ||= new("#{MRUBY_CONFIG}.lock") + end + end + + def initialize(filename) + @filename = filename + end + + def build(target_name) + read[target_name] ||= {} + end + + def write + locks = {"mruby_version" => mruby} + locks["builds"] = @builds if @builds + File.write(@filename, YAML.dump(locks)) + end + + private + + def read + @builds ||= if File.exist?(@filename) + YAML.load_file(@filename)["builds"] || {} + else + {} + end + end + + def mruby + mruby = { + 'version' => MRuby::Source::MRUBY_VERSION, + 'release_no' => MRuby::Source::MRUBY_RELEASE_NO, + } + + git_dir = "#{MRUBY_ROOT}/.git" + if File.directory?(git_dir) + mruby['git_commit'] = `git --git-dir '#{git_dir}' --work-tree '#{MRUBY_ROOT}' rev-parse --verify HEAD`.strip + end + + mruby + end + + enable + end +end -- cgit v1.2.3 From 3110d84ed834cba90d9830ae23e89cd61bcae459 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Sun, 25 Aug 2019 09:48:07 +0900 Subject: Defer several build libraries loading until needed --- Rakefile | 2 -- lib/mruby-core-ext.rb | 2 ++ lib/mruby/build.rb | 4 ++++ lib/mruby/gem.rb | 5 ++--- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/Rakefile b/Rakefile index be42233db..079b1a41b 100644 --- a/Rakefile +++ b/Rakefile @@ -10,8 +10,6 @@ $LOAD_PATH << File.join(MRUBY_ROOT, "lib") # load build systems require "mruby-core-ext" require "mruby/build" -require "mruby/gem" -require "mruby/lockfile" # load configuration file MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb" diff --git a/lib/mruby-core-ext.rb b/lib/mruby-core-ext.rb index 8c985f147..7b78bfa91 100644 --- a/lib/mruby-core-ext.rb +++ b/lib/mruby-core-ext.rb @@ -1,3 +1,5 @@ +autoload :Pathname, 'pathname' + class Object class << self def attr_block(*syms) diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index ecc343360..dfce42bea 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -1,7 +1,11 @@ +require "mruby-core-ext" require "mruby/build/load_gems" require "mruby/build/command" module MRuby + autoload :Gem, "mruby/gem" + autoload :Lockfile, "mruby/lockfile" + class << self def targets @targets ||= {} diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb index 95c1d4bc3..6cb067b91 100644 --- a/lib/mruby/gem.rb +++ b/lib/mruby/gem.rb @@ -1,7 +1,6 @@ -require 'pathname' require 'forwardable' -require 'tsort' -require 'shellwords' +autoload :TSort, 'tsort' +autoload :Shellwords, 'shellwords' module MRuby module Gem -- cgit v1.2.3 From d4af765651193d342488cfbbf81f352f53d5377e Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 13 Sep 2019 02:21:09 +0900 Subject: Remove `-std=gnu99` when `enable_cxx_abi`; ref #4703 To stop warnings since C++ do not accept `-std=gnu99` option. --- lib/mruby/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index dfce42bea..5bedfc0e6 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -162,8 +162,8 @@ module MRuby compilers.each { |c| c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI) c.flags << c.cxx_compile_flag + c.flags.delete('-std=gnu99') } - compilers.each { |c| c.flags << c.cxx_compile_flag } linker.command = cxx.command if toolchains.find { |v| v == 'gcc' } @cxx_abi_enabled = true end -- cgit v1.2.3 From be76cec3422ddedbfce48768db5aec004e2f0aee Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Fri, 13 Sep 2019 17:14:37 +0900 Subject: Fix warnings for invalid C++ option with `enable_cxx_abi`; ref #3618, #4703 --- lib/mruby/build.rb | 2 +- lib/mruby/build/command.rb | 3 ++- tasks/toolchains/gcc.rake | 9 ++++++--- travis_config.rb | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 5bedfc0e6..375b2933a 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -162,7 +162,7 @@ module MRuby compilers.each { |c| c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI) c.flags << c.cxx_compile_flag - c.flags.delete('-std=gnu99') + c.flags = c.flags.flatten - c.cxx_invalid_flags.flatten } linker.command = cxx.command if toolchains.find { |v| v == 'gcc' } @cxx_abi_enabled = true diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index a98f2ca7e..bff250c93 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -41,7 +41,7 @@ module MRuby class Command::Compiler < Command attr_accessor :flags, :include_paths, :defines, :source_exts attr_accessor :compile_options, :option_define, :option_include_path, :out_ext - attr_accessor :cxx_compile_flag, :cxx_exception_flag + attr_accessor :cxx_compile_flag, :cxx_exception_flag, :cxx_invalid_flags def initialize(build, source_exts=[]) super(build) @@ -53,6 +53,7 @@ module MRuby @option_include_path = '-I%s' @option_define = '-D%s' @compile_options = '%{flags} -o %{outfile} -c %{infile}' + @cxx_invalid_flags = [] end alias header_search_paths include_paths diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index ca083a4b2..1a28026bf 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -1,20 +1,23 @@ MRuby::Toolchain.new(:gcc) do |conf, params| default_command = params[:default_command] || 'gcc' - compile_flags = %w(-g -O3 -Wall -Wundef -Werror-implicit-function-declaration) + compiler_flags = %w(-g -O3 -Wall -Wundef) + c_mandatory_flags = %w(-std=gnu99) + cxx_invalid_flags = %w(-Wdeclaration-after-statement -Werror-implicit-function-declaration) [conf.cc, conf.objc, conf.asm, conf.cxx].each do |compiler| if compiler == conf.cxx compiler.command = ENV['CXX'] || default_command.sub(/cc|$/, '++') - compiler.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || compile_flags] + compiler.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || compiler_flags] else compiler.command = ENV['CC'] || default_command - compiler.flags = ['-std=gnu99', ENV['CFLAGS'] || [compile_flags, %w(-Wdeclaration-after-statement -Wwrite-strings)]] + compiler.flags = [c_mandatory_flags, ENV['CFLAGS'] || [compiler_flags, cxx_invalid_flags, %w(-Wwrite-strings)]] end compiler.option_include_path = '-I%s' compiler.option_define = '-D%s' compiler.compile_options = '%{flags} -MMD -o %{outfile} -c %{infile}' compiler.cxx_compile_flag = '-x c++ -std=c++03' compiler.cxx_exception_flag = '-fexceptions' + compiler.cxx_invalid_flags = c_mandatory_flags + cxx_invalid_flags end conf.linker do |linker| diff --git a/travis_config.rb b/travis_config.rb index 7a13ced72..94cd4aadc 100644 --- a/travis_config.rb +++ b/travis_config.rb @@ -40,7 +40,7 @@ MRuby::Build.new('cxx_abi') do |conf| toolchain :gcc conf.gembox 'full-core' - conf.cc.flags += %w(-Werror=declaration-after-statement -fpermissive) + conf.cc.flags += %w(-fpermissive) conf.compilers.each do |c| c.defines += %w(MRB_GC_FIXED_ARENA) end -- cgit v1.2.3 From f7616c4287379f09cfca02d277814e2c85dc510a Mon Sep 17 00:00:00 2001 From: take-cheeze Date: Wed, 9 Oct 2019 02:22:33 +0900 Subject: Add mrbgem version field to lock file --- lib/mruby/build.rb | 3 ++- lib/mruby/build/load_gems.rb | 1 + lib/mruby/gem.rb | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 375b2933a..55b82cd2b 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -43,7 +43,7 @@ module MRuby include Rake::DSL include LoadGems attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir - attr_reader :libmruby_objs, :gems, :toolchains + attr_reader :libmruby_objs, :gems, :toolchains, :gem_dir_to_repo_url attr_writer :enable_bintest, :enable_test alias libmruby libmruby_objs @@ -90,6 +90,7 @@ module MRuby @enable_test = false @enable_lock = true @toolchains = [] + @gem_dir_to_repo_url = {} MRuby.targets[@name] = self end diff --git a/lib/mruby/build/load_gems.rb b/lib/mruby/build/load_gems.rb index 7f2c7202b..9f09167ba 100644 --- a/lib/mruby/build/load_gems.rb +++ b/lib/mruby/build/load_gems.rb @@ -113,6 +113,7 @@ module MRuby end if lock_enabled? + @gem_dir_to_repo_url[gemdir] = url unless params[:path] locks[url] = { 'url' => url, 'branch' => git.current_branch(gemdir), diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb index 6cb067b91..a1cdb28af 100644 --- a/lib/mruby/gem.rb +++ b/lib/mruby/gem.rb @@ -91,6 +91,9 @@ module MRuby build.libmruby_objs << @objs instance_eval(&@build_config_initializer) if @build_config_initializer + + repo_url = build.gem_dir_to_repo_url[dir] + build.locks[repo_url]['version'] = version if repo_url end def setup_compilers -- cgit v1.2.3