summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-02-09 04:55:41 +0000
committerSamuel Giddins <segiddins@segiddins.me>2017-02-12 15:28:51 -0800
commitf726047c1f05d231a58ebc6c670442b02d6d9e0b (patch)
treea684652f4c8fe4889e54ce6d1c247f01897e6438
parent16057c38b1a0809f145f8eb74cebbf5d1093b63b (diff)
downloadbundler-f726047c1f05d231a58ebc6c670442b02d6d9e0b.tar.gz
Auto merge of #5410 - bundler:seg-git-build-args, r=indirect
Properly set native extension build args for git gems Closes https://github.com/bundler/bundler/pull/5399 Closes https://github.com/bundler/bundler/issues/5401 (cherry picked from commit 74341aaaa949e914cd1cffb163cd99bdf14b91df)
-rw-r--r--lib/bundler/source/git.rb7
-rw-r--r--lib/bundler/source/path.rb13
-rw-r--r--spec/install/gems/native_extensions_spec.rb42
3 files changed, 56 insertions, 6 deletions
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index d1757a4a93..30ff27c446 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -161,7 +161,9 @@ module Bundler
local_specs
end
- def install(spec, force = false)
+ def install(spec, options = {})
+ force = options[:force]
+
Bundler.ui.info "Using #{version_message(spec)} from #{self}"
if requires_checkout? && !@copied && !force
@@ -170,7 +172,8 @@ module Bundler
serialize_gemspecs_in(install_path)
@copied = true
end
- generate_bin(spec, !Bundler.rubygems.spec_missing_extensions?(spec))
+ generate_bin_options = { :disable_extensions => !Bundler.rubygems.spec_missing_extensions?(spec), :build_args => options[:build_args] }
+ generate_bin(spec, generate_bin_options)
requires_checkout? ? spec.post_install_message : nil
end
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 87a490446c..4661a6d068 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -71,9 +71,9 @@ module Bundler
File.basename(expanded_path.to_s)
end
- def install(spec, force = false)
+ def install(spec, options = {})
Bundler.ui.info "Using #{version_message(spec)} from #{self}"
- generate_bin(spec, :disable_extensions)
+ generate_bin(spec, :disable_extensions => true)
nil # no post-install message
end
@@ -193,7 +193,7 @@ module Bundler
path
end
- def generate_bin(spec, disable_extensions = false)
+ def generate_bin(spec, options = {})
gem_dir = Pathname.new(spec.full_gem_path)
# Some gem authors put absolute paths in their gemspec
@@ -208,7 +208,12 @@ module Bundler
end
end.compact
- installer = Path::Installer.new(spec, :env_shebang => false, :disable_extensions => disable_extensions)
+ installer = Path::Installer.new(
+ spec,
+ :env_shebang => false,
+ :disable_extensions => options[:disable_extensions],
+ :build_args => options[:build_args]
+ )
installer.post_install
rescue Gem::InvalidSpecificationException => e
Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" \
diff --git a/spec/install/gems/native_extensions_spec.rb b/spec/install/gems/native_extensions_spec.rb
index 6134663fcc..15fd884432 100644
--- a/spec/install/gems/native_extensions_spec.rb
+++ b/spec/install/gems/native_extensions_spec.rb
@@ -47,4 +47,46 @@ describe "installing a gem with native extensions" do
run "Bundler.require; puts CExtension.new.its_true"
expect(out).to eq("true")
end
+
+ it "installs from git" do
+ build_git "c_extension" do |s|
+ s.extensions = ["ext/extconf.rb"]
+ s.write "ext/extconf.rb", <<-E
+ require "mkmf"
+ name = "c_extension_bundle"
+ dir_config(name)
+ raise "OMG" unless with_config("c_extension") == "hello"
+ create_makefile(name)
+ E
+
+ s.write "ext/c_extension.c", <<-C
+ #include "ruby.h"
+
+ VALUE c_extension_true(VALUE self) {
+ return Qtrue;
+ }
+
+ void Init_c_extension_bundle() {
+ VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
+ rb_define_method(c_Extension, "its_true", c_extension_true, 0);
+ }
+ C
+
+ s.write "lib/c_extension.rb", <<-C
+ require "c_extension_bundle"
+ C
+ end
+
+ bundle! "config build.c_extension --with-c_extension=hello"
+
+ install_gemfile! <<-G
+ gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
+ G
+
+ expect(out).not_to include("extconf.rb failed")
+ expect(out).to include("Using c_extension 1.0")
+
+ run! "Bundler.require; puts CExtension.new.its_true"
+ expect(out).to eq("true")
+ end
end