From 117e2ec06544e02511a2b5d2164edb00908ebab2 Mon Sep 17 00:00:00 2001 From: Yuichiro MASUI Date: Mon, 21 Jan 2013 14:05:42 +0900 Subject: Export build flags to lib/libmruby.flags.mak --- tasks/mruby_build_commands.rake | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'tasks/mruby_build_commands.rake') diff --git a/tasks/mruby_build_commands.rake b/tasks/mruby_build_commands.rake index 7014d5a20..7f9b50313 100644 --- a/tasks/mruby_build_commands.rake +++ b/tasks/mruby_build_commands.rake @@ -45,12 +45,16 @@ module MRuby @option_define = '-D%s' @compile_options = "%{flags} -MMD -o %{outfile} -c %{infile}" end + + def all_flags(_defineds=[], _include_paths=[], _flags=[]) + define_flags = [defines, _defineds].flatten.map{ |d| option_define % d } + include_path_flags = [include_paths, _include_paths].flatten.map{ |f| option_include_path % filename(f) } + [flags, define_flags, include_path_flags, _flags].flatten.join(' ') + end def run(outfile, infile, _defineds=[], _include_paths=[], _flags=[]) FileUtils.mkdir_p File.dirname(outfile) - define_flags = [defines, _defineds].flatten.map{ |d| option_define % d } - include_path_flags = [include_paths, _include_paths, File.dirname(infile)].flatten.map{ |f| option_include_path % filename(f) } - _run compile_options, { :flags => [flags, define_flags, include_path_flags, _flags].flatten.join(' '), :infile => filename(infile), :outfile => filename(outfile) } + _run compile_options, { :flags => all_flags(_defineds, [_include_paths, File.dirname(infile)], _flags), :infile => filename(infile), :outfile => filename(outfile) } end def define_rules(build_dir, source_dir='') @@ -108,11 +112,18 @@ module MRuby @link_options = "%{flags} -o %{outfile} %{objs} %{libs}" end + def all_flags(_library_paths=[], _flags=[]) + library_path_flags = [library_paths, _library_paths].flatten.map{ |f| option_library_path % filename(f) } + [flags, library_path_flags, _flags].flatten.join(' ') + end + + def library_flags(_libraries) + [libraries, _libraries].flatten.reverse.map{ |d| option_library % d }.join(' ') + end + def run(outfile, objfiles, _libraries=[], _library_paths=[], _flags=[]) FileUtils.mkdir_p File.dirname(outfile) - library_flags = [libraries, _libraries].flatten.reverse.map{ |d| option_library % d } - library_path_flags = [library_paths, _library_paths].flatten.map{ |f| option_library_path % filename(f) } - _run link_options, { :flags => [flags, library_path_flags, _flags].flatten.join(' '), :outfile => filename(outfile) , :objs => filename(objfiles).join(' '), :libs => library_flags.join(' ') } + _run link_options, { :flags => all_flags(_library_paths, _flags), :outfile => filename(outfile) , :objs => filename(objfiles).join(' '), :libs => library_flags(_libraries) } end end -- cgit v1.2.3