diff options
| author | Yuichiro MASUI <[email protected]> | 2013-02-23 16:36:57 +0900 |
|---|---|---|
| committer | Yuichiro MASUI <[email protected]> | 2013-02-23 19:03:59 +0900 |
| commit | 0970ca957226d52af52e1f261fbb7ee8b3086cce (patch) | |
| tree | 44d19fe10c6650d9010d25ab840ce6e7e2f860fb /tasks | |
| parent | 58b9e7672474160df90ba11c915eeac093fe12d2 (diff) | |
| download | mruby-0970ca957226d52af52e1f261fbb7ee8b3086cce.tar.gz mruby-0970ca957226d52af52e1f261fbb7ee8b3086cce.zip | |
Support to build on pwd != mruby source root
Diffstat (limited to 'tasks')
| -rw-r--r-- | tasks/mrbgems.rake | 5 | ||||
| -rw-r--r-- | tasks/mrbgems_test.rake | 4 | ||||
| -rw-r--r-- | tasks/mruby_build.rake | 24 | ||||
| -rw-r--r-- | tasks/mruby_build_commands.rake | 18 | ||||
| -rw-r--r-- | tasks/ruby_ext.rake | 4 | ||||
| -rw-r--r-- | tasks/toolchains/gcc.rake | 2 | ||||
| -rw-r--r-- | tasks/toolchains/vs2012.rake | 2 |
7 files changed, 34 insertions, 25 deletions
diff --git a/tasks/mrbgems.rake b/tasks/mrbgems.rake index 285aa75b8..17f266105 100644 --- a/tasks/mrbgems.rake +++ b/tasks/mrbgems.rake @@ -1,5 +1,6 @@ MRuby.each_target do - dir = File.dirname(__FILE__).relative_path_from(root) + current_dir = File.dirname(__FILE__).relative_path_from(Dir.pwd) + relative_from_root = File.dirname(__FILE__).relative_path_from(MRUBY_ROOT) if enable_gems? # set up all gems @@ -8,7 +9,7 @@ MRuby.each_target do # loader all gems self.libmruby << objfile("#{build_dir}/mrbgems/gem_init") file objfile("#{build_dir}/mrbgems/gem_init") => "#{build_dir}/mrbgems/gem_init.c" - file "#{build_dir}/mrbgems/gem_init.c" => [MRUBY_CONFIGS].flatten do |t| + file "#{build_dir}/mrbgems/gem_init.c" => MRUBY_CONFIGS.flatten do |t| FileUtils.mkdir_p "#{build_dir}/mrbgems" open(t.name, 'w') do |f| f.puts %Q[/*] diff --git a/tasks/mrbgems_test.rake b/tasks/mrbgems_test.rake index 2c8ee2ab2..6d40d092a 100644 --- a/tasks/mrbgems_test.rake +++ b/tasks/mrbgems_test.rake @@ -1,5 +1,7 @@ MRuby.each_target do - dir = File.dirname(__FILE__).relative_path_from(root) + current_dir = File.dirname(__FILE__).relative_path_from(Dir.pwd) + relative_from_root = File.dirname(__FILE__).relative_path_from(MRUBY_ROOT) + current_build_dir = "#{build_dir}/#{relative_from_root}" gems.each do |g| test_rbobj = g.test_rbireps.ext(exts.object) diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index b296e8d37..4d28b1d95 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -1,5 +1,5 @@ -load 'tasks/mruby_build_gem.rake' -load 'tasks/mruby_build_commands.rake' +load "#{MRUBY_ROOT}/tasks/mruby_build_gem.rake" +load "#{MRUBY_ROOT}/tasks/mruby_build_commands.rake" module MRuby class << self @@ -30,7 +30,7 @@ module MRuby end def self.load - Dir.glob("#{File.dirname(__FILE__)}/toolchains/*.rake").each do |file| + Dir.glob("#{MRUBY_ROOT}/tasks/toolchains/*.rake").each do |file| Kernel.load file end end @@ -44,7 +44,7 @@ module MRuby include Rake::DSL include LoadGems attr_accessor :name, :bins, :exts, :file_separator - attr_reader :root, :libmruby, :gems + attr_reader :libmruby, :gems COMPILERS = %w(cc cxx objc asm) COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc) @@ -56,8 +56,6 @@ module MRuby @name = name.to_s unless MRuby.targets[@name] - @root = File.expand_path("#{File.dirname(__FILE__)}/..") - if ENV['OS'] == 'Windows_NT' @exts = Exts.new('.o', '.exe', '.a') else @@ -93,12 +91,16 @@ module MRuby tc.setup(self) end + def root + MRUBY_ROOT + end + def build_dir - "build/#{self.name}" + "#{MRUBY_ROOT}/build/#{self.name}" end def mrbcfile - MRuby.targets['host'].exefile("build/host/bin/mrbc") + MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/mrbc") end def compilers @@ -114,7 +116,7 @@ module MRuby else compiler.defines += %w(DISABLE_GEMS) end - compiler.define_rules build_dir + compiler.define_rules build_dir, File.expand_path(File.join(File.dirname(__FILE__), '..')) end end @@ -161,14 +163,14 @@ module MRuby def run_test puts ">>> Test #{name} <<<" mrbtest = exefile("#{build_dir}/test/mrbtest") - sh "#{filename mrbtest}" + sh "#{filename mrbtest.relative_path}" puts end def print_build_summary puts "================================================" puts " Config Name: #{@name}" - puts " Output Directory: #{self.build_dir}" + puts " Output Directory: #{self.build_dir.relative_path}" puts " Binaries: #{@bins.join(', ')}" unless @bins.empty? unless @gems.empty? puts " Included Gems:" diff --git a/tasks/mruby_build_commands.rake b/tasks/mruby_build_commands.rake index 884f2027f..ec8a8d3e3 100644 --- a/tasks/mruby_build_commands.rake +++ b/tasks/mruby_build_commands.rake @@ -39,7 +39,7 @@ module MRuby @command = ENV['CC'] || 'cc' @flags = [ENV['CFLAGS'] || []] @source_exts = source_exts - @include_paths = ["#{build.root}/include"] + @include_paths = ["#{MRUBY_ROOT}/include"] @defines = %w() @option_include_path = '-I%s' @option_define = '-D%s' @@ -60,7 +60,7 @@ module MRuby include_path_flags = [include_paths, _include_paths, File.dirname(infile)].flatten.map do |f| option_include_path % filename(f) end - _pp "CC", infile, outfile + _pp "CC", infile.relative_path, outfile.relative_path _run compile_options, { :flags => all_flags(_defineds, _include_paths, _flags), :infile => filename(infile), :outfile => filename(outfile) } end @@ -76,7 +76,7 @@ module MRuby source_exts.each do |ext, compile| rule generated_file_matcher => [ proc { |file| - file.sub(generated_file_matcher, "#{source_dir}\\1#{ext}") + file.sub(generated_file_matcher, "#{source_dir}/\\1#{ext}") }, proc { |file| get_dependencies(file) @@ -141,7 +141,7 @@ module MRuby library_flags = [libraries, _libraries].flatten.map { |d| option_library % d } library_path_flags = [library_paths, _library_paths].flatten.map { |f| option_library_path % filename(f) } - _pp "LD", outfile + _pp "LD", outfile.relative_path _run link_options, { :flags => all_flags(_library_paths, _flags), :outfile => filename(outfile) , :objs => filename(objfiles).join(' '), :flags_before_libraries => [flags_before_libraries, _flags_before_libraries].flatten.join(' '), @@ -161,7 +161,7 @@ module MRuby def run(outfile, objfiles) FileUtils.mkdir_p File.dirname(outfile) - _pp "AR", outfile + _pp "AR", outfile.relative_path _run archive_options, { :outfile => filename(outfile), :objs => filename(objfiles).join(' ') } end end @@ -177,7 +177,7 @@ module MRuby def run(outfile, infile) FileUtils.mkdir_p File.dirname(outfile) - _pp "YACC", infile, outfile + _pp "YACC", infile.relative_path, outfile.relative_path _run compile_options, { :outfile => filename(outfile) , :infile => filename(infile) } end end @@ -193,7 +193,7 @@ module MRuby def run(outfile, infile) FileUtils.mkdir_p File.dirname(outfile) - _pp "GPERF", infile, outfile + _pp "GPERF", infile.relative_path, outfile.relative_path _run compile_options, { :outfile => filename(outfile) , :infile => filename(infile) } end end @@ -210,7 +210,7 @@ module MRuby end def run_clone(dir, url, _flags = []) - _pp "GIT", url, dir + _pp "GIT", url, dir.relative_path _run clone_options, { :flags => [flags, _flags].flatten.join(' '), :url => url, :dir => filename(dir) } end end @@ -226,7 +226,7 @@ module MRuby @command ||= @build.mrbcfile IO.popen("#{filename @command} #{@compile_options % {:funcname => funcname}}", 'r+') do |io| [infiles].flatten.each do |f| - _pp "MRBC", "#{f}", nil, :indent => 2 + _pp "MRBC", f.relative_path, nil, :indent => 2 io.write IO.read(f) end io.close_write diff --git a/tasks/ruby_ext.rake b/tasks/ruby_ext.rake index 6817f6018..a0fbe7b72 100644 --- a/tasks/ruby_ext.rake +++ b/tasks/ruby_ext.rake @@ -12,6 +12,10 @@ class String def relative_path_from(dir) Pathname.new(File.expand_path(self)).relative_path_from(Pathname.new(File.expand_path(dir))).to_s end + + def relative_path + relative_path_from(Dir.pwd) + end # Compatible with 1.9 on 1.8 def %(params) diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index bef9b8618..66fa75dcb 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -2,7 +2,7 @@ MRuby::Toolchain.new(:gcc) do |conf| [conf.cc, conf.cxx, conf.objc, conf.asm].each do |cc| cc.command = ENV['CC'] || 'gcc' cc.flags = [ENV['CFLAGS'] || %w(-g -O3 -Wall -Werror-implicit-function-declaration)] - cc.include_paths = ["#{root}/include"] + cc.include_paths = ["#{MRUBY_ROOT}/include"] cc.defines = %w(DISABLE_GEMS) cc.option_include_path = '-I%s' cc.option_define = '-D%s' diff --git a/tasks/toolchains/vs2012.rake b/tasks/toolchains/vs2012.rake index 2f1a608b0..f4039cc29 100644 --- a/tasks/toolchains/vs2012.rake +++ b/tasks/toolchains/vs2012.rake @@ -2,7 +2,7 @@ MRuby::Toolchain.new(:vs2012) do |conf| [conf.cc, conf.cxx].each do |cc| cc.command = ENV['CC'] || 'cl.exe' cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /W3 /D_DEBUG /MDd /Zi /Od /RTC1 /DHAVE_STRING_H /DNO_GETTIMEOFDAY /D_CRT_SECURE_NO_WARNINGS)] - cc.include_paths = ["#{root}/include"] + cc.include_paths = ["#{MRUBY_ROOT}/include"] cc.defines = %w(DISABLE_GEMS) cc.option_include_path = '/I%s' cc.option_define = '/D%s' |
