ruby-changes:46311
From: nobu <ko1@a...>
Date: Fri, 21 Apr 2017 11:43:29 +0900 (JST)
Subject: [ruby-changes:46311] nobu:r58425 (trunk): exts.mk: refine notes [Feature #13302]
nobu 2017-04-21 11:43:25 +0900 (Fri, 21 Apr 2017) New Revision: 58425 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58425 Log: exts.mk: refine notes [Feature #13302] * ext/extmk.rb: split notes into header and footer, which are common, from bodies which are unique for each extensions. * template/exts.mk.tmpl: now each notes are not one line, should not unique. Modified files: trunk/ext/extmk.rb trunk/template/exts.mk.tmpl Index: ext/extmk.rb =================================================================== --- ext/extmk.rb (revision 58424) +++ ext/extmk.rb (revision 58425) @@ -679,6 +679,8 @@ begin https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L679 submakeopts << 'UPDATE_LIBRARIES="$(UPDATE_LIBRARIES)"' submakeopts << 'SHOWFLAGS=' mf.macro "SUBMAKEOPTS", submakeopts + mf.macro "NOTE_MESG", %w[echo] + mf.macro "NOTE_NAME", %w[echo] mf.puts targets = %w[all install static install-so install-rb clean distclean realclean] targets.each do |tgt| @@ -720,10 +722,14 @@ begin https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L722 mf.puts "\n""note:\n" unless fails.empty? abandon = false - mf.puts %Q<\t@echo "*** Following extensions are not compiled:"> + mf.puts "note: note-body\n" + mf.puts "note-body:: note-header\n" + mf.puts "note-header:\n" + mf.puts %Q<\t@$(NOTE_MESG) "*** Following extensions are not compiled:"> + mf.puts "note-body:: note-header\n" fails.each do |ext, (parent, err)| abandon ||= mandatory_exts[ext] - mf.puts %Q<\t@echo "#{ext}:"> + mf.puts %Q<\t@$(NOTE_NAME) "#{ext}:"> if parent mf.puts %Q<\t@echo "\tCould not be configured. It will not be installed."> err and err.scan(/.+/) do |ee| @@ -734,7 +740,8 @@ begin https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L740 mf.puts %Q<\t@echo "\tSkipped because its parent was not configured."> end end - mf.puts %Q<\t@echo "*** Fix the problems, then remove these directories and try again if you want."> + mf.puts "note:\n" + mf.puts %Q<\t@$(NOTE_MESG) "*** Fix the problems, then remove these directories and try again if you want."> if abandon mf.puts "\t""@exit 1" end Index: template/exts.mk.tmpl =================================================================== --- template/exts.mk.tmpl (revision 58424) +++ template/exts.mk.tmpl (revision 58425) @@ -8,7 +8,7 @@ ECHO = $(ECHO1:0=@echo) https://github.com/ruby/ruby/blob/trunk/template/exts.mk.tmpl#L8 require './rbconfig' macros = {} deps = [] -note = [] +notes = {} rubies = [] exeext = RbConfig::CONFIG['EXEEXT'] gnumake = false @@ -16,10 +16,11 @@ opt = OptionParser.new do |o| https://github.com/ruby/ruby/blob/trunk/template/exts.mk.tmpl#L16 o.on('--gnumake=BOOL') {|v| gnumake = v == 'yes'} o.order!(ARGV) end +contpat = /(?>(?>[^\\\n]|\\.)*\\\n)*(?>[^\\\n]|\\.)*/ Dir.glob("{ext,gems}/*/exts.mk") do |e| gem = /\Agems(?=\/)/ =~ e s = File.read(e) - s.scan(/^(extensions|EXT[A-Z]+|MFLAGS)[ \t]*=[ \t]*((?>(?>[^\\\n]|\\.)*\\\n)*(?>[^\\\n]|\\.)*)$/) do |n, v| + s.scan(/^(extensions|EXT[A-Z]+|MFLAGS|NOTE_[A-Z]+)[ \t]*=[ \t]*(#{contpat})$/o) do |n, v| v.gsub!(/\\\n[ \t]*/, ' ') next if v.empty? next if gem and n != "extensions" @@ -48,12 +49,15 @@ Dir.glob("{ext,gems}/*/exts.mk") do |e| https://github.com/ruby/ruby/blob/trunk/template/exts.mk.tmpl#L49 "x) do deps << $&.sub(/ +note$/, '') end - s.scan(%r"^note:\n((?:\t.+\n)+)") do |(n)| + s.scan(%r"^(note(?:-\w+)?):(:)?[ \t]*(#{contpat})\n((?:\t.+\n)*)"o) do |(t, m, d, n)| + note = (notes[t] ||= [[m||""], []]) + note[0] |= d.split(/(?:\\\n|[ \t])[ \t]*/) n = n.split(/^/) - e = (note.pop if /@exit/ =~ note[-1]) - note.pop if n[-1] == note[-1] - note |= n - note << e if e + if m + note[1].concat(n) + else + note[1] |= n + end end end deps.uniq! @@ -92,19 +96,13 @@ else https://github.com/ruby/ruby/blob/trunk/template/exts.mk.tmpl#L96 mflags = " $(MFLAGS)" end -%> -% unless macros["MFLAGS"].empty? -MFLAGS =<%= macros["MFLAGS"].fold(column) %> +% macros.each_pair do |k, v| +<%=k%> =<%= v.fold(column) %> % end % RbConfig::MAKEFILE_CONFIG.keys.grep(/RM/) do |k| <%=k%> = <%=RbConfig::MAKEFILE_CONFIG[k]%> % end -extensions =<%= macros["extensions"].fold(column) %> -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)" \ @@ -146,5 +144,7 @@ ext/extinit.<%=objext%>: https://github.com/ruby/ruby/blob/trunk/template/exts.mk.tmpl#L144 extso: @echo EXTSO=$(EXTSO) -note: -<%= note.join("") %> +% notes.each_pair do |k, (d, n)| +<%= k %>:<%= d.join(' ') %> +<%= n.join("") %> +% end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/