summaryrefslogtreecommitdiff
path: root/lib/rubygems/ext
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-16 00:14:16 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-16 00:14:16 +0000
commit28918eac58eb6e2681d10839ac0d1430b2a4f1f9 (patch)
tree3c2c9e36118efe1d9406acdd14c186788879bea3 /lib/rubygems/ext
parentcfe1458078b8cf36e490c516977c52e1faa9e88a (diff)
* lib/rubygems: Update to RubyGems master commit 2a74263. This fixes
several bugs in RubyGems 2.2.0.preview.1. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/ext')
-rw-r--r--lib/rubygems/ext/build_error.rb6
-rw-r--r--lib/rubygems/ext/builder.rb61
-rw-r--r--lib/rubygems/ext/cmake_builder.rb3
3 files changed, 56 insertions, 14 deletions
diff --git a/lib/rubygems/ext/build_error.rb b/lib/rubygems/ext/build_error.rb
new file mode 100644
index 0000000000..bfe85ffc11
--- /dev/null
+++ b/lib/rubygems/ext/build_error.rb
@@ -0,0 +1,6 @@
+##
+# Raised when there is an error while building extensions.
+
+class Gem::Ext::BuildError < Gem::InstallError
+end
+
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index 8c05723573..069ab4cfe0 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -19,6 +19,11 @@ class Gem::Ext::Builder
CHDIR_MUTEX = Mutex.new # :nodoc:
+ ##
+ # `make` targets to run when building the extension
+
+ MAKE_TARGETS = ['clean', '', 'install'] # :nodoc:
+
attr_accessor :build_args # :nodoc:
def self.class_name
@@ -28,7 +33,7 @@ class Gem::Ext::Builder
def self.make(dest_path, results)
unless File.exist? 'Makefile' then
- raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
+ raise Gem::InstallError, 'Makefile not found'
end
# try to find make program from Ruby configure arguments first
@@ -40,7 +45,7 @@ class Gem::Ext::Builder
destdir = '"DESTDIR=%s"' % ENV['DESTDIR'] if RUBY_VERSION > '2.0'
- ['', 'install'].each do |target|
+ self::MAKE_TARGETS.each do |target|
# Pass DESTDIR via command line to override what's in MAKEFLAGS
cmd = [
make_program,
@@ -74,15 +79,24 @@ class Gem::Ext::Builder
unless $?.success? then
results << "Building has failed. See above output for more information on the failure." if verbose
- raise Gem::InstallError, "#{command_name || class_name} failed:\n\n#{results.join "\n"}"
+
+ exit_reason =
+ if $?.exited? then
+ ", exit code #{$?.exitstatus}"
+ elsif $?.signaled? then
+ ", uncaught signal #{$?.termsig}"
+ end
+
+ raise Gem::InstallError, "#{command_name || class_name} failed#{exit_reason}"
end
end
##
- # Creates a new extension builder for +spec+ using the given +build_args+.
- # The gem for +spec+ is unpacked in +gem_dir+.
+ # Creates a new extension builder for +spec+. If the +spec+ does not yet
+ # have build arguments, saved, set +build_args+ which is an ARGV-style
+ # array.
- def initialize spec, build_args
+ def initialize spec, build_args = spec.build_args
@spec = spec
@build_args = build_args
@gem_dir = spec.gem_dir
@@ -113,12 +127,10 @@ class Gem::Ext::Builder
end
##
- # Logs the build +output+ in +build_dir+, then raises ExtensionBuildError.
+ # Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError.
def build_error build_dir, output, backtrace = nil # :nodoc:
- gem_make_out = File.join build_dir, 'gem_make.out'
-
- open gem_make_out, 'wb' do |io| io.puts output end
+ gem_make_out = write_gem_make_out output
message = <<-EOF
ERROR: Failed to build gem native extension.
@@ -129,14 +141,15 @@ Gem files will remain installed in #{@gem_dir} for inspection.
Results logged to #{gem_make_out}
EOF
- raise Gem::Installer::ExtensionBuildError, message, backtrace
+ raise Gem::Ext::BuildError, message, backtrace
end
def build_extension extension, dest_path # :nodoc:
results = []
extension ||= '' # I wish I knew why this line existed
- extension_dir = File.join @gem_dir, File.dirname(extension)
+ extension_dir =
+ File.expand_path File.join @gem_dir, File.dirname(extension)
builder = builder_for extension
@@ -151,7 +164,10 @@ EOF
say results.join("\n") if Gem.configuration.really_verbose
end
end
- rescue
+
+ write_gem_make_out results.join "\n"
+ rescue => e
+ results << e.message
build_error extension_dir, results.join("\n"), $@
end
end
@@ -170,7 +186,9 @@ EOF
say "This could take a while..."
end
- dest_path = File.join @gem_dir, @spec.require_paths.first
+ dest_path = @spec.extension_install_dir
+
+ FileUtils.rm_f @spec.gem_build_complete_path
@ran_rake = false # only run rake once
@@ -179,6 +197,21 @@ EOF
build_extension extension, dest_path
end
+
+ FileUtils.touch @spec.gem_build_complete_path
+ end
+
+ ##
+ # Writes +output+ to gem_make.out in the extension install directory.
+
+ def write_gem_make_out output # :nodoc:
+ destination = File.join @spec.extension_install_dir, 'gem_make.out'
+
+ FileUtils.mkdir_p @spec.extension_install_dir
+
+ open destination, 'wb' do |io| io.puts output end
+
+ destination
end
end
diff --git a/lib/rubygems/ext/cmake_builder.rb b/lib/rubygems/ext/cmake_builder.rb
index d6d106f4ae..8bd82dafe2 100644
--- a/lib/rubygems/ext/cmake_builder.rb
+++ b/lib/rubygems/ext/cmake_builder.rb
@@ -1,4 +1,7 @@
class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
+
+ MAKE_TARGETS = ['', 'install'] # :nodoc:
+
def self.build(extension, directory, dest_path, results)
unless File.exist?('Makefile') then
cmd = "cmake . -DCMAKE_INSTALL_PREFIX=#{dest_path}"