shasum for project meta-info;
authorwenzelm
Sun, 11 Jul 2021 21:29:54 +0200
changeset 74229 90652c0ef969
parent 74228 472bdccfba62
child 74230 0274d442b7ea
shasum for project meta-info;
src/Tools/Setup/isabelle/setup/Build.java
--- a/src/Tools/Setup/isabelle/setup/Build.java	Sun Jul 11 21:13:11 2021 +0200
+++ b/src/Tools/Setup/isabelle/setup/Build.java	Sun Jul 11 21:29:54 2021 +0200
@@ -23,6 +23,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Properties;
+import java.util.TreeMap;
 import java.util.jar.Attributes;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
@@ -77,6 +78,12 @@
         return List.copyOf(result);
     }
 
+    private static String sha_digest(MessageDigest sha, String name)
+    {
+        String digest = String.format(Locale.ROOT, "%040x", new BigInteger(1, sha.digest()));
+        return digest + " " + name + "\n";
+    }
+
     public static class Context
     {
         private final Path _dir;
@@ -162,8 +169,7 @@
                         "Missing input file " + Environment.quote(file.toString()));
                 }
             }
-            String digest = String.format(Locale.ROOT, "%040x", new BigInteger(1, sha.digest()));
-            return digest + " " + name + "\n";
+            return sha_digest(sha, name);
         }
 
         public String shasum(String file)
@@ -171,6 +177,18 @@
         {
             return shasum(file, List.of(path(file)));
         }
+
+        public String shasum_props()
+            throws NoSuchAlgorithmException
+        {
+            TreeMap<String,Object> sorted = new TreeMap<String,Object>();
+            for (Object x : _props.entrySet()) {
+                sorted.put(x.toString(), _props.get(x));
+            }
+            MessageDigest sha = MessageDigest.getInstance("SHA");
+            sha.update(sorted.toString().getBytes(StandardCharsets.UTF_8));
+            return sha_digest(sha, "<props>");
+        }
     }
 
 
@@ -385,6 +403,7 @@
             List<Path> compiler_deps = new LinkedList<Path>();
             {
                 StringBuilder _shasum = new StringBuilder();
+                _shasum.append(context.shasum_props());
                 for (String s : requirements) {
                     if (s.startsWith("env:")) {
                         List<Path> paths = new LinkedList<Path>();