mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Parallel ext configuration
* ext/configure-ext.mk: configure each directories underneath ext in parallel. * template/exts.mk.tmpl: then collect the results. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ee9f6fdfad
commit
17b748df2b
7 changed files with 148 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -137,6 +137,8 @@ y.tab.c
|
|||
|
||||
# /ext/
|
||||
/ext/extinit.c
|
||||
/ext/configure-ext.mk
|
||||
/ext/*/exts.mk
|
||||
|
||||
# /ext/-test-/win32/dln/
|
||||
/ext/-test-/win32/dln/dlntest.exp
|
||||
|
|
|
@ -432,7 +432,7 @@ clean-ext distclean-ext realclean-ext::
|
|||
-$(Q)$(RM) ext/extinit.$(OBJEXT)
|
||||
|
||||
distclean-ext realclean-ext::
|
||||
-$(Q)$(RM) ext/extinit.c
|
||||
-$(Q)$(RM) ext/extinit.c ext/configure-ext.mk ext/*/exts.mk
|
||||
-$(Q)$(RMDIR) ext 2> /dev/null || true
|
||||
|
||||
clean-extout:
|
||||
|
|
14
common.mk
14
common.mk
|
@ -210,9 +210,19 @@ showconfig:
|
|||
exts: build-ext
|
||||
|
||||
EXTS_MK = exts.mk
|
||||
$(EXTS_MK): $(MKFILES) all-incs $(PREP) $(RBCONFIG) $(LIBRUBY) $(TIMESTAMPDIR)/.$(arch).time
|
||||
$(EXTS_MK): ext/configure-ext.mk $(TIMESTAMPDIR)/.$(arch).time $(srcdir)/template/exts.mk.tmpl
|
||||
$(MAKE) -f ext/configure-ext.mk V=$(V) MINIRUBY='$(MINIRUBY)' \
|
||||
SCRIPT_ARGS='$(SCRIPT_ARGS)' EXTSTATIC=$(EXTSTATIC) \
|
||||
gnumake=$(gnumake) EXTLDFLAGS="$(EXTLDFLAGS)" srcdir="$(srcdir)"
|
||||
$(ECHO) generating makefile $@
|
||||
$(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$(EXTS_MK) $(EXTMK_ARGS) configure
|
||||
$(Q)$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -o $@ -c \
|
||||
$(srcdir)/template/exts.mk.tmpl
|
||||
|
||||
ext/configure-ext.mk: $(PREP) all-incs $(MKFILES) $(RBCONFIG) $(LIBRUBY)
|
||||
$(ECHO) generating makefiles $@
|
||||
$(Q)$(MAKEDIRS) ext
|
||||
$(Q)$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -o $@ -c \
|
||||
$(srcdir)/template/$(@F).tmpl --srcdir="$(srcdir)"
|
||||
|
||||
configure-ext: $(EXTS_MK)
|
||||
|
||||
|
|
|
@ -421,7 +421,8 @@ if target = ARGV.shift and /^[a-z-]+$/ =~ target
|
|||
"INSTALL_DATA=install -c -p -m 0644",
|
||||
"MAKEDIRS=mkdir -p") if $dryrun
|
||||
when /configure/
|
||||
$configure_only = true
|
||||
target = target.sub(/^sub/, '')
|
||||
$configure_only = $& || true
|
||||
end
|
||||
end
|
||||
unless $message
|
||||
|
@ -674,7 +675,7 @@ unless $extlist.empty?
|
|||
].map {|n, v|
|
||||
"#{n}=#{v}" if v &&= v[/\S(?:.*\S)?/]
|
||||
}.compact
|
||||
puts(*conf)
|
||||
puts(*conf) unless $configure_only == 'sub'
|
||||
$stdout.flush
|
||||
$mflags.concat(conf)
|
||||
$makeflags.concat(conf)
|
||||
|
@ -701,6 +702,7 @@ ENV.delete("RUBYOPT")
|
|||
if $configure_only and $command_output
|
||||
exts.map! {|d| "ext/#{d}/."}
|
||||
gems.map! {|d| "gems/#{d}/."}
|
||||
FileUtils.makedirs(File.dirname($command_output))
|
||||
atomic_write_open($command_output) do |mf|
|
||||
mf.puts "V = 0"
|
||||
mf.puts "Q1 = $(V:1=)"
|
||||
|
@ -760,7 +762,7 @@ if $configure_only and $command_output
|
|||
mf.puts
|
||||
mf.puts "#{rubies.join(' ')}: $(extensions:/.=/#{$force_static ? 'static' : 'all'}) $(gems:/.=/all)"
|
||||
submake = "$(Q)$(MAKE) $(MFLAGS) $(SUBMAKEOPTS)"
|
||||
mf.puts "all static: #{rubies.join(' ')}\n"
|
||||
mf.puts "all static: #{rubies.join(' ')}\n" unless $configure_only == 'sub'
|
||||
$extobjs.each do |tgt|
|
||||
mf.puts "#{tgt}: #{File.dirname(tgt)}/static"
|
||||
end
|
||||
|
|
27
template/configure-ext.mk.tmpl
Normal file
27
template/configure-ext.mk.tmpl
Normal file
|
@ -0,0 +1,27 @@
|
|||
V = 0
|
||||
Q1 = $(V:1=)
|
||||
Q = $(Q1:0=@)
|
||||
ECHO1 = $(V:1=@:)
|
||||
ECHO = $(ECHO1:0=@echo)
|
||||
|
||||
<%
|
||||
srcdir = miniruby = nil
|
||||
opt = OptionParser.new do |o|
|
||||
o.on('--srcdir=SRCDIR') {|v| srcdir = v}
|
||||
o.on('--miniruby=MINIRUBY') {|v| miniruby = v}
|
||||
o.order!(ARGV)
|
||||
end
|
||||
srcdir ||= File.dirname(File.dirname(__FILE__))
|
||||
exts = Dir.glob("#{srcdir}/ext/*/").map(&File.method(:basename))
|
||||
%>
|
||||
all:
|
||||
% exts.each do |dir|
|
||||
all: ext/<%=dir%>/exts.mk
|
||||
ext/<%=dir%>/exts.mk: FORCE
|
||||
$(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=ext/<%=dir%>/exts.mk \
|
||||
$(SCRIPT_ARGS) --extension=<%=dir%> --extstatic $(EXTSTATIC) \
|
||||
--gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
|
||||
-- subconfigure
|
||||
% end
|
||||
|
||||
.PHONY: FORCE
|
98
template/exts.mk.tmpl
Normal file
98
template/exts.mk.tmpl
Normal file
|
@ -0,0 +1,98 @@
|
|||
# -*- makefile -*-
|
||||
V = 0
|
||||
Q1 = $(V:1=)
|
||||
Q = $(Q1:0=@)
|
||||
ECHO1 = $(V:1=@:)
|
||||
ECHO = $(ECHO1:0=@echo)
|
||||
<%
|
||||
require './rbconfig'
|
||||
macros = {}
|
||||
deps = []
|
||||
note = []
|
||||
Dir.glob("ext/*/exts.mk") do |e|
|
||||
s = File.read(e)
|
||||
s.scan(/^(extensions|EXT[A-Z]+)[ \t]*=[ \t]*((?>(?>[^\\\n]|\\.)*\\\n)*(?>[^\\\n]|\\.)*)$/) do |n, v|
|
||||
v.gsub!(/\\\n[ \t]*/, ' ')
|
||||
next if v.empty?
|
||||
v = v.split
|
||||
m = macros[n] ||= []
|
||||
case n
|
||||
when "LIBS"
|
||||
m.concat(v)
|
||||
else
|
||||
macros[n] = m | v
|
||||
end
|
||||
end
|
||||
s.scan(%r"^(ext/\S+)/[^/\s:]+:[ \t]*\1/static$|^(?:ruby|install(?:-(?:so|rb))?|static|(?:dist|real)?clean):.+$") do
|
||||
deps << $&
|
||||
end
|
||||
s.scan(%r"^note:\n((?:\t.+\n)+)") do |(n)|
|
||||
note |= n.split(/^/)
|
||||
end
|
||||
end
|
||||
deps.uniq!
|
||||
if objs = macros["EXTOBJS"] and objs.any? {|e|e.start_with?("ext/extinit.")}
|
||||
objs.delete_if {|e|e.start_with?("dmyext.")}
|
||||
end
|
||||
macros.default = [].freeze
|
||||
class Array
|
||||
def fold(h, w = 70)
|
||||
return "" if empty?
|
||||
w -= h
|
||||
ret = [s = String.new]
|
||||
each do |e|
|
||||
if s.size + e.size + 1 > w
|
||||
ret << (s = String.new)
|
||||
end
|
||||
s << " " << e
|
||||
end
|
||||
ret.join(" \\\n" + "\t" * (h / 8) + " " * (h % 8))
|
||||
end
|
||||
end
|
||||
@erbout = _erbout
|
||||
def self.column
|
||||
w = 0
|
||||
@erbout[/^.*\z/].scan(/\t|([^\t]+)/) {|s,| w += (s ? s.size : 8 - w % 8)}
|
||||
w
|
||||
end
|
||||
targets = %w[all static install install-so install-rb clean distclean realclean]
|
||||
objext = RbConfig::CONFIG["OBJEXT"]
|
||||
%>
|
||||
|
||||
extensions =<%= macros["extensions"].fold(column) %>
|
||||
gems =
|
||||
EXTOBJS =<%= macros["EXTOBJS"].fold(column) %>
|
||||
EXTLIBS =<%= macros["EXTLIBS"].fold(column) %>
|
||||
EXTSO =<%= macros["EXTSO"].fold(column) %>
|
||||
EXTLDFLAGS =<%= macros["EXTLDFLAGS"].fold(column) %>
|
||||
EXTINITS =<%= macros["EXTINITS"].fold(column) %>
|
||||
SUBMAKEOPTS = DLDOBJS="$(EXTOBJS) $(EXTENCS)" EXTOBJS= \
|
||||
EXTSOLIBS="$(EXTLIBS)" LIBRUBY_SO_UPDATE=$(LIBRUBY_EXTS) \
|
||||
EXTLDFLAGS="$(EXTLDFLAGS)" EXTINITS="$(EXTINITS)" \
|
||||
UPDATE_LIBRARIES="$(UPDATE_LIBRARIES)" SHOWFLAGS=
|
||||
|
||||
all static: ruby
|
||||
|
||||
clean:
|
||||
-$(Q)$(RM) ext/extinit.<%= objext %>
|
||||
distclean:
|
||||
-$(Q)$(RM) ext/extinit.c
|
||||
|
||||
<%= deps.join("\n") %>
|
||||
ruby:
|
||||
$(Q)$(MAKE) $(MFLAGS) $(SUBMAKEOPTS) $@
|
||||
libencs:
|
||||
$(Q)$(MAKE) -f enc.mk V=$(V) $@
|
||||
ext/extinit.<%=objext%>:
|
||||
$(Q)$(MAKE) $(MFLAGS) V=$(V) EXTINITS="$(EXTINITS)" $@
|
||||
|
||||
% targets.product(macros["extensions"].map {|e|e.chomp("/.")}) do |t, e|
|
||||
<%=e%>/<%=t%>:
|
||||
$(Q)$(MAKE) -C $(@D) $(MFLAGS) V=$(V) $(@F)
|
||||
% end
|
||||
|
||||
extso:
|
||||
@echo EXTSO=$(EXTSO)
|
||||
|
||||
note:
|
||||
<%= note.join("") %>
|
|
@ -1072,7 +1072,9 @@ clean-ext distclean-ext realclean-ext::
|
|||
) )
|
||||
|
||||
distclean-ext realclean-ext::
|
||||
-$(Q)$(RM) ext/extinit.c
|
||||
-$(Q)$(RM) ext/extinit.c ext/configure-ext.mk
|
||||
@cd ext && for /D $(EXTS) %I in (.) \
|
||||
do @if exist %I\exts.mk del %I\exts.mk
|
||||
-$(Q)rmdir ext 2> nul || @
|
||||
|
||||
clean-extout:
|
||||
|
|
Loading…
Reference in a new issue