Commit 33350251 authored by Yuichiro MASUI's avatar Yuichiro MASUI

Added conf.bins for defining bulding binaries

parent eab894e5
...@@ -27,25 +27,21 @@ load 'test/mrbtest.rake' ...@@ -27,25 +27,21 @@ load 'test/mrbtest.rake'
# generic build targets, rules # generic build targets, rules
task :default => :all task :default => :all
binfiles = [exefile('bin/mruby'), exefile('bin/mirb'), exefile('bin/mrbc')] binfiles = MRuby.targets['host'].bins.map do |bin|
install_path = exefile("bin/#{bin}")
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 install_path => exefile("build/host/bin/#{bin}") do |t|
FileUtils.cp t.prerequisites.first, t.name
file exefile('bin/mruby') => exefile('build/host/bin/mruby') do |t| end
FileUtils.cp t.prerequisites.first, t.name
end
file exefile('bin/mirb') => exefile('build/host/bin/mirb') do |t| install_path
FileUtils.cp t.prerequisites.first, t.name
end end
file exefile('bin/mrbc') => exefile('build/host/bin/mrbc') do |t| desc "build all targets, install (locally) in-repo"
FileUtils.cp t.prerequisites.first, t.name 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
end
desc "run all mruby tests" 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')}" sh "#{filename exefile('build/host/test/mrbtest')}"
if MRuby.targets.count > 1 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." 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 ...@@ -54,7 +50,7 @@ end
desc "clean all built and in-repo installed artifacts" desc "clean all built and in-repo installed artifacts"
task :clean do task :clean do
MRuby.targets.each do |t| MRuby.each_target do |t|
FileUtils.rm_rf t.build_dir FileUtils.rm_rf t.build_dir
end end
FileUtils.rm_f binfiles FileUtils.rm_f binfiles
......
...@@ -2,6 +2,7 @@ MRuby::Build.new do |conf| ...@@ -2,6 +2,7 @@ MRuby::Build.new do |conf|
conf.cc = ENV['CC'] || 'gcc' conf.cc = ENV['CC'] || 'gcc'
conf.ld = ENV['LD'] || 'gcc' conf.ld = ENV['LD'] || 'gcc'
conf.ar = ENV['AR'] || 'ar' conf.ar = ENV['AR'] || 'ar'
# conf.bins = %w(mrbc mruby mirb)
# conf.cxx = conf.cc # conf.cxx = conf.cc
# conf.objcc = conf.cc # conf.objcc = conf.cc
# conf.asm = conf.cc # conf.asm = conf.cc
...@@ -27,6 +28,7 @@ MRuby::CrossBuild.new('i386') do |conf| ...@@ -27,6 +28,7 @@ MRuby::CrossBuild.new('i386') do |conf|
conf.cc = ENV['CC'] || 'gcc' conf.cc = ENV['CC'] || 'gcc'
conf.ld = ENV['LD'] || 'gcc' conf.ld = ENV['LD'] || 'gcc'
conf.ar = ENV['AR'] || 'ar' conf.ar = ENV['AR'] || 'ar'
# conf.bins = %w(mrbc mruby mirb)
# conf.cxx = 'gcc' # conf.cxx = 'gcc'
# conf.objcc = 'gcc' # conf.objcc = 'gcc'
# conf.asm = 'gcc' # conf.asm = 'gcc'
......
...@@ -53,6 +53,7 @@ The following options can be configurated: ...@@ -53,6 +53,7 @@ The following options can be configurated:
* conf.objccflags (Object compiler flags) * conf.objccflags (Object compiler flags)
* conf.asmflags (Assembler flags) * conf.asmflags (Assembler flags)
* conf.gem (A GEM which should be integrated - can be set several times) * 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 To compile just call ```./minirake``` inside of the mruby source root. To
generate the test tool environment call ```./minirake test```. To clean generate the test tool environment call ```./minirake test```. To clean
......
...@@ -3,11 +3,11 @@ module MRuby ...@@ -3,11 +3,11 @@ module MRuby
attr_accessor :build attr_accessor :build
def targets def targets
@targets ||= [] @targets ||= {}
end end
def each_target(&block) def each_target(&block)
@targets.each do |target| @targets.each do |key, target|
target.instance_eval(&block) target.instance_eval(&block)
end end
end end
...@@ -22,6 +22,7 @@ module MRuby ...@@ -22,6 +22,7 @@ module MRuby
attr_writer :cxx, :cxxflags attr_writer :cxx, :cxxflags
attr_writer :objcc, :objcflags attr_writer :objcc, :objcflags
attr_writer :asm, :asmflags attr_writer :asm, :asmflags
attr_accessor :bins
attr_accessor :gperf, :yacc attr_accessor :gperf, :yacc
attr_accessor :cat, :git attr_accessor :cat, :git
attr_reader :root, :gems attr_reader :root, :gems
...@@ -38,9 +39,11 @@ module MRuby ...@@ -38,9 +39,11 @@ module MRuby
@yacc, @gperf = 'bison', 'gperf' @yacc, @gperf = 'bison', 'gperf'
@cat, @git = 'cat', 'git' @cat, @git = 'cat', 'git'
@bins = %w(mruby mrbc mirb)
@gems, @libmruby = [], [] @gems, @libmruby = [], []
MRuby.targets << self MRuby.targets[name.to_s] = self
MRuby.build = self MRuby.build = self
instance_eval(&block) instance_eval(&block)
end end
......
dir = File.dirname(__FILE__).sub(%r|^\./|, '') dir = File.dirname(__FILE__).sub(%r|^\./|, '')
MRuby.each_target do MRuby.each_target do
exec = exefile("#{build_dir}/bin/mirb") if bins.select { |s| s.to_s == 'mirb' }
objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } 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| 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 } link t.name, t.prerequisites, gems.map { |g| g.mruby_ldflags }, gems.map { |g| g.mruby_libs }
end
end end
end end
dir = File.dirname(__FILE__).sub(%r|^\./|, '') dir = File.dirname(__FILE__).sub(%r|^\./|, '')
MRuby.each_target do MRuby.each_target do
exec = exefile("#{build_dir}/bin/mrbc") if bins.select { |s| s.to_s == 'mrbc' }
objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } 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| file exec => objs + ["#{build_dir}/lib/libmruby_core.a"] do |t|
link t.name, t.prerequisites, [], gems.map { |g| g.mruby_libs } link t.name, t.prerequisites, [], gems.map { |g| g.mruby_libs }
end
end end
end end
dir = File.dirname(__FILE__).sub(%r|^\./|, '') dir = File.dirname(__FILE__).sub(%r|^\./|, '')
MRuby.each_target do MRuby.each_target do
exec = exefile("#{build_dir}/bin/mruby") if bins.select { |s| s.to_s == 'mruby' }
objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } 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| 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 } link t.name, t.prerequisites, gems.map { |g| g.mruby_ldflags }, gems.map { |g| g.mruby_libs }
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment