Skip to content

Commit 0e92346

Browse files
committed
Don't worry about missing Makefile.
1 parent 76abc01 commit 0e92346

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

lib/rubygems/ext/builder.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
class Gem::Ext::Builder
1212
include Gem::UserInteraction
1313

14+
class NoMakefileError < Gem::InstallError
15+
end
16+
1417
attr_accessor :build_args # :nodoc:
1518

1619
def self.class_name
@@ -21,7 +24,8 @@ def self.class_name
2124
def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"],
2225
target_rbconfig: Gem.target_rbconfig)
2326
unless File.exist? File.join(make_dir, "Makefile")
24-
raise Gem::InstallError, "Makefile not found"
27+
# No makefile exists, nothing to do.
28+
raise NoMakefileError, "No Makefile found in #{make_dir}"
2529
end
2630

2731
# try to find make program from Ruby configure arguments first

lib/rubygems/ext/ext_conf_builder.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_di
6666
end
6767

6868
results
69+
rescue Gem::Ext::Builder::NoMakefileError => error
70+
results << error.message
71+
results << "Skipping make for #{extension} as no Makefile was found."
72+
# We are good, do not re-raise the error.
6973
ensure
7074
FileUtils.rm_rf tmp_dest if tmp_dest
7175
end

test/rubygems/test_gem_ext_ext_conf_builder.rb

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ def setup
1515
end
1616

1717
def test_class_build
18-
if Gem.java_platform?
19-
pend("failing on jruby")
20-
end
21-
2218
if vc_windows? && !nmake_found?
2319
pend("test_class_build skipped - nmake not found")
2420
end
2521

2622
File.open File.join(@ext, "extconf.rb"), "w" do |extconf|
23+
extconf.puts "return if Gem.java_platform?"
2724
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
2825
end
2926

@@ -35,20 +32,22 @@ def test_class_build
3532

3633
assert_match(/^current directory:/, output[0])
3734
assert_match(/^#{Regexp.quote(Gem.ruby)}.* extconf.rb/, output[1])
38-
assert_equal "creating Makefile\n", output[2]
39-
assert_match(/^current directory:/, output[3])
40-
assert_contains_make_command "clean", output[4]
41-
assert_contains_make_command "", output[7]
42-
assert_contains_make_command "install", output[10]
35+
36+
if Gem.java_platform?
37+
assert_includes(output, "Skipping make for extconf.rb as no Makefile was found.")
38+
else
39+
assert_equal "creating Makefile\n", output[2]
40+
assert_match(/^current directory:/, output[3])
41+
assert_contains_make_command "clean", output[4]
42+
assert_contains_make_command "", output[7]
43+
assert_contains_make_command "install", output[10]
44+
end
45+
4346
assert_empty Dir.glob(File.join(@ext, "siteconf*.rb"))
4447
assert_empty Dir.glob(File.join(@ext, ".gem.*"))
4548
end
4649

4750
def test_class_build_rbconfig_make_prog
48-
if Gem.java_platform?
49-
pend("failing on jruby")
50-
end
51-
5251
configure_args do
5352
File.open File.join(@ext, "extconf.rb"), "w" do |extconf|
5453
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
@@ -72,10 +71,6 @@ def test_class_build_env_make
7271
env_large_make = ENV.delete "MAKE"
7372
ENV["MAKE"] = "anothermake"
7473

75-
if Gem.java_platform?
76-
pend("failing on jruby")
77-
end
78-
7974
configure_args "" do
8075
File.open File.join(@ext, "extconf.rb"), "w" do |extconf|
8176
extconf.puts "require 'mkmf'\ncreate_makefile 'foo'"
@@ -206,11 +201,11 @@ def test_class_make
206201
end
207202

208203
def test_class_make_no_Makefile
209-
error = assert_raise Gem::InstallError do
204+
error = assert_raise Gem::Ext::Builder::NoMakefileError do
210205
Gem::Ext::ExtConfBuilder.make @ext, ["output"], @ext
211206
end
212207

213-
assert_equal "Makefile not found", error.message
208+
assert_match(/No Makefile found/, error.message)
214209
end
215210

216211
def configure_args(args = nil)

0 commit comments

Comments
 (0)