Files
mruby-mruby/tasks/libmruby.rake
T
dearblue 4c25ace8b3 Expose all header files of the gems for small compilation
After building mruby, if the user compiles and links to `libmruby.a`, expose the included directory of the captured gems.
This is a change to the `<build-dir> /lib/libmruby.flags.mak` file and will result in being added to `bin/mruby-config --cflags`.
This eliminates the need for the user to look up the path and add the compiler flag if the user wants to take advantage of her gems publishing features.

In the main build with `rake CONFIG=...`, there is no problem because it can only be seen from the gems that depends directly and indirectly as before.
However, when compiling independently by the user using `bin/mruby-config`, a header file name collision may occur if a unique header directory is added.
2021-08-09 21:16:45 +09:00

40 lines
1.4 KiB
Ruby

MRuby.each_target do
file libmruby_core_static => libmruby_core_objs.flatten do |t|
archiver.run t.name, t.prerequisites
end
products << libmruby_core_static
next unless libmruby_enabled?
file libmruby_static => libmruby_objs.flatten do |t|
archiver.run t.name, t.prerequisites
end
file "#{build_dir}/lib/libmruby.flags.mak" => [__FILE__, libmruby_static] do |t|
mkdir_p File.dirname t.name
open(t.name, 'w') do |f|
gemincs = gems.map { |g| g.export_include_paths.map { |n| g.filename(n) } }.flatten.uniq
f.puts "MRUBY_CFLAGS = #{cc.all_flags([], gemincs)}"
f.puts "MRUBY_CC = #{cc.command}"
f.puts "MRUBY_LD = #{linker.command}"
libgems = gems.reject{|g| g.bin?}
gem_flags = libgems.map {|g| g.linker.flags }
gem_library_paths = libgems.map {|g| g.linker.library_paths }
f.puts "MRUBY_LDFLAGS = #{linker.all_flags(gem_library_paths, gem_flags)} #{linker.option_library_path % "#{build_dir}/lib"}"
gem_flags_before_libraries = libgems.map {|g| g.linker.flags_before_libraries }
f.puts "MRUBY_LDFLAGS_BEFORE_LIBS = #{[linker.flags_before_libraries, gem_flags_before_libraries].flatten.join(' ')}"
gem_libraries = libgems.map {|g| g.linker.libraries }
f.puts "MRUBY_LIBS = #{linker.option_library % 'mruby'} #{linker.library_flags(gem_libraries)}"
f.puts "MRUBY_LIBMRUBY_PATH = #{libmruby_static}"
end
end
products << libmruby_static
end