diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-07-14 11:59:46 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-07-16 10:11:42 +0900 |
commit | 78d2be69b500e4552e0e75fdefd26606a0506009 (patch) | |
tree | 125c30d13c035b9dc6d96f9930bab3b656db19f2 /ext | |
parent | f375280d5a9d2a1da0a0432a9e9fe7ffed910d50 (diff) | |
download | ruby-78d2be69b500e4552e0e75fdefd26606a0506009.tar.gz |
Move copying/linking extra files to Makefile so removed by `clean`
Diffstat (limited to 'ext')
-rwxr-xr-x | ext/extmk.rb | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/ext/extmk.rb b/ext/extmk.rb index ce8e9b88c5..6a9f9a7a70 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -37,6 +37,7 @@ require 'rbconfig' $topdir = "." $top_srcdir = srcdir +inplace = File.identical?($top_srcdir, $topdir) $" << "mkmf.rb" load File.expand_path("lib/mkmf.rb", srcdir) @@ -521,7 +522,10 @@ cond = proc {|ext, *| end ext_prefix = ext_prefix[$top_srcdir.size+1..-2] +@ext_prefix = ext_prefix +@inplace = inplace extend Module.new { + def timestamp_file(name, target_prefix = nil) if @gemname and name == '$(TARGET_SO_DIR)' name = "$(arch)/gems/#{@gemname}#{target_prefix}" @@ -537,6 +541,9 @@ extend Module.new { return super unless @gemname super(*args) do |conf| conf.find do |s| + s.sub!(%r(^(srcdir *= *)\$\(top_srcdir\)/\.bundle/gems/[^/]+(?=/))) { + "gem_#{$&}\n" "#{$1}$(gem_srcdir)" + } s.sub!(/^(TIMESTAMP_DIR *= *)\$\(extout\)/) { "TARGET_TOPDIR = $(topdir)/.bundle\n" "#{$1}$(TARGET_TOPDIR)" } @@ -545,37 +552,65 @@ extend Module.new { "#{$1}$(TARGET_GEM_DIR)$(target_prefix)" } end - conf.any? {|s| /^TARGET *= *\S/ =~ s} and conf << %{ + + gemlib = File.directory?("#{$top_srcdir}/#{@ext_prefix}/#{@gemname}/lib") + if conf.any? {|s| /^TARGET *= *\S/ =~ s} + conf << %{ gem_platform = #{Gem::Platform.local} # default target all: +gem = #{@gemname} + build_complete = $(TARGET_GEM_DIR)/gem.build_complete install-so: build_complete +clean-so:: clean-build_complete + build_complete: $(build_complete) $(build_complete): $(TARGET_SO) $(Q) $(TOUCH) $@ -clean-so:: +clean-build_complete: -$(Q)$(RM) $(build_complete) + +install: gemspec +clean: clean-gemspec + +gemspec = $(TARGET_TOPDIR)/specifications/$(gem).gemspec +$(gemspec): $(gem_srcdir)/.bundled.$(gem).gemspec + $(Q) $(MAKEDIRS) $(@D) + $(Q) $(COPY) $(gem_srcdir)/.bundled.$(gem).gemspec $@ + +gemspec: $(gemspec) + +clean-gemspec: + -$(Q)$(RM) $(gemspec) +} + + if gemlib + conf << %{ +install-rb: gemlib +clean-rb:: clean-gemlib + +LN_S = #{config_string('LN_S')} +CP_R = #{config_string('CP')} -r + +gemlib = $(TARGET_TOPDIR)/gems/$(gem)/lib +gemlib:#{%{ $(gemlib)\n$(gemlib): $(gem_srcdir)/lib} if $nmake} + $(Q) $(RUBY) $(top_srcdir)/tool/ln_sr.rb -f $(gem_srcdir)/lib $(gemlib) + +clean-gemlib: + $(Q) $(#{@inplace ? 'NULLCMD' : 'RM_RF'}) $(gemlib) } + end + end + conf end end } -if @gemname - gemdir = File.join($top_srcdir, ext_prefix, @gemname) - if File.exist?(spec_file = File.join(gemdir, ".bundled.#{@gemname}.gemspec")) or - File.exist?(spec_file = File.join(gemdir, "#{@gemname}.gemspec")) - dest = "#{File.dirname(ext_prefix)}/specifications" - FileUtils.mkdir_p(dest) - File.copy_stream(spec_file, "#{dest}/#{@gemname}.gemspec") - puts "copied #{@gemname}.gemspec" - end -end - dir = Dir.pwd FileUtils::makedirs(ext_prefix) Dir::chdir(ext_prefix) @@ -594,26 +629,6 @@ exts.each do |d| end end -if @gemname - src_gemlib = File.join($top_srcdir, ext_prefix, @gemname, "lib") - src_gemlib = relative_from(src_gemlib, ([".."]*ext_prefix.count("/")).join("/")) - gemlib = "#{@gemname}/lib" - if File.directory?(src_gemlib) - if File.exist?(gemlib) - puts "using #{gemlib}" - else - begin - FileUtils.mkdir_p(File.dirname(gemlib)) - File.symlink(relative_from(src_gemlib, ".."), gemlib) - puts "linked #{gemlib}" - rescue NotImplementedError, Errno::EPERM - FileUtils.cp_r(src_gemlib, gemlib) - puts "copied #{gemlib}" - end - end - end -end - $top_srcdir = srcdir $topdir = "." $hdrdir = hdrdir |