Permalink
Browse files

Moved the parallel_execute method to Builder and make it accept array…

…s of command arrays for dep. management.

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3339 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
alloy committed Jan 26, 2010
1 parent 71a58c5 commit 95da69a3d8e3f421d4b024c3e30e0425ac479912
Showing with 19 additions and 16 deletions.
  1. +1 −16 rakelib/builder.rake
  2. +18 −0 rakelib/builder.rb
View
@@ -399,21 +399,6 @@ AOT_STDLIB = [
'lib/yaml/rubytypes.rb',
]
namespace :stdlib do
- # Runs the given array of +commands+ in parallel. The amount of spawned
- # simultaneous jobs is determined by the `j' env variable and defaults to 1.
- def parallel_execute(commands)
- @jobs ||= ENV['j'] ? ENV['j'].to_i : 1
- commands = commands.dup
-
- Array.new(@jobs) do
- Thread.new do
- while command = commands.shift
- sh command
- end
- end
- end.each { |t| t.join }
- end
-
desc "AOT compile the stdlib"
task :build => [:miniruby, 'macruby:dylib'] do
archf = ARCHS.map { |x| "--arch #{x}" }.join(' ')
@@ -425,7 +410,7 @@ namespace :stdlib do
end
end
end.flatten.compact
- parallel_execute(commands)
+ Builder.parallel_execute(commands)
end
desc "Touch .rbo files to ignore their build"
View
@@ -124,6 +124,24 @@ def do_option(name, default)
}
class Builder
+ # Runs the given array of +commands+ in parallel. The amount of spawned
+ # simultaneous jobs is determined by the `j' env variable and defaults to 1.
+ #
+ # When the members of the +commands+ array are in turn arrays of strings,
+ # then those commands will be executed in consecutive order.
+ def self.parallel_execute(commands)
+ @jobs ||= ENV['j'] ? ENV['j'].to_i : 1
+ commands = commands.dup
+
+ Array.new(@jobs) do |i|
+ Thread.new do
+ while c = commands.shift
+ Array(c).each { |command| sh(command) }
+ end
+ end
+ end.each { |t| t.join }
+ end
+
attr_reader :objs, :cflags, :cxxflags
attr_accessor :objc_cflags, :ldflags, :dldflags

0 comments on commit 95da69a

Please sign in to comment.