-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use build profile in build hash #1425
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9d6db8c
Compute hash using build profile
mosteo aa20dc1
Fix problem with multiple hashes in one run
mosteo 9790aea
Write hash inputs to build dirs
mosteo 3c78245
Testsuite additions and fixes
mosteo 3455674
Self-review
mosteo ca4f2f9
Update pins and dependencies
mosteo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule aaa
updated
6 files
+3 −3 | alire.toml | |
+1 −1 | src/aaa-ansi.adb | |
+13 −3 | src/aaa-caches-files.adb | |
+9 −0 | src/aaa-caches-files.ads | |
+45 −24 | src/aaa-table_io.adb | |
+1 −0 | src/aaa-table_io.ads |
Submodule umwi
updated
6 files
+2 −0 | README.md | |
+1 −1 | alire.toml | |
+2 −2 | demo/src/demo.adb | |
+3 −3 | info/src/umwi-info.adb | |
+18 −15 | src/umwi.adb | |
+10 −4 | src/umwi.ads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
with Alire.Directories; | ||
with Alire.Hashes.SHA256_Impl; | ||
with Alire.Paths; | ||
with Alire.Roots; | ||
with Alire.Utils.Text_Files; | ||
|
||
package body Alire.Builds.Hashes is | ||
|
||
use Directories.Operators; | ||
|
||
package SHA renames Alire.Hashes.SHA256_Impl; | ||
|
||
subtype Variables is AAA.Strings.Set; | ||
-- We'll store all variables that affect a Release in a deterministic order | ||
|
||
----------- | ||
-- Clear -- | ||
----------- | ||
|
||
procedure Clear (This : in out Hasher) is | ||
begin | ||
This.Hashes.Clear; | ||
end Clear; | ||
|
||
-------------- | ||
-- Is_Empty -- | ||
-------------- | ||
|
||
function Is_Empty (This : Hasher) return Boolean | ||
is (This.Hashes.Is_Empty); | ||
|
||
------------- | ||
-- Compute -- | ||
------------- | ||
|
||
procedure Compute (This : in out Hasher; | ||
Root : in out Roots.Root) | ||
is | ||
|
||
------------- | ||
-- Compute -- | ||
------------- | ||
|
||
procedure Compute (Rel : Releases.Release) is | ||
Vars : Variables; | ||
|
||
--------- | ||
-- Add -- | ||
--------- | ||
|
||
procedure Add (Kind, Key, Value : String) is | ||
use AAA.Strings; | ||
Datum : constant String := | ||
Trim (Kind) & ":" | ||
& Trim (Key) & "=" | ||
& Trim (Value); | ||
begin | ||
Trace.Debug (" build hashing " & Datum); | ||
Vars.Insert (Datum); | ||
end Add; | ||
|
||
------------------ | ||
-- Compute_Hash -- | ||
------------------ | ||
|
||
procedure Compute_Hash is | ||
C : SHA.Hashing_Context; | ||
begin | ||
for Var of Vars loop | ||
SHA.Update (C, Var, Append_Nul => True); | ||
-- The nul character as separator ensures no ambiguity because | ||
-- of consecutive entries. | ||
end loop; | ||
|
||
This.Hashes.Insert (Rel.Name, SHA.Get_Digest (C)); | ||
end Compute_Hash; | ||
|
||
------------------ | ||
-- Write_Inputs -- | ||
------------------ | ||
|
||
procedure Write_Inputs is | ||
File : constant Absolute_Path := | ||
Builds.Path | ||
/ Rel.Base_Folder & "_" & This.Hashes (Rel.Name) | ||
/ Paths.Working_Folder_Inside_Root | ||
/ "build_hash_inputs"; | ||
use Directories; | ||
use Utils.Text_Files; | ||
|
||
Lines : AAA.Strings.Vector; | ||
begin | ||
-- First ensure we have a pristine file to work with | ||
Delete_Tree (File); | ||
Create_Tree (Parent (File)); | ||
Touch (File); | ||
|
||
-- Now add the hashed contents for the record | ||
|
||
for Var of Vars loop | ||
Lines.Append (Var); | ||
end loop; | ||
|
||
Append_Lines (File, | ||
Lines, | ||
Backup => False); | ||
end Write_Inputs; | ||
|
||
begin | ||
Trace.Debug (" build hashing: " & Rel.Milestone.TTY_Image); | ||
|
||
-- Build profile | ||
Add ("profile", | ||
Rel.Name.As_String, | ||
Root.Configuration.Build_Profile (Rel.Name)'Image); | ||
|
||
-- GPR externals | ||
-- TBD | ||
|
||
-- Environment variables | ||
-- TBD | ||
|
||
-- Configuration variables | ||
-- TBD | ||
|
||
-- Final computation | ||
Compute_Hash; | ||
|
||
-- Write the hash input for the record | ||
Write_Inputs; | ||
|
||
Trace.Debug (" build hashing release complete"); | ||
end Compute; | ||
|
||
begin | ||
Trace.Debug ("build hashing root " & Root.Path); | ||
This.Hashes.Clear; | ||
|
||
for Rel of Root.Solution.Releases loop | ||
if Root.Requires_Build_Sync (Rel) then | ||
Compute (Rel); | ||
end if; | ||
end loop; | ||
end Compute; | ||
|
||
---------- | ||
-- Hash -- | ||
---------- | ||
|
||
function Hash (This : in out Hasher; | ||
Name : Crate_Name) | ||
return String | ||
is (This.Hashes (Name)); | ||
|
||
end Alire.Builds.Hashes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
private with Ada.Containers.Indefinite_Ordered_Maps; | ||
|
||
limited with Alire.Roots; | ||
|
||
package Alire.Builds.Hashes is | ||
|
||
type Hasher is tagged private; | ||
-- Used to compute all build hashes for releases in a build | ||
|
||
procedure Clear (This : in out Hasher); | ||
-- Remove any cached hashes | ||
|
||
function Is_Empty (This : Hasher) return Boolean; | ||
-- Says if the Hasher has been used or not | ||
|
||
procedure Compute (This : in out Hasher; | ||
Root : in out Roots.Root); | ||
-- Compute all hashes needed for a release | ||
|
||
function Hash (This : in out Hasher; | ||
Name : Crate_Name) | ||
return String | ||
with Pre => not This.Is_Empty; | ||
-- Retrieve the hash of a crate in Root's solution | ||
|
||
private | ||
|
||
package Crate_Hash_Maps is new Ada.Containers.Indefinite_Ordered_Maps | ||
(Crate_Name, String); | ||
|
||
type Hasher is tagged record | ||
Hashes : Crate_Hash_Maps.Map; | ||
end record; | ||
|
||
end Alire.Builds.Hashes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end we my not have "build_profile" in the hash since there is a separate object dir depending on the profile, at least in Alire generated gpr files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I'm going to merge it as is for now, as it is trivial to remove later on.