Skip to content

Commit

Permalink
Add some hardcoded externals to hash input (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo authored Sep 4, 2023
1 parent e9678b7 commit 3a2268e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/alire/alire-builds-hashes.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions testsuite/tests/build/hashes/config-types/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
6 changes: 6 additions & 0 deletions testsuite/tests/build/hashes/hashing-inputs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand All @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/dockerized/misc/default-cache/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
Expand Down

0 comments on commit 3a2268e

Please sign in to comment.