From 3a2268ebe51e58dad7a30290a8e0066d76dcbaa5 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 4 Sep 2023 18:53:53 +0200 Subject: [PATCH] Add some hardcoded externals to hash input (#1440) --- src/alire/alire-builds-hashes.adb | 13 ++++++++++++- testsuite/tests/build/hashes/config-types/test.py | 2 ++ testsuite/tests/build/hashes/hashing-inputs/test.py | 6 ++++++ .../tests/dockerized/misc/default-cache/test.py | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/alire/alire-builds-hashes.adb b/src/alire/alire-builds-hashes.adb index 2b263fe0d..b80dddcb8 100644 --- a/src/alire/alire-builds-hashes.adb +++ b/src/alire/alire-builds-hashes.adb @@ -109,9 +109,20 @@ package body Alire.Builds.Hashes is procedure Add_Externals is Externals : constant Releases.Externals_Info := Rel.GPR_Externals; + + function Set (S : String) return GPR.Name_Vector + is (GPR.To_Set (S)); + + Hardcoded : constant GPR.Name_Vector + := Set ("LIBRARY_TYPE") + .Union (Set (AAA.Strings.To_Upper_Case (Rel.Name_Str) + & "_LIBRARY_TYPE")); + -- We add these to our generated library crates, although they're + -- not declared anywhere in manifests. begin for Var of GPR.Name_Vector'(Externals.Declared - .Union (Externals.Modified)) + .Union (Externals.Modified) + .Union (Hardcoded)) -- Externals modified but not declared are presumably for the -- benefit of another crate. It's unclear if these will affect -- the crate doing the setting, so we err on the side of diff --git a/testsuite/tests/build/hashes/config-types/test.py b/testsuite/tests/build/hashes/config-types/test.py index 4ae5724c4..2df2bb4ff 100644 --- a/testsuite/tests/build/hashes/config-types/test.py +++ b/testsuite/tests/build/hashes/config-types/test.py @@ -24,6 +24,8 @@ 'config:hello.var6=0.00000000000000E+00\n' 'config:hello.var7=0.00000000000000E+00\n' f'dependency:libhello=1.0.0={find_hash("libhello")}\n' + 'external:HELLO_LIBRARY_TYPE=default\n' + 'external:LIBRARY_TYPE=default\n' 'profile:hello=RELEASE\n' f'version:gnat_external={external_compiler_version()}\n', hash_input("hello")) diff --git a/testsuite/tests/build/hashes/hashing-inputs/test.py b/testsuite/tests/build/hashes/hashing-inputs/test.py index 56e49fad9..d56eb55fc 100644 --- a/testsuite/tests/build/hashes/hashing-inputs/test.py +++ b/testsuite/tests/build/hashes/hashing-inputs/test.py @@ -39,6 +39,8 @@ assert_eq( 'config:libhello.var1=false\n' # crate config var (set by hello) 'environment:TEST_ENV=myenv\n' # plain env var set + 'external:LIBHELLO_LIBRARY_TYPE=default\n' + 'external:LIBRARY_TYPE=default\n' # hardcoded undeclared GPR external 'external:TEST_FREEFORM_UNSET=default\n' # declared unset GPR external 'external:TEST_GPR_EXTERNAL=gpr_ext_B\n' # declared set GPR external 'external:TEST_UNDECLARED=used_by_another_crate\n' # modified GPR external @@ -58,6 +60,8 @@ 'config:hello.var6=0.00000000000000E+00\n' 'config:hello.var7=0.00000000000000E+00\n' f'dependency:libhello=1.0.0={find_hash("libhello")}\n' + 'external:HELLO_LIBRARY_TYPE=default\n' + 'external:LIBRARY_TYPE=default\n' 'profile:hello=VALIDATION\n' f'version:gnat_external={external_compiler_version()}\n', hash_input("hello")) @@ -67,6 +71,8 @@ # the inputs of a different crate that depends on it. assert_eq( f'dependency:hello=1.0.1={find_hash("hello")}\n' + 'external:LIBRARY_TYPE=default\n' + 'external:XXX_LIBRARY_TYPE=default\n' 'profile:xxx=VALIDATION\n' f'version:gnat_external={external_compiler_version()}\n', content_of(os.path.join("alire", "build_hash_inputs")) diff --git a/testsuite/tests/dockerized/misc/default-cache/test.py b/testsuite/tests/dockerized/misc/default-cache/test.py index 1437dacc2..b97356f0d 100644 --- a/testsuite/tests/dockerized/misc/default-cache/test.py +++ b/testsuite/tests/dockerized/misc/default-cache/test.py @@ -43,7 +43,7 @@ # We hardcode this hash so we detect unwilling changes to our hashing scheme. # Every time this hash changes we must know the reason (changes in the hashing # procedures) -hash = "d56fceceba3a7deaa9df1a9b43afa4fb9c643bf5245b335cc12ba0ae4df15682" +hash = "cc2adb8312e543d98d36736d6220023a47a4508f547109334ee36916280e73ac" assert \ os.path.isdir(f"{base}/builds/crate_real_1.0.0_filesystem_{hash}"), \ f"Shared build not found at the expected location: f{contents(base)}"