* common.mk (configure-ext, build-ext), ext/extmk.rb (extmake):

support paralell-make under ext.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-03-08 00:33:05 +00:00
parent 15f0e53a06
commit acd036bcdc
4 changed files with 81 additions and 14 deletions

View File

@ -1,3 +1,8 @@
Tue Mar 8 09:32:48 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk (configure-ext, build-ext), ext/extmk.rb (extmake):
support paralell-make under ext.
Tue Mar 8 09:25:23 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Mar 8 09:25:23 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (proc_setgroups): use getgrnam() if getgrnam_r() is * process.c (proc_setgroups): use getgrnam() if getgrnam_r() is

View File

@ -140,7 +140,7 @@ COMPILE_PRELUDE = $(MINIRUBY) -I$(srcdir) $(srcdir)/tool/compile_prelude.rb
all: showflags main docs all: showflags main docs
main: showflags encs exts main: showflags encs exts
@$(RUNCMD) $(MKMAIN_CMD) $(MAKE) @$(NULLCMD)
.PHONY: showflags .PHONY: showflags
exts enc trans: showflags exts enc trans: showflags
@ -162,7 +162,16 @@ showconfig:
"$(configure_args)" \ "$(configure_args)" \
$(MESSAGE_END) $(MESSAGE_END)
exts: $(MKMAIN_CMD) exts: build-ext
EXTS_MK = exts.mk
$(EXTS_MK): $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY)
@$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$(EXTS_MK) $(EXTMK_ARGS) configure
configure-ext: $(EXTS_MK)
build-ext: $(EXTS_MK)
$(Q)$(MAKE) -f $(EXTS_MK) $(MFLAGS)
$(MKMAIN_CMD): $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY) $(MKMAIN_CMD): $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY)
@$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$@ $(EXTMK_ARGS) @$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$@ $(EXTMK_ARGS)

View File

@ -2908,6 +2908,8 @@ AC_CONFIG_FILES(Makefile, [{
ruby_pc="${RUBY_BASE_NAME}-${MAJOR}.${MINOR}.pc" ruby_pc="${RUBY_BASE_NAME}-${MAJOR}.${MINOR}.pc"
AC_SUBST(ruby_pc) AC_SUBST(ruby_pc)
AC_SUBST(exec, [exec])
AC_CONFIG_FILES($ruby_pc:template/ruby.pc.in, AC_CONFIG_FILES($ruby_pc:template/ruby.pc.in,
[ [
if sed ['s/\$(\([A-Za-z_][A-Za-z0-9_]*\))/${\1}/g;s/@[A-Za-z_][A-Za-z0-9_]*@//'] $ruby_pc > ruby.tmp.pc && if sed ['s/\$(\([A-Za-z_][A-Za-z0-9_]*\))/${\1}/g;s/@[A-Za-z_][A-Za-z0-9_]*@//'] $ruby_pc > ruby.tmp.pc &&

View File

@ -17,6 +17,7 @@ $extpath = nil
$ignore = nil $ignore = nil
$message = nil $message = nil
$command_output = nil $command_output = nil
$configure_only = false
$progname = $0 $progname = $0
alias $PROGRAM_NAME $0 alias $PROGRAM_NAME $0
@ -90,8 +91,10 @@ def extract_makefile(makefile, keep = true)
end end
def extmake(target) def extmake(target)
print "#{$message} #{target}\n" unless $configure_only
$stdout.flush print "#{$message} #{target}\n"
$stdout.flush
end
FileUtils.mkpath target unless File.directory?(target) FileUtils.mkpath target unless File.directory?(target)
begin begin
@ -150,6 +153,10 @@ def extmake(target)
[conf, "#{$srcdir}/depend"].any? {|f| modified?(f, [t])}) [conf, "#{$srcdir}/depend"].any? {|f| modified?(f, [t])})
then then
ok = false ok = false
if $configure_only
print "#{$message} #{target}\n"
$stdout.flush
end
init_mkmf init_mkmf
Logging::logfile 'mkmf.log' Logging::logfile 'mkmf.log'
rm_f makefile rm_f makefile
@ -177,7 +184,7 @@ def extmake(target)
return true return true
end end
args = sysquote($mflags) args = sysquote($mflags)
unless $destdir.to_s.empty? or $mflags.include?("DESTDIR") unless $destdir.to_s.empty? or $mflags.defined?("DESTDIR")
args += [sysquote("DESTDIR=" + relative_from($destdir, "../"+prefix))] args += [sysquote("DESTDIR=" + relative_from($destdir, "../"+prefix))]
end end
if $static if $static
@ -186,7 +193,7 @@ def extmake(target)
end end
FileUtils.rm_f(old_cleanfiles - $distcleanfiles) FileUtils.rm_f(old_cleanfiles - $distcleanfiles)
FileUtils.rm_f(old_objs - $objs) FileUtils.rm_f(old_objs - $objs)
unless system($make, *args) unless $configure_only or system($make, *args)
$ignore or $continue or return false $ignore or $continue or return false
end end
$compiled[target] = true $compiled[target] = true
@ -330,11 +337,13 @@ if target = ARGV.shift and /^[a-z-]+$/ =~ target
$mflags.unshift("INSTALL_PROG=install -c -p -m 0755", $mflags.unshift("INSTALL_PROG=install -c -p -m 0755",
"INSTALL_DATA=install -c -p -m 0644", "INSTALL_DATA=install -c -p -m 0644",
"MAKEDIRS=mkdir -p") if $dryrun "MAKEDIRS=mkdir -p") if $dryrun
when /configure/
$configure_only = true
end end
end end
unless $message unless $message
if target if target
$message = target.sub(/^(\w+)e?\b/, '\1ing').tr('-', ' ') $message = target.sub(/^(\w+?)e?\b/, '\1ing').tr('-', ' ')
else else
$message = "compiling" $message = "compiling"
end end
@ -445,6 +454,7 @@ exts.each do |d|
extmake(d) or abort extmake(d) or abort
end end
end end
$top_srcdir = srcdir $top_srcdir = srcdir
$topdir = "." $topdir = "."
$hdrdir = hdrdir $hdrdir = hdrdir
@ -549,17 +559,14 @@ Dir.chdir ".."
unless $destdir.to_s.empty? unless $destdir.to_s.empty?
$mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}" $mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}"
end end
message = "making #{rubies.join(', ')}"
$mflags.concat(rubies)
$makeflags.uniq! $makeflags.uniq!
$makeflags.concat(rubies)
if $nmake == ?b if $nmake == ?b
unless (vars = $mflags.grep(/\A\w+=/n)).empty? unless (vars = $mflags.grep(/\A\w+=/n)).empty?
open(mkf = "libruby.mk", "wb") do |tmf| open(mkf = "libruby.mk", "wb") do |tmf|
tmf.puts("!include Makefile") tmf.puts("!include Makefile")
tmf.puts tmf.puts
tmf.puts(*vars.map {|v| v.sub(/=/, " = ")}) tmf.puts(*vars.map {|v| v.sub(/\=/, " = ")})
tmf.puts("PRE_LIBRUBY_UPDATE = del #{mkf}") tmf.puts("PRE_LIBRUBY_UPDATE = del #{mkf}")
end end
$mflags.unshift("-f#{mkf}") $mflags.unshift("-f#{mkf}")
@ -568,13 +575,55 @@ if $nmake == ?b
end end
$mflags.unshift("topdir=#$topdir") $mflags.unshift("topdir=#$topdir")
ENV.delete("RUBYOPT") ENV.delete("RUBYOPT")
if $command_output if $configure_only and $command_output
exts.map! {|d| "ext/#{d}"}
open($command_output, "wb") do |mf|
mf.puts "V = 0"
mf.puts "Q1 = $(V:1=)"
mf.puts "Q = $(Q1:0=@)"
mf.puts "ECHO1 = $(V:1=@:)"
mf.puts "ECHO = $(ECHO1:0=@echo)"
mf.puts
mf.print "extensions ="
w = 12
exts.each do |d|
if d.size + w > 70
mf.print " \\\n\t "
w = 12
end
mf.print " #{d}"
w += d.size + 1
end
mf.puts
targets = %w[all install static install-so install-rb clean distclean realclean]
targets.each do |target|
mf.puts "#{target}: $(extensions:=/#{target})"
end
mf.puts
mf.puts "all: #{rubies.join(' ')}"
mf.puts "#{rubies.join(' ')}: $(extensions:=/all)"
rubies.each do |target|
mf.puts "#{target}:\n\t$(Q)$(MAKE) $(MFLAGS) $@"
end
mf.puts
exec = config_string("exec") {|s| s + " "}
targets.each do |target|
exts.each do |d|
mf.puts "#{d}/#{target}:\n\t$(Q)cd $(@D) && #{exec}$(MAKE) $(MFLAGS) $(@F)"
end
end
end
elsif $command_output
message = "making #{rubies.join(', ')}"
message = "echo #{message}" message = "echo #{message}"
$mflags.concat(rubies)
$makeflags.concat(rubies)
cmd = $makeflags.map {|ss|ss.sub(/.*[$(){};\s].*/, %q['\&'])}.join(' ') cmd = $makeflags.map {|ss|ss.sub(/.*[$(){};\s].*/, %q['\&'])}.join(' ')
open($command_output, 'wb') do |ff| open($command_output, 'wb') do |ff|
case $command_output case $command_output
when /\.sh\z/ when /\.sh\z/
ff.puts message, "rm -f $0; exec \"$@\" #{cmd}" ff.puts message, "rm -f \"$0\"; exec \"$@\" #{cmd}"
when /\.bat\z/ when /\.bat\z/
["@echo off", message, "%* #{cmd}", "del %0 & exit %ERRORLEVEL%"].each do |ss| ["@echo off", message, "%* #{cmd}", "del %0 & exit %ERRORLEVEL%"].each do |ss|
ff.print ss, "\r\n" ff.print ss, "\r\n"
@ -584,9 +633,11 @@ if $command_output
end end
ff.chmod(0755) ff.chmod(0755)
end end
else elsif !$configure_only
message = "making #{rubies.join(', ')}"
puts message puts message
$stdout.flush $stdout.flush
$mflags.concat(rubies)
system($make, *sysquote($mflags)) or exit($?.exitstatus) system($make, *sysquote($mflags)) or exit($?.exitstatus)
end end