summaryrefslogtreecommitdiff
path: root/ext/extmk.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-01 12:39:54 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-01 12:39:54 (GMT)
commitc7924b1305afe127d0da132d11ecefb30c30a6fc (patch)
tree95bf8d76df796eebc4f1b4cc98169beccfcd35ec /ext/extmk.rb
parent26f59b09fe3a1c2ec50145f7c3d5b425f48a7a32 (diff)
extmk.rb: build gems
* ext/extmk.rb: [EXPERIMENTAL] build extension libraries in extracted gems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/extmk.rb')
-rwxr-xr-xext/extmk.rb37
1 files changed, 30 insertions, 7 deletions
diff --git a/ext/extmk.rb b/ext/extmk.rb
index 50b9485..51d8b3e 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -135,7 +135,7 @@ def extract_makefile(makefile, keep = true)
true
end
-def extmake(target)
+def extmake(target, basedir = 'ext')
unless $configure_only || verbose?
print "#{$message} #{target}\n"
$stdout.flush
@@ -147,7 +147,7 @@ def extmake(target)
parent = true
d = target
until (d = File.dirname(d)) == '.'
- if File.exist?("#{$top_srcdir}/ext/#{d}/extconf.rb")
+ if File.exist?("#{$top_srcdir}/#{basedir}/#{d}/extconf.rb")
parent = (/^all:\s*install/ =~ IO.read("#{d}/Makefile") rescue false)
break
end
@@ -165,7 +165,7 @@ def extmake(target)
$topdir = prefix + $topdir
$target = target
$mdir = target
- $srcdir = File.join($top_srcdir, "ext", $mdir)
+ $srcdir = File.join($top_srcdir, basedir, $mdir)
$preload = nil
$objs = []
$srcs = []
@@ -184,7 +184,7 @@ def extmake(target)
}
mkconfig = {
"hdrdir" => ($hdrdir == top_srcdir) ? top_srcdir : "$(top_srcdir)/include",
- "srcdir" => "$(top_srcdir)/ext/#{$mdir}",
+ "srcdir" => "$(top_srcdir)/#{basedir}/#{$mdir}",
"topdir" => $topdir,
}
rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup}
@@ -543,6 +543,14 @@ if $extout
end
end
+FileUtils.makedirs('gems')
+ext_prefix = "#$top_srcdir/gems"
+gems = Dir.glob("#{ext_prefix}/**/extconf.rb").collect {|d|
+ d = File.dirname(d)
+ d.slice!(0, ext_prefix.length + 1)
+ d
+}.sort
+
dir = Dir.pwd
FileUtils::makedirs('ext')
Dir::chdir('ext')
@@ -559,6 +567,18 @@ exts.each do |d|
end
end
+Dir.chdir('..')
+FileUtils::makedirs('gems')
+FileUtils::makedirs('.ext/gems')
+Dir.chdir('gems')
+extout = $extout
+gems.each do |d|
+ $extout = extout.dup
+ extmake(d, 'gems')
+end
+$extout = extout
+Dir.chdir('../ext')
+
$top_srcdir = srcdir
$topdir = "."
$hdrdir = hdrdir
@@ -674,6 +694,7 @@ $mflags.unshift("topdir=#$topdir")
ENV.delete("RUBYOPT")
if $configure_only and $command_output
exts.map! {|d| "ext/#{d}/."}
+ gems.map! {|d| "gems/#{d}/."}
atomic_write_open($command_output) do |mf|
mf.puts "V = 0"
mf.puts "Q1 = $(V:1=)"
@@ -699,6 +720,7 @@ if $configure_only and $command_output
end
mf.macro "extensions", exts
+ mf.macro "gems", gems
mf.macro "EXTOBJS", $extlist.empty? ? ["dmyext.#{$OBJEXT}"] : ["ext/extinit.#{$OBJEXT}", *$extobjs]
mf.macro "EXTLIBS", $extlibs
mf.macro "EXTLDFLAGS", $extflags.split
@@ -719,14 +741,14 @@ if $configure_only and $command_output
mf.puts
targets = %w[all install static install-so install-rb clean distclean realclean]
targets.each do |tgt|
- mf.puts "#{tgt}: $(extensions:/.=/#{tgt})"
+ mf.puts "#{tgt}: $(extensions:/.=/#{tgt}) $(gems:/.=/#{tgt})"
mf.puts "#{tgt}: note" unless /clean\z/ =~ tgt
end
mf.puts
mf.puts "clean:\n\t-$(Q)$(RM) ext/extinit.#{$OBJEXT}"
mf.puts "distclean:\n\t-$(Q)$(RM) ext/extinit.c"
mf.puts
- mf.puts "#{rubies.join(' ')}: $(extensions:/.=/#{$force_static ? 'static' : 'all'})"
+ mf.puts "#{rubies.join(' ')}: $(extensions:/.=/#{$force_static ? 'static' : 'all'}) $(gems:/.=/all)"
submake = "$(Q)$(MAKE) $(MFLAGS) $(SUBMAKEOPTS)"
mf.puts "all static: #{rubies.join(' ')}\n"
$extobjs.each do |tgt|
@@ -746,8 +768,9 @@ if $configure_only and $command_output
config_string("exec") {|str| submake << str << " "}
submake << "$(MAKE)"
end
+ gems = exts + gems
targets.each do |tgt|
- exts.each do |d|
+ (tgt == 'static' ? exts : gems).each do |d|
mf.puts "#{d[0..-2]}#{tgt}:\n\t$(Q)#{submake} $(MFLAGS) V=$(V) $(@F)"
end
end