-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementation of an automatic gpr file with (#458)
* First prototype implementation of an automatic gpr file with * Add user query and config option for Auto-gpr-with * Introduce Boolean properties * Alire.Properties.Labeled: check TOML_Kind for labels * auto-gpr-with: add crate entry to disable auto-gpr-with feature * testsuite: allow custom indexes to reference fixtures/crates/ This removes duplication of several sources and archives. * Bump index version to 0.3 for auto-gpr-with feature * auto-gpr-with: do not add default project file for extern crates * Bump alire-index in CI scripts * tests/workflows/auto-gpr-with: rename test crate to avoid conflicts with scripts * Review fixes * tests/get/external-tool-dependency: make the test more robust On Windows when using msys2, the make seen by alr can be different than the one seen from the testsuite scripts. The means that the current way to identify make's version will fail in some cases. This patch introduces a different way to workaround the different version numbers of make.
- Loading branch information
1 parent
ffe95df
commit 8b908a6
Showing
83 changed files
with
575 additions
and
129 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package body Alire.Properties.Bool is | ||
|
||
--------------- | ||
-- From_TOML -- | ||
--------------- | ||
|
||
function From_TOML (From : TOML_Adapters.Key_Queue) | ||
return Conditional.Properties | ||
is | ||
Value : TOML.TOML_Value; | ||
Key : constant String := From.Pop (Value); | ||
|
||
------------------ | ||
-- Key_To_Label -- | ||
------------------ | ||
|
||
function Key_To_Label (K : String) return Labels is | ||
begin | ||
-- TODO: instead of this inefficient O(n) lookup, have a map. | ||
for L in Labels loop | ||
if Bool.Key (L) = K then | ||
return L; | ||
end if; | ||
end loop; | ||
From.Checked_Error ("Key is not a valid boolean property: " & K); | ||
end Key_To_Label; | ||
|
||
-- For conditional loading, we use specific conditional loaders that | ||
-- only recognize the property being loaded: | ||
|
||
begin | ||
return Props : Conditional.Properties do | ||
declare | ||
Val : constant TOML.TOML_Value := TOML_Adapters.To_Array (Value); | ||
-- We process the same way single values and arrays of values | ||
-- (since they get converted into individual properties). | ||
begin | ||
if Val.Length > 1 then | ||
raise Checked_Error with | ||
"Expected single value for " & Key; | ||
end if; | ||
|
||
if Val.Item (1).Kind /= TOML_Boolean then | ||
raise Checked_Error with "Expected boolean value for " & Key; | ||
end if; | ||
|
||
declare | ||
L : constant Property := New_Property | ||
(Key_To_Label (Key), | ||
Val.Item (1).As_Boolean); | ||
use all type Conditional.Properties; | ||
begin | ||
-- Labeled property is valid and added to the release props. | ||
Props := Props and | ||
Conditional.For_Properties.New_Value (L); | ||
end; | ||
end; | ||
end return; | ||
exception | ||
when E : others => | ||
Log_Exception (E); | ||
raise Checked_Error with "Cannot read valid property from " & Key; | ||
end From_TOML; | ||
|
||
end Alire.Properties.Bool; |
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,72 @@ | ||
with Alire.Conditional; | ||
with Alire.GPR; | ||
with Alire.TOML_Adapters; | ||
with Alire.TOML_Keys; | ||
with Alire.Utils; | ||
|
||
package Alire.Properties.Bool with Preelaborate is | ||
|
||
type Labels is | ||
(Auto_GPR_With | ||
-- Boolean to specify if a crate is compatible with the auto-gpr-with | ||
-- feature. | ||
); | ||
|
||
type Property is new Properties.Property with private; | ||
|
||
function New_Property (Name : Labels; | ||
V : Boolean) | ||
return Property; | ||
|
||
overriding | ||
function Image (V : Property) return String; | ||
|
||
overriding | ||
function To_YAML (V : Property) return String; | ||
|
||
overriding | ||
function Key (V : Property) return String; | ||
|
||
function Value (V : Property) return Boolean; | ||
|
||
function From_TOML (From : TOML_Adapters.Key_Queue) | ||
return Conditional.Properties; | ||
private | ||
|
||
function Key (L : Labels) return String | ||
is (case L is | ||
when Auto_GPR_With => TOML_Keys.Auto_GPR_With); | ||
|
||
type Property is new Properties.Property with record | ||
Name : Labels; | ||
Value : Boolean; | ||
end record; | ||
|
||
overriding | ||
function To_TOML (V : Property) return TOML.TOML_Value; | ||
|
||
function New_Property (Name : Labels; | ||
V : Boolean) | ||
return Property | ||
is (Name => Name, Value => V); | ||
|
||
overriding | ||
function Image (V : Property) return String | ||
is (Utils.To_Mixed_Case (V.Name'Img) & ": " & V.To_YAML); | ||
|
||
overriding | ||
function To_YAML (V : Property) return String | ||
is (Key (V.Name) & "=" & (if V.Value then "true" else "false")); | ||
|
||
overriding | ||
function To_TOML (V : Property) return TOML.TOML_Value | ||
is (TOML.Create_Boolean (V.Value)); | ||
|
||
overriding | ||
function Key (V : Property) return String | ||
is (Key (V.Name)); | ||
|
||
function Value (V : Property) return Boolean | ||
is (V.Value); | ||
|
||
end Alire.Properties.Bool; |
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
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.