Revision
3340
Author
eloy.de.enige@gmail.com
Date
2010-01-26 11:48:59 -0800 (Tue, 26 Jan 2010)

Log Message

Allow the extensions to be compiled parallel.

Modified Paths

Diff

Modified: MacRuby/trunk/rakelib/builder.rake (3339 => 3340)


--- MacRuby/trunk/rakelib/builder.rake	2010-01-26 19:48:49 UTC (rev 3339)
+++ MacRuby/trunk/rakelib/builder.rake	2010-01-26 19:48:59 UTC (rev 3340)
@@ -337,28 +337,31 @@
 
 EXTENSIONS = ['ripper', 'digest', 'etc', 'readline', 'libyaml', 'fcntl', 'socket', 'zlib', 'bigdecimal', 'openssl', 'json'].sort
 def perform_extensions_target(target)
+  commands = []
   EXTENSIONS.map { |x| File.join('ext', x) }.each do |ext_dir|
     Dir.glob(File.join(ext_dir, '**/extconf.rb')) do |p|
+      cmd = []
       dir = File.dirname(p)
       Dir.chdir(dir) do
-        $stderr.puts "cd #{dir}"
         srcdir = File.join(*dir.split(File::SEPARATOR).map { |x| '..' })
         next if target == :clean and !File.exist?('Makefile')
         if !File.exist?('Makefile') or File.mtime('extconf.rb') > File.mtime('Makefile')
-          sh "#{srcdir}/miniruby -I#{srcdir} -I#{srcdir}/lib -r rbconfig -e \"RbConfig::CONFIG['libdir'] = '#{srcdir}'; require './extconf.rb'\""
+          cmd <<  "cd #{dir} && #{srcdir}/miniruby -I#{srcdir} -I#{srcdir}/lib -r rbconfig -e \"RbConfig::CONFIG['libdir'] = '#{srcdir}'; require './extconf.rb'\""
         end
-        line = "/usr/bin/make top_srcdir=#{srcdir} ruby=\"#{srcdir}/miniruby -I#{srcdir} -I#{srcdir}/lib\" extout=#{srcdir}/.ext hdrdir=#{srcdir}/include arch_hdrdir=#{srcdir}/include"
+        line = "cd #{dir} && /usr/bin/make top_srcdir=#{srcdir} ruby=\"#{srcdir}/miniruby -I#{srcdir} -I#{srcdir}/lib\" extout=#{srcdir}/.ext hdrdir=#{srcdir}/include arch_hdrdir=#{srcdir}/include"
         case target
           when :all
             line << " libdir=#{srcdir}"
           else
             line << " #{target}"
         end
-        sh line
-        rm_f 'Makefile' if target == :clean
+        cmd << line
+        cmd << 'rm -f Makefile' if target == :clean
+        commands << cmd
       end
     end
   end
+  Builder.parallel_execute(commands)
 end
 
 desc "Build extensions"