summaryrefslogtreecommitdiff
blob: 5ab58723d8ad824ac57034f4c80ba7408a1cb030 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
--- trunk/lib/rubygems/installer.rb	2006/08/10 18:06:59	1060
+++ trunk/lib/rubygems/installer.rb	2006/08/10 18:15:28	1062
@@ -292,9 +292,12 @@
       say "Building native extensions.  This could take a while..."
       start_dir = Dir.pwd
       dest_path = File.join(directory, spec.require_paths[0])
+      ran_rake = false # only run rake once
 
-      results = []
       spec.extensions.each do |extension|
+        break if ran_rake
+        results = []
+
         case extension
         when /extconf/ then
           builder = ExtExtConfBuilder
@@ -302,6 +305,7 @@
           builder = ExtConfigureBuilder
         when /rakefile/i then
           builder = ExtRakeBuilder
+          ran_rake = true
         else
           builder = nil
           results = ["No builder for extension '#{extension}'"]
@@ -310,7 +314,7 @@
         begin
           err = false
           Dir.chdir File.join(directory, File.dirname(extension))
-          results = builder.build(extension, directory, dest_path)
+          results = builder.build(extension, directory, dest_path, results)
         rescue => ex
           err = true
         end
@@ -551,29 +555,27 @@
   end  # class Uninstaller
 
   class ExtConfigureBuilder
-    def self.build(extension, directory, dest_path)
-      results = []
+    def self.build(extension, directory, dest_path, results)
       unless File.exist?('Makefile') then
         cmd = "sh ./configure --prefix=#{dest_path}"
         results << cmd
         results << `#{cmd}`
       end
 
-      results.push(*ExtExtConfBuilder.make(dest_path))
+      ExtExtConfBuilder.make(dest_path, results)
       results
     end
   end
 
   class ExtExtConfBuilder
-    def self.build(extension, directory, dest_path)
-      results = ["#{Gem.ruby} #{File.basename(extension)} #{ARGV.join(" ")}"]
+    def self.build(extension, directory, dest_path, results)
+      results << "#{Gem.ruby} #{File.basename(extension)} #{ARGV.join(" ")}"
       results << `#{Gem.ruby} #{File.basename(extension)} #{ARGV.join(" ")}`
-      results.push(*make(dest_path))
+      make(dest_path, results)
       results
     end
 
-    def self.make(dest_path)
-      results = []
+    def self.make(dest_path, results)
       raise unless File.exist?('Makefile')
       mf = File.read('Makefile')
       mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
@@ -585,27 +587,25 @@
         make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
       end
 
-      ['', 'install', 'clean'].each do |target|
+      ['', 'install'].each do |target|
         results << "#{make_program} #{target}".strip
         results << `#{make_program} #{target}`
-      end
 
-      results
+        raise unless $?.exitstatus.zero?
+      end
     end
 
   end
 
   class ExtRakeBuilder
-    def ExtRakeBuilder.build(ext, directory, dest_path)
+    def ExtRakeBuilder.build(ext, directory, dest_path, results)
       make_program = ENV['rake'] || 'rake'
       make_program += " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"
 
-      results = []
+      results << "#{make_program} extension".strip
+      results << `#{make_program} extension`
 
-      ['', 'install', 'clean'].each do |target|
-        results << "#{make_program} #{target}".strip
-        results << `#{make_program} #{target}`
-      end
+      raise unless $?.exitstatus.zero?
 
       results
     end