Skip to content

Commit

Permalink
extmk.rb: makefiles for gems
Browse files Browse the repository at this point in the history
* ext/extmk.rb (extmake): now yield makefile content at creation.
  substitute makefiles for gems in the block, not to rewrite when
  nothing changed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Aug 19, 2016
1 parent ec8f8fa commit 438f52d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions ext/extmk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def extract_makefile(makefile, keep = true)
true
end

def extmake(target, basedir = (maybestatic = 'ext'))
def extmake(target, basedir = (maybestatic = 'ext'), &block)
unless $configure_only || verbose?
print "#{$message} #{target}\n"
$stdout.flush
Expand Down Expand Up @@ -225,7 +225,7 @@ def extmake(target, basedir = (maybestatic = 'ext'))
load $0 = conf
end
else
create_makefile(target)
create_makefile(target, &block)
end
$defs << "-DRUBY_EXPORT" if $static
ok = File.exist?(makefile)
Expand All @@ -241,11 +241,11 @@ def extmake(target, basedir = (maybestatic = 'ext'))
end
end
ok &&= File.open(makefile){|f| s = f.gets and !s[DUMMY_SIGNATURE]}
ok = yield(ok) if block_given?
unless ok
mf = ["# #{DUMMY_SIGNATURE}\n", *dummy_makefile(CONFIG["srcdir"])].join("")
mf = yield mf if block
atomic_write_open(makefile) do |f|
f.puts "# " + DUMMY_SIGNATURE
f.print(*dummy_makefile(CONFIG["srcdir"]))
f.print(mf)
end

return true if !error and target.start_with?("-")
Expand Down Expand Up @@ -570,18 +570,14 @@ def $mflags.defined?(var)
extout = $extout
gems.each do |d|
$extout = extout.dup
extmake(d, 'gems')
open("#{d}/Makefile", "r+b") do |f|
mf = f.read
f.rewind
extmake(d, 'gems') do |mf|
mf.sub!(/^RUBYARCHDIR *= *(\$\(extout\))\/(\$\(arch\))(.*)/) {
"TARGET_SO_DIR = #$1/gems/#$2/#{d[%r{\A[^/]+}]}#$3\n" \
"TARGET_SO_TIME = .gems.-.arch.-.#{d[/\A[^\/]+/]}.time"
}
mf.gsub!(/\bRUBYARCHDIR\b/, 'TARGET_SO_DIR')
mf.gsub!(/\.TARGET_SO_DIR\.time/, '$(TARGET_SO_TIME)')
f.write(mf)
f.truncate(f.pos)
mf
end
end
$extout = extout
Expand Down

0 comments on commit 438f52d

Please sign in to comment.