diff options
author | Homu <homu@barosl.com> | 2016-02-25 13:29:08 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-02-25 13:29:08 +0900 |
commit | 43b31afde9628c211f5ebd82bb46cab5982a80c4 (patch) | |
tree | 8f927501510d151bfe1ec12db4b0260fa5c64202 /lib/bundler | |
parent | c1f6b0ca96a5593e99a7b9133aff88ade1e38918 (diff) | |
parent | 347c117793b4681416501e67ecb2c832709b37b4 (diff) | |
download | bundler-43b31afde9628c211f5ebd82bb46cab5982a80c4.tar.gz |
Auto merge of #4272 - bundler:git-extension-rebuild, r=segiddins
Skip building git gem extensions if they're already built
None
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 2 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 17 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 4 | ||||
-rw-r--r-- | lib/bundler/source/path.rb | 15 |
4 files changed, 30 insertions, 8 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 22c22a2d..2f36c29c 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -53,7 +53,7 @@ module Gem if method_defined?(:extension_dir) alias_method :rg_extension_dir, :extension_dir def extension_dir - @extension_dir ||= if source.respond_to?(:extension_dir_name) + @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name) File.expand_path(File.join(extensions_dir, source.extension_dir_name)) else rg_extension_dir diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 0f567db1..4e5ca7d1 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -54,10 +54,23 @@ module Bundler def validate(spec) Bundler.ui.silence { spec.validate(false) } + rescue Gem::InvalidSpecificationException => e + error_message = "The gemspec at #{spec.loaded_from} is not valid. Please fix this gemspec.\n" \ + "The validation error was '#{e.message}'\n" + raise Gem::InvalidSpecificationException.new(error_message) rescue Errno::ENOENT nil end + def set_installed_by_version(spec, installed_by_version = Gem::VERSION) + return unless spec.respond_to?(:installed_by_version=) + spec.installed_by_version = Gem::Version.create(installed_by_version) + end + + def spec_missing_extensions?(spec) + !spec.respond_to?(:missing_extensions?) || spec.missing_extensions? + end + def path(obj) obj.to_s end @@ -503,9 +516,7 @@ module Bundler # Missing summary is downgraded to a warning in later versions, # so we set it to an empty string to prevent an exception here. spec.summary ||= "" - Bundler.ui.silence { spec.validate(false) } - rescue Errno::ENOENT - nil + RubygemsIntegration.instance_method(:validate).bind(self).call(spec) end end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 90bbd13d..228ab61a 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -222,6 +222,10 @@ module Bundler private + def build_extensions(installer) + super if Bundler.rubygems.spec_missing_extensions?(installer.spec) + end + def serialize_gemspecs_in(destination) expanded_path = destination.expand_path(Bundler.root) Dir["#{expanded_path}/#{@glob}"].each do |spec_path| diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 6bfd2e88..9790ba51 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -135,9 +135,12 @@ module Bundler if File.directory?(expanded_path) # We sort depth-first since `<<` will override the earlier-found specs Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file| - next unless spec = Bundler.load_gemspec(file, :validate) - spec.loaded_from = file.to_s + next unless spec = Bundler.load_gemspec(file) spec.source = self + Bundler.rubygems.set_installed_by_version(spec) + # Validation causes extension_dir to be calculated, which depends + # on #source, so we validate here instead of load_gemspec + Bundler.rubygems.validate(spec) index << spec end @@ -194,8 +197,7 @@ module Bundler SharedHelpers.chdir(gem_dir) do installer = Path::Installer.new(spec, :env_shebang => false) run_hooks(:pre_install, installer) - installer.build_extensions unless disable_extensions - run_hooks(:post_build, installer) + build_extensions(installer) unless disable_extensions installer.generate_bin run_hooks(:post_install, installer) end @@ -213,6 +215,11 @@ module Bundler Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}" end + def build_extensions(installer) + installer.build_extensions + run_hooks(:post_build, installer) + end + def run_hooks(type, installer) hooks_meth = "#{type}_hooks" return unless Gem.respond_to?(hooks_meth) |