lib/mkmf/lite.rb in mkmf-lite-0.6.0 vs lib/mkmf/lite.rb in mkmf-lite-0.7.0

- old
+ new

@@ -14,14 +14,18 @@ # Mkmf module in the standard library. module Lite extend Memoist # The version of the mkmf-lite library - MKMF_LITE_VERSION = '0.6.0' + MKMF_LITE_VERSION = '0.7.0' private + def cpp_defs + RbConfig::CONFIG['DEFS'] + end + # rubocop:disable Layout/LineLength def cpp_command command = RbConfig::CONFIG['CC'] || RbConfig::CONFIG['CPP'] || File.which('cc') || File.which('gcc') || File.which('cl') raise 'Compiler not found' unless command command @@ -42,15 +46,15 @@ end end memoize :cpp_out_file - # TODO: We should adjust this based on OS. For now we're using - # arguments I think you'll typically see set on Linux and BSD. def cpp_libraries - if RbConfig::CONFIG['LIBS'] - RbConfig::CONFIG['LIBS'] + RbConfig::CONFIG['LIBRUBYARG'] + return if File::ALT_SEPARATOR && RbConfig::CONFIG['CPP'] =~ /^cl/ + + if cpp_command =~ /clang/i + '-Lrt -Ldl -Lcrypt -Lm' else '-lrt -ldl -lcrypt -lm' end end @@ -203,11 +207,11 @@ stdout_orig = $stdout.dup Dir.chdir(Dir.tmpdir) do File.write(cpp_source_file, code) - command = "#{cpp_command} " + command = "#{cpp_command} #{cpp_libraries} #{cpp_defs} " command += "#{cpp_out_file} " command += cpp_source_file # Temporarily close these $stderr.reopen(IO::NULL) @@ -252,12 +256,12 @@ Dir.chdir(Dir.tmpdir) do File.write(cpp_source_file, code) if command_options - command = "#{cpp_command} #{command_options} " + command = "#{cpp_command} #{command_options} #{cpp_libraries} #{cpp_defs} " else - command = "#{cpp_command} " + command = "#{cpp_command} #{cpp_libraries} #{cpp_defs} " end command += "#{cpp_out_file} " command += cpp_source_file