Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Shellsplit build config
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Mar 28, 2019
1 parent 2167156 commit 70cb2f0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/bundler/installer/gem_installer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "shellwords"

module Bundler
class GemInstaller
attr_reader :spec, :standalone, :worker, :force, :installer
Expand Down Expand Up @@ -56,7 +58,9 @@ def gem_install_message

def spec_settings
# Fetch the build settings, if there are any
Bundler.settings["build.#{spec.name}"]
if settings = Bundler.settings["build.#{spec.name}"]
Shellwords.shellsplit(settings)
end
end

def install
Expand Down
11 changes: 11 additions & 0 deletions spec/bundler/installer/gem_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@
subject.install_from_spec
end
end

context "spec_settings is build option with spaces" do
it "invokes install method with build_args" do
allow(Bundler.settings).to receive(:[]).with(:bin)
allow(Bundler.settings).to receive(:[]).with(:inline)
allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy --with-another-dummy-config")
expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy", "--with-another-dummy-config"])
subject.install_from_spec
end
end
end
41 changes: 41 additions & 0 deletions spec/install/gems/native_extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,45 @@
run! "Bundler.require; puts CExtension.new.its_true"
expect(out).to eq("true")
end

it "install with multiple build flags" 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" && with_config("c_extension_bundle-dir") == "hola"
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 --with-c_extension_bundle-dir=hola"

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")

run! "Bundler.require; puts CExtension.new.its_true"
expect(out).to eq("true")
end
end

0 comments on commit 70cb2f0

Please sign in to comment.