summaryrefslogtreecommitdiffhomepage
path: root/tasks/mruby_build.rake
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/mruby_build.rake')
-rw-r--r--tasks/mruby_build.rake63
1 files changed, 34 insertions, 29 deletions
diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake
index cd9f77fc4..2962e167a 100644
--- a/tasks/mruby_build.rake
+++ b/tasks/mruby_build.rake
@@ -53,39 +53,37 @@ module MRuby
Exts = Struct.new(:object, :executable, :library)
def initialize(name='host', &block)
- MRuby::Build.current = self
- @name = name
- @root = File.expand_path("#{File.dirname(__FILE__)}/..")
+ @name = name.to_s
- if ENV['OS'] == 'Windows_NT'
- @exts = Exts.new('.o', '.exe', '.a')
- else
- @exts = Exts.new('.o', '', '.a')
- end
-
- @file_separator = '/'
- @cc = Command::Compiler.new(self, %w(.c))
- @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp))
- @objc = Command::Compiler.new(self, %w(.m))
- @asm = Command::Compiler.new(self, %w(.S .asm))
- @linker = Command::Linker.new(self)
- @archiver = Command::Archiver.new(self)
- @yacc = Command::Yacc.new(self)
- @gperf = Command::Gperf.new(self)
- @git = Command::Git.new(self)
- @mrbc = Command::Mrbc.new(self)
-
- @bins = %w(mruby mrbc mirb)
- @gems, @libmruby = [], []
+ unless MRuby.targets[@name]
+ @root = File.expand_path("#{File.dirname(__FILE__)}/..")
- MRuby.targets[name.to_s] = self
-
- instance_eval(&block)
+ if ENV['OS'] == 'Windows_NT'
+ @exts = Exts.new('.o', '.exe', '.a')
+ else
+ @exts = Exts.new('.o', '', '.a')
+ end
- compilers.each do |compiler|
- compiler.defines -= %w(DISABLE_GEMS) if respond_to?(:enable_gems?) && enable_gems?
- compiler.define_rules build_dir
+ @file_separator = '/'
+ @cc = Command::Compiler.new(self, %w(.c))
+ @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp))
+ @objc = Command::Compiler.new(self, %w(.m))
+ @asm = Command::Compiler.new(self, %w(.S .asm))
+ @linker = Command::Linker.new(self)
+ @archiver = Command::Archiver.new(self)
+ @yacc = Command::Yacc.new(self)
+ @gperf = Command::Gperf.new(self)
+ @git = Command::Git.new(self)
+ @mrbc = Command::Mrbc.new(self)
+
+ @bins = %w(mruby mrbc mirb)
+ @gems, @libmruby = [], []
+
+ MRuby.targets[@name] = self
end
+
+ MRuby::Build.current = MRuby.targets[@name]
+ MRuby.targets[@name].instance_eval(&block)
end
def toolchain(name)
@@ -108,6 +106,13 @@ module MRuby
end
end
+ def define_rules
+ compilers.each do |compiler|
+ compiler.defines -= %w(DISABLE_GEMS) if respond_to?(:enable_gems?) && enable_gems?
+ compiler.define_rules build_dir
+ end
+ end
+
def filename(name)
if name.is_a?(Array)
name.flatten.map { |n| filename(n) }