[前][次][番号順一覧][スレッド一覧]

ruby-changes:61210

From: Nobuyoshi <ko1@a...>
Date: Tue, 12 May 2020 15:58:14 +0900 (JST)
Subject: [ruby-changes:61210] d1748484e8 (master): extlibs.rb: added variable references

https://git.ruby-lang.org/ruby.git/commit/?id=d1748484e8

From d1748484e8d919cbd7d13249d9e4f7af981c383e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 10 May 2020 14:58:55 +0900
Subject: extlibs.rb: added variable references

Reduce duplicate parts such as package name and version numbers.

diff --git a/ext/fiddle/extlibs b/ext/fiddle/extlibs
index 1f0c934..2282eab 100644
--- a/ext/fiddle/extlibs
+++ b/ext/fiddle/extlibs
@@ -1,5 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extlibs#L1
-https://ftp.osuosl.org/pub/blfs/conglomeration/libffi/libffi-3.2.1.tar.gz \
+ver = 3.2.1
+pkg = libffi-$(ver)
+
+https://ftp.osuosl.org/pub/blfs/conglomeration/libffi/$(pkg).tar.gz \
   md5:83b89587607e3eb65c70d361f13bab43 \
   sha512:980ca30a8d76f963fca722432b1fe5af77d7a4e4d2eac5144fbc5374d4c596609a293440573f4294207e1bdd9fda80ad1e1cafb2ffb543df5a275bc3bd546483 \
   #
-	win32/libffi-3.2.1-mswin.patch -p0
+	win32/$(pkg)-mswin.patch -p0
diff --git a/tool/extlibs.rb b/tool/extlibs.rb
index f021a2b..e7184b8 100755
--- a/tool/extlibs.rb
+++ b/tool/extlibs.rb
@@ -7,6 +7,20 @@ require 'digest' https://github.com/ruby/ruby/blob/trunk/tool/extlibs.rb#L7
 require_relative 'downloader'
 require_relative 'lib/colorize'
 
+class Vars < Hash
+  def pattern
+    /\$\((#{Regexp.union(keys)})\)/
+  end
+
+  def expand(str)
+    if empty?
+      str
+    else
+      str.gsub(pattern) {self[$1]}
+    end
+  end
+end
+
 class ExtLibs
   def initialize
     @colorize = Colorize.new
@@ -143,16 +157,21 @@ class ExtLibs https://github.com/ruby/ruby/blob/trunk/tool/extlibs.rb#L157
           $stdout.puts "downloading for #{list}"
           $stdout.flush
         end
+        vars = Vars.new
         extracted = false
         dest = File.dirname(list)
         url = chksums = nil
         IO.foreach(list) do |line|
           line.sub!(/\s*#.*/, '')
+          if /^(\w+)\s*=\s*(.*)/ =~ line
+            vars[$1] = vars.expand($2)
+            next
+          end
           if chksums
             chksums.concat(line.split)
           elsif /^\t/ =~ line
             if extracted and (mode == :all or mode == :patch)
-              patch, *args = line.split
+              patch, *args = line.split.map {|s| vars.expand(s)}
               do_patch(dest, patch, args)
             end
             next
@@ -163,7 +182,11 @@ class ExtLibs https://github.com/ruby/ruby/blob/trunk/tool/extlibs.rb#L182
             chksums.pop
             next
           end
-          next unless url
+          unless url
+            chksums = nil
+            next
+          end
+          url = vars.expand(url)
           begin
             extracted = do_command(mode, dest, url, cache_dir, chksums)
           rescue => e
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]