1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Parallel gem configuration

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-01-26 08:19:34 +00:00
parent 17ee91960f
commit 72ad0019ba
3 changed files with 54 additions and 67 deletions

View file

@ -219,7 +219,7 @@ $(EXTS_MK): ext/configure-ext.mk $(TIMESTAMPDIR)/.$(arch).time $(srcdir)/templat
ext/configure-ext.mk: $(PREP) all-incs $(MKFILES) $(RBCONFIG) $(LIBRUBY) ext/configure-ext.mk: $(PREP) all-incs $(MKFILES) $(RBCONFIG) $(LIBRUBY)
$(ECHO) generating makefiles $@ $(ECHO) generating makefiles $@
$(Q)$(MAKEDIRS) ext $(Q)$(MAKEDIRS) $(@D)
$(Q)$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -o $@ -c \ $(Q)$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -o $@ -c \
$(srcdir)/template/$(@F).tmpl --srcdir="$(srcdir)" \ $(srcdir)/template/$(@F).tmpl --srcdir="$(srcdir)" \
--miniruby="$(MINIRUBY)" --script-args='$(SCRIPT_ARGS)' --miniruby="$(MINIRUBY)" --script-args='$(SCRIPT_ARGS)'

View file

@ -486,7 +486,13 @@ for dir in ["ext", File::join($top_srcdir, "ext")]
end end
end unless $extstatic end unless $extstatic
ext_prefix = "#{$top_srcdir}/ext" @gemname = nil
if ARGV[0]
ext_prefix, exts = ARGV.shift.split('/', 2)
$extension = [exts] if exts
@gemname = exts if ext_prefix == 'gems'
end
ext_prefix = "#{$top_srcdir}/#{ext_prefix || 'ext'}"
exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t} exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t}
default_exclude_exts = default_exclude_exts =
case case
@ -525,6 +531,7 @@ cond = proc {|ext, *|
exts.delete_if {|d| File.fnmatch?("-*", d)} exts.delete_if {|d| File.fnmatch?("-*", d)}
end end
end end
ext_prefix = File.basename(ext_prefix)
if $extout if $extout
extout = RbConfig.expand("#{$extout}", RbConfig::CONFIG.merge("topdir"=>$topdir)) extout = RbConfig.expand("#{$extout}", RbConfig::CONFIG.merge("topdir"=>$topdir))
@ -533,55 +540,20 @@ if $extout
end end
end end
FileUtils.makedirs('gems')
ext_prefix = "#$top_srcdir/gems"
gems = Dir.glob(File.join(ext_prefix, ($extension || ''), '**/extconf.rb')).collect {|d|
d = File.dirname(d)
d.slice!(0, ext_prefix.length + 1)
d
}.find_all {|ext|
with_config(ext, &cond)
}.sort
extend Module.new { extend Module.new {
def timestamp_file(name, target_prefix = nil) def timestamp_file(name, target_prefix = nil)
if @gemname and name == '$(TARGET_SO_DIR)'
name = "$(arch)/gems/#{@gemname}#{target_prefix}"
end
super.sub(%r[/\.extout\.(?:-\.)?], '/.') super.sub(%r[/\.extout\.(?:-\.)?], '/.')
end end
def configuration(srcdir) def configuration(srcdir)
super << "EXTSO #{['=', $extso].join(' ')}\n" super << "EXTSO #{['=', $extso].join(' ')}\n"
end end
}
dir = Dir.pwd def create_makefile(*args, &block)
FileUtils::makedirs('ext') return super unless @gemname
Dir::chdir('ext')
hdrdir = $hdrdir
$hdrdir = ($top_srcdir = relative_from(srcdir, $topdir = "..")) + "/include"
extso = []
fails = []
exts.each do |d|
$static = $force_static ? true : $static_ext[d]
if $ignore or !$nodynamic or $static
result = extmake(d) or abort
extso |= $extso
fails << result unless result == true
end
end
Dir.chdir('..')
FileUtils::makedirs('gems')
Dir.chdir('gems')
extout = $extout
unless gems.empty?
def self.timestamp_file(name, target_prefix = nil)
name = "$(arch)/gems/#{@gemname}#{target_prefix}" if name == '$(TARGET_SO_DIR)'
super
end
def self.create_makefile(*args, &block)
super(*args) do |conf| super(*args) do |conf|
conf.find do |s| conf.find do |s|
s.sub!(/^(TARGET_SO_DIR *= *)\$\(RUBYARCHDIR\)/) { s.sub!(/^(TARGET_SO_DIR *= *)\$\(RUBYARCHDIR\)/) {
@ -604,15 +576,25 @@ $(build_complete): $(TARGET_SO)
conf conf
end end
end end
}
dir = Dir.pwd
FileUtils::makedirs(ext_prefix)
Dir::chdir(ext_prefix)
hdrdir = $hdrdir
$hdrdir = ($top_srcdir = relative_from(srcdir, $topdir = "..")) + "/include"
extso = []
fails = []
exts.each do |d|
$static = $force_static ? true : $static_ext[d]
if $ignore or !$nodynamic or $static
result = extmake(d, ext_prefix) or abort
extso |= $extso
fails << result unless result == true
end
end end
gems.each do |d|
$extout = extout.dup
@gemname = d[%r{\A[^/]+}]
extmake(d, 'gems')
extso |= $extso
end
$extout = extout
Dir.chdir('../ext')
$top_srcdir = srcdir $top_srcdir = srcdir
$topdir = "." $topdir = "."
@ -700,8 +682,7 @@ $makeflags.uniq!
$mflags.unshift("topdir=#$topdir") $mflags.unshift("topdir=#$topdir")
ENV.delete("RUBYOPT") ENV.delete("RUBYOPT")
if $configure_only and $command_output if $configure_only and $command_output
exts.map! {|d| "ext/#{d}/."} exts.map! {|d| "#{ext_prefix}/#{d}/."}
gems.map! {|d| "gems/#{d}/."}
FileUtils.makedirs(File.dirname($command_output)) FileUtils.makedirs(File.dirname($command_output))
atomic_write_open($command_output) do |mf| atomic_write_open($command_output) do |mf|
mf.puts "V = 0" mf.puts "V = 0"
@ -728,7 +709,6 @@ if $configure_only and $command_output
end end
mf.macro "extensions", exts mf.macro "extensions", exts
mf.macro "gems", gems
mf.macro "EXTOBJS", $extlist.empty? ? ["dmyext.#{$OBJEXT}"] : ["ext/extinit.#{$OBJEXT}", *$extobjs] mf.macro "EXTOBJS", $extlist.empty? ? ["dmyext.#{$OBJEXT}"] : ["ext/extinit.#{$OBJEXT}", *$extobjs]
mf.macro "EXTLIBS", $extlibs mf.macro "EXTLIBS", $extlibs
mf.macro "EXTSO", extso mf.macro "EXTSO", extso
@ -753,14 +733,13 @@ if $configure_only and $command_output
targets = %w[all install static install-so install-rb clean distclean realclean] targets = %w[all install static install-so install-rb clean distclean realclean]
targets.each do |tgt| targets.each do |tgt|
mf.puts "#{tgt}: $(extensions:/.=/#{tgt})" mf.puts "#{tgt}: $(extensions:/.=/#{tgt})"
mf.puts "#{tgt}: $(gems:/.=/#{tgt})" unless tgt == 'static'
mf.puts "#{tgt}: note" unless /clean\z/ =~ tgt mf.puts "#{tgt}: note" unless /clean\z/ =~ tgt
end end
mf.puts mf.puts
mf.puts "clean:\n\t-$(Q)$(RM) ext/extinit.#{$OBJEXT}" mf.puts "clean:\n\t-$(Q)$(RM) ext/extinit.#{$OBJEXT}"
mf.puts "distclean:\n\t-$(Q)$(RM) ext/extinit.c" mf.puts "distclean:\n\t-$(Q)$(RM) ext/extinit.c"
mf.puts mf.puts
mf.puts "#{rubies.join(' ')}: $(extensions:/.=/#{$force_static ? 'static' : 'all'}) $(gems:/.=/all)" mf.puts "#{rubies.join(' ')}: $(extensions:/.=/#{$force_static ? 'static' : 'all'})"
submake = "$(Q)$(MAKE) $(MFLAGS) $(SUBMAKEOPTS)" submake = "$(Q)$(MAKE) $(MFLAGS) $(SUBMAKEOPTS)"
mf.puts "all static: #{rubies.join(' ')}\n" unless $configure_only == 'sub' mf.puts "all static: #{rubies.join(' ')}\n" unless $configure_only == 'sub'
$extobjs.each do |tgt| $extobjs.each do |tgt|
@ -780,9 +759,8 @@ if $configure_only and $command_output
config_string("exec") {|str| submake << str << " "} config_string("exec") {|str| submake << str << " "}
submake << "$(MAKE)" submake << "$(MAKE)"
end end
gems = exts + gems
targets.each do |tgt| targets.each do |tgt|
(tgt == 'static' ? exts : gems).each do |d| exts.each do |d|
mf.puts "#{d[0..-2]}#{tgt}:\n\t$(Q)#{submake} $(MFLAGS) V=$(V) $(@F)" mf.puts "#{d[0..-2]}#{tgt}:\n\t$(Q)#{submake} $(MFLAGS) V=$(V) $(@F)"
end end
end end

View file

@ -13,20 +13,29 @@ opt = OptionParser.new do |o|
o.order!(ARGV) o.order!(ARGV)
end end
srcdir ||= File.dirname(File.dirname(__FILE__)) srcdir ||= File.dirname(File.dirname(__FILE__))
exts = Dir.glob("#{srcdir}/ext/*/").map(&File.method(:basename)) exts = {}
[["ext", "exts"], ["gems", "gems"]].each do |t, dir|
exts[t] = Dir.glob("#{srcdir}/#{dir}/*/").map {|n| n[(srcdir.size+1)..-1]}
end
%> %>
MINIRUBY = <%=miniruby%> MINIRUBY = <%=miniruby%>
SCRIPT_ARGS = <%=script_args%> SCRIPT_ARGS = <%=script_args%>
EXTMK_ARGS = $(SCRIPT_ARGS) --extstatic $(EXTSTATIC) \
--gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
all: all: exts gems
% exts.each do |dir| exts:
all: ext/<%=dir%>/exts.mk gems:
ext/<%=dir%>/exts.mk: FORCE
$(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make='$(MAKE)' --command-output=ext/<%=dir%>/exts.mk \ % exts.each do |t, dirs|
$(SCRIPT_ARGS) --extension=<%=dir%> --extstatic $(EXTSTATIC) \ % dirs.each do |dir|
--gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \ <%=t%>: <%=dir%>/exts.mk
-- subconfigure <%=dir%>/exts.mk: FORCE
$(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make='$(MAKE)' \
--command-output=$@ $(EXTMK_ARGS) \
-- subconfigure $(@D)
% end
% end % end
.PHONY: FORCE .PHONY: FORCE all exts gems
FORCE: FORCE: