Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extconf.rb to cancel building the extension #7372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/rubygems/ext/ext_conf_builder.rb
Expand Up @@ -37,6 +37,10 @@ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_di
end
end

if File.exist?(File.join(extension_dir, "gem.build_skipped"))
return ["Skipping the extension build"]
end

ENV["DESTDIR"] = nil

make dest_path, results, extension_dir, tmp_dest_relative
Expand Down
21 changes: 21 additions & 0 deletions test/rubygems/test_gem_specification.rb
Expand Up @@ -1416,6 +1416,27 @@ def test_build_extensions_default_gem
assert_path_not_exist spec.extension_dir
end

def test_extconf_skip_build
ext_spec

assert_path_not_exist @ext.extension_dir, "sanity check"
refute_empty @ext.extensions, "sanity check"

extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
FileUtils.mkdir_p File.dirname extconf_rb

File.open extconf_rb, "w" do |f|
f.write <<-'RUBY'
File.write("gem.build_skipped", "")
File.write("Makefile", "syntax-error")
RUBY
end

@ext.build_extensions

assert_path_exist @ext.extension_dir
end

def test_build_extensions_error
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
Expand Down