diff options
| author | Yuichiro MASUI <[email protected]> | 2013-01-09 22:40:08 +0900 |
|---|---|---|
| committer | Yuichiro MASUI <[email protected]> | 2013-01-09 22:40:08 +0900 |
| commit | 33350251ae3d8d683ac4b4c462e7f8aa690c25da (patch) | |
| tree | 28560c8ddb827fbfec2380fb3a40324d0ac001df | |
| parent | eab894e5be20babfc5761835a6d085ec077095c0 (diff) | |
| download | mruby-33350251ae3d8d683ac4b4c462e7f8aa690c25da.tar.gz mruby-33350251ae3d8d683ac4b4c462e7f8aa690c25da.zip | |
Added conf.bins for defining bulding binaries
| -rw-r--r-- | Rakefile | 26 | ||||
| -rw-r--r-- | build_config.rb | 2 | ||||
| -rw-r--r-- | doc/compile/README.md | 1 | ||||
| -rw-r--r-- | tasks/mruby_build.rake | 9 | ||||
| -rw-r--r-- | tools/mirb/mirb.rake | 10 | ||||
| -rw-r--r-- | tools/mrbc/mrbc.rake | 10 | ||||
| -rw-r--r-- | tools/mruby/mruby.rake | 10 |
7 files changed, 38 insertions, 30 deletions
@@ -27,25 +27,21 @@ load 'test/mrbtest.rake' # generic build targets, rules task :default => :all -binfiles = [exefile('bin/mruby'), exefile('bin/mirb'), exefile('bin/mrbc')] - -desc "build all targets, install (locally) in-repo" -task :all => binfiles + MRuby.targets.map { |t| [exefile("#{t.build_dir}/bin/mruby"), exefile("#{t.build_dir}/bin/mirb"), exefile("#{t.build_dir}/bin/mrbc")] }.flatten - -file exefile('bin/mruby') => exefile('build/host/bin/mruby') do |t| - FileUtils.cp t.prerequisites.first, t.name -end +binfiles = MRuby.targets['host'].bins.map do |bin| + install_path = exefile("bin/#{bin}") + + file install_path => exefile("build/host/bin/#{bin}") do |t| + FileUtils.cp t.prerequisites.first, t.name + end -file exefile('bin/mirb') => exefile('build/host/bin/mirb') do |t| - FileUtils.cp t.prerequisites.first, t.name + install_path end -file exefile('bin/mrbc') => exefile('build/host/bin/mrbc') do |t| - FileUtils.cp t.prerequisites.first, t.name -end +desc "build all targets, install (locally) in-repo" +task :all => binfiles + MRuby.targets.values.map { |t| [exefile("#{t.build_dir}/bin/mruby"), exefile("#{t.build_dir}/bin/mirb"), exefile("#{t.build_dir}/bin/mrbc")] }.flatten desc "run all mruby tests" -task :test => MRuby.targets.map { |t| exefile("#{t.build_dir}/test/mrbtest") } do +task :test => MRuby.targets.values.map { |t| exefile("#{t.build_dir}/test/mrbtest") } do sh "#{filename exefile('build/host/test/mrbtest')}" if MRuby.targets.count > 1 puts "\nYou should run #{MRuby.targets.map{ |t| t.name == 'host' ? nil : "#{t.build_dir}/test/mrbtest" }.compact.join(', ')} on target device." @@ -54,7 +50,7 @@ end desc "clean all built and in-repo installed artifacts" task :clean do - MRuby.targets.each do |t| + MRuby.each_target do |t| FileUtils.rm_rf t.build_dir end FileUtils.rm_f binfiles diff --git a/build_config.rb b/build_config.rb index 93ccc1a98..4e80a2596 100644 --- a/build_config.rb +++ b/build_config.rb @@ -2,6 +2,7 @@ MRuby::Build.new do |conf| conf.cc = ENV['CC'] || 'gcc' conf.ld = ENV['LD'] || 'gcc' conf.ar = ENV['AR'] || 'ar' + # conf.bins = %w(mrbc mruby mirb) # conf.cxx = conf.cc # conf.objcc = conf.cc # conf.asm = conf.cc @@ -27,6 +28,7 @@ MRuby::CrossBuild.new('i386') do |conf| conf.cc = ENV['CC'] || 'gcc' conf.ld = ENV['LD'] || 'gcc' conf.ar = ENV['AR'] || 'ar' + # conf.bins = %w(mrbc mruby mirb) # conf.cxx = 'gcc' # conf.objcc = 'gcc' # conf.asm = 'gcc' diff --git a/doc/compile/README.md b/doc/compile/README.md index e68c0d6f1..cec70e68b 100644 --- a/doc/compile/README.md +++ b/doc/compile/README.md @@ -53,6 +53,7 @@ The following options can be configurated: * conf.objccflags (Object compiler flags) * conf.asmflags (Assembler flags) * conf.gem (A GEM which should be integrated - can be set several times) +* conf.bins (Build binaries) To compile just call ```./minirake``` inside of the mruby source root. To generate the test tool environment call ```./minirake test```. To clean diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index d5dc075c3..de9e556b4 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -3,11 +3,11 @@ module MRuby attr_accessor :build def targets - @targets ||= [] + @targets ||= {} end def each_target(&block) - @targets.each do |target| + @targets.each do |key, target| target.instance_eval(&block) end end @@ -22,6 +22,7 @@ module MRuby attr_writer :cxx, :cxxflags attr_writer :objcc, :objcflags attr_writer :asm, :asmflags + attr_accessor :bins attr_accessor :gperf, :yacc attr_accessor :cat, :git attr_reader :root, :gems @@ -38,9 +39,11 @@ module MRuby @yacc, @gperf = 'bison', 'gperf' @cat, @git = 'cat', 'git' + @bins = %w(mruby mrbc mirb) + @gems, @libmruby = [], [] - MRuby.targets << self + MRuby.targets[name.to_s] = self MRuby.build = self instance_eval(&block) end diff --git a/tools/mirb/mirb.rake b/tools/mirb/mirb.rake index 52f334420..958ebe79a 100644 --- a/tools/mirb/mirb.rake +++ b/tools/mirb/mirb.rake @@ -1,10 +1,12 @@ dir = File.dirname(__FILE__).sub(%r|^\./|, '') MRuby.each_target do - exec = exefile("#{build_dir}/bin/mirb") - objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } + if bins.select { |s| s.to_s == 'mirb' } + exec = exefile("#{build_dir}/bin/mirb") + objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } - file exec => objs + ["#{build_dir}/lib/libmruby.a"] do |t| - link t.name, t.prerequisites, gems.map { |g| g.mruby_ldflags }, gems.map { |g| g.mruby_libs } + file exec => objs + ["#{build_dir}/lib/libmruby.a"] do |t| + link t.name, t.prerequisites, gems.map { |g| g.mruby_ldflags }, gems.map { |g| g.mruby_libs } + end end end diff --git a/tools/mrbc/mrbc.rake b/tools/mrbc/mrbc.rake index cf356ba4f..bff88312a 100644 --- a/tools/mrbc/mrbc.rake +++ b/tools/mrbc/mrbc.rake @@ -1,10 +1,12 @@ dir = File.dirname(__FILE__).sub(%r|^\./|, '') MRuby.each_target do - exec = exefile("#{build_dir}/bin/mrbc") - objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } + if bins.select { |s| s.to_s == 'mrbc' } + exec = exefile("#{build_dir}/bin/mrbc") + objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } - file exec => objs + ["#{build_dir}/lib/libmruby_core.a"] do |t| - link t.name, t.prerequisites, [], gems.map { |g| g.mruby_libs } + file exec => objs + ["#{build_dir}/lib/libmruby_core.a"] do |t| + link t.name, t.prerequisites, [], gems.map { |g| g.mruby_libs } + end end end diff --git a/tools/mruby/mruby.rake b/tools/mruby/mruby.rake index 162e8d1ba..7842c4266 100644 --- a/tools/mruby/mruby.rake +++ b/tools/mruby/mruby.rake @@ -1,10 +1,12 @@ dir = File.dirname(__FILE__).sub(%r|^\./|, '') MRuby.each_target do - exec = exefile("#{build_dir}/bin/mruby") - objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } + if bins.select { |s| s.to_s == 'mruby' } + exec = exefile("#{build_dir}/bin/mruby") + objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } - file exec => objs + ["#{build_dir}/lib/libmruby.a"] do |t| - link t.name, t.prerequisites, gems.map { |g| g.mruby_ldflags }, gems.map { |g| g.mruby_libs } + file exec => objs + ["#{build_dir}/lib/libmruby.a"] do |t| + link t.name, t.prerequisites, gems.map { |g| g.mruby_ldflags }, gems.map { |g| g.mruby_libs } + end end end |
