Permalink
Browse files

builder.rb: command line macros

* lib/rubygems/ext/builder.rb (Gem::Ext::Builder.make): pass dest_path
  by command line macros, not editing generated Makefile.  [Bug #7698]
  • Loading branch information...
1 parent 4d4cf72 commit 83e01ec2bd2131f751c60e73f50c07c5c7455010 @nobu nobu committed with drbrain Feb 28, 2013
@@ -16,12 +16,6 @@ def self.make(dest_path, results)
raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
end
- mf = Gem.read_binary 'Makefile'
- mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
- mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
-
- File.open('Makefile', 'wb') {|f| f.print mf}
-
# try to find make program from Ruby configure arguments first
RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
make_program = $1 || ENV['MAKE'] || ENV['make']
@@ -13,11 +13,20 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
def self.build(extension, directory, dest_path, results, args=[])
pwd = Dir.pwd
- cmd = "#{Gem.ruby} #{File.join pwd, File.basename(extension)}"
+ cmd = "#{Gem.ruby} -r./siteconf #{File.join pwd, File.basename(extension)}"
cmd << " #{args.join ' '}" unless args.empty?
Dir.mktmpdir("gem-install.") do |tmpdir|
Dir.chdir(tmpdir) do
+ open("siteconf.rb", "w") do |f|
+ f.puts "require 'rbconfig'"
+ f.puts "dest_path = #{dest_path.dump}"
+ %w[sitearchdir sitelibdir].each do |dir|
+ f.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path"
+ f.puts "RbConfig::CONFIG['#{dir}'] = dest_path"
+ end
+ end
+
begin
run cmd, results
@@ -134,12 +134,6 @@ def test_class_make
assert_equal make_command, output[0]
assert_equal "#{make_command} install", output[2]
-
- edited_makefile = Gem.read_binary makefile_path
- edited_makefile.gsub!(/\r/, '') if Gem.win_platform?
-
- assert_match "\nRUBYARCHDIR = #{@ext}$(target_prefix)\n", edited_makefile
- assert_match "\nRUBYLIBDIR = #{@ext}$(target_prefix)\n", edited_makefile
end
def test_class_make_no_Makefile

0 comments on commit 83e01ec

Please sign in to comment.