diff --git a/.gitignore b/.gitignore index 41253a3..99d5489 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /ext/ilios/*.o /ext/ilios/mkmf.log /ext/ilios/Makefile +/ext/ilios/compile_flags.txt /ext/ilios/cpp-driver /ext/ilios/libuv /ext/ilios/ports diff --git a/ext/ilios/extconf.rb b/ext/ilios/extconf.rb index 8e512ce..23c1dbf 100644 --- a/ext/ilios/extconf.rb +++ b/ext/ilios/extconf.rb @@ -27,6 +27,21 @@ def num_cpu_cores cores >= 7 ? MAX_CORES : cores end +def create_compile_flags_txt + cppflags = $CPPFLAGS.split + include_flags = cppflags.select { |flag| flag.start_with?('-I') } + define_flags = cppflags.select { |flag| flag.start_with?('-D') } + $defs + + File.open('compile_flags.txt', 'w') do |f| + include_flags.each { |flag| f.puts(flag) } + f.puts("-I#{Dir.pwd}") + f.puts("-I#{RbConfig::CONFIG['rubyhdrdir']}") + f.puts("-I#{RbConfig::CONFIG['rubyhdrdir']}/ruby/backward") + f.puts("-I#{RbConfig::CONFIG['rubyarchhdrdir']}") + define_flags.each { |flag| f.puts(flag) } + end +end + module LibuvInstaller LIBUV_INSTALL_PATH = File.expand_path('libuv') private_constant :LIBUV_INSTALL_PATH @@ -146,3 +161,4 @@ def self.install_from_source $LDFLAGS += " #{ENV['LDFLAGS']}" create_makefile('ilios') +create_compile_flags_txt