mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Support to build on pwd != mruby source root
This commit is contained in:
+3
-2
@@ -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[/*]
|
||||
|
||||
@@ -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)
|
||||
|
||||
+13
-11
@@ -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:"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user