From bc3cd19d575e4775c1a04b7e5d15d6b8aeeda615 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Wed, 3 Mar 2021 16:41:34 +0100 Subject: [PATCH] Configuration feature extras (#700) * [configuration] as top-level table in manifests [config_vars] and [config_settings] are now [configuration.variables] and [configuration.settings] * Replace stderr warnings with regular ones * Fix YAML output * Rename `configuration.settings` to `@.values` This is under the rationale that `settings` makes more sense for configuring how Alire deals with the configuration. * Update documentation for new config tables * Fix obsolete comment --- deps/ada-toml | 2 +- doc/catalog-format-spec.md | 24 +++---- doc/user-changes.md | 25 +++++++- src/alire/alire-conditional_trees.adb | 27 ++++++++ src/alire/alire-conditional_trees.ads | 7 +- src/alire/alire-crate_configuration.adb | 36 +---------- src/alire/alire-properties-configurations.adb | 54 ++++++++++++++-- src/alire/alire-properties-configurations.ads | 64 +++++++++++++++++-- src/alire/alire-properties-from_toml.adb | 4 +- src/alire/alire-properties-from_toml.ads | 19 ++---- src/alire/alire-releases.adb | 9 ++- src/alire/alire-releases.ads | 2 +- src/alire/alire-roots-optional.adb | 1 + src/alire/alire-toml_adapters.adb | 22 +++++-- src/alire/alire-toml_adapters.ads | 12 +++- src/alire/alire-toml_keys.ads | 5 +- testsuite/fix-text.sh | 11 ++++ .../basic_index/he/hello/hello-1.0.1.toml | 4 +- .../li/libhello/libhello-1.0.0.toml | 2 +- .../libcrate_config-1.0.0.toml | 2 +- .../tests/index/bad-config-vars/manifest.toml | 2 +- testsuite/tests/index/bad-config-vars/test.py | 2 +- testsuite/tests/show/jekyll/test.py | 4 +- 23 files changed, 246 insertions(+), 94 deletions(-) create mode 100755 testsuite/fix-text.sh diff --git a/deps/ada-toml b/deps/ada-toml index 7896310c..ff7a848d 160000 --- a/deps/ada-toml +++ b/deps/ada-toml @@ -1 +1 @@ -Subproject commit 7896310c861133d47a422b21096ca85700ebb572 +Subproject commit ff7a848dff4c061e5fc6199665effb76a0e09f68 diff --git a/doc/catalog-format-spec.md b/doc/catalog-format-spec.md index 6ac583ac..a7e69209 100644 --- a/doc/catalog-format-spec.md +++ b/doc/catalog-format-spec.md @@ -441,7 +441,7 @@ static, i.e. they cannot depend on the context. notes = "Experimental version" ``` - - `config_variables` optional table of crate configuration variable + - `configuration.variables` optional table of crate configuration variable definitions. For more information on crate configuration, see [Using crate @@ -479,14 +479,14 @@ static, i.e. they cannot depend on the context. Example: ```toml - [config_variables] + [configuration.variables] Device_Name = {type = "String", default = "no device name"} Print_Debug = {type = "Boolean", default = false} Debug_Level = {type = "Enum", values = ["Info", "Debug", "Warn", "Error"], default = "Warn"} Buffer_Size = {type = "Integer", first = 0, last = 1024, default = 256} Max_Power = {type = "Real", first = 0.0, last = 100.0, default = 50.0} ``` - - `config_settings` optional table of variables assignment: + - `configuration.values` optional table of variables assignment: The keys of the table are crate names, and entries are sub-tables of `variable_name` and `value`. The type of the value has to match the @@ -494,7 +494,7 @@ static, i.e. they cannot depend on the context. Example: ```toml - [config_settings] + [configuration.values] crate_1.var1 = 42 crate_1.var2 = true crate_2.var1 = "Debug" @@ -621,7 +621,7 @@ would be best if this logging can be disabled/enabled at compile time. To achieve this, a crate maintainer can define a configuration variable in the crate manifest `alire.toml`. The definition will be like so: ```toml -[config_variables] +[configuration.variables] Enable_Logs = {type = "Boolean", default = false} ``` A single variable of type `Boolean` with a default value of `false`. @@ -646,7 +646,7 @@ If one of the crates depending on `test` sets the configuration variable to `true`, e.g.: ```toml -[config_settings] +[configuration.values] test.Enable_Logs = true ``` @@ -701,7 +701,7 @@ stack or on the heap depending on their project. Enumerations variables in crate configuration can be used to set a level of log verbosity: ```toml -[config_variables] +[configuration.variables] Log_Level = {type = "Enum", values = ["Info", "Debug", "Warn", "Error"], default = "Warn"} ``` @@ -710,7 +710,7 @@ Log_Level = {type = "Enum", values = ["Info", "Debug", "Warn", "Error"], default Integer variables can be used the define the size of a static buffer: ```toml -[config_variables] +[configuration.variables] Buffer_Size = {type = "Integer", first = 0, last = 1024, default = 256} ``` This is useful in particular for embedded projects where compile time memory @@ -721,7 +721,7 @@ usage is preferred over dynamic allocation. String variables can be used to define the URL of a website or service: ```toml -[config_variables] +[configuration.variables] URL_Name = {type = "String", default = "example.com"} ``` @@ -729,7 +729,7 @@ URL_Name = {type = "String", default = "example.com"} Real variables can be used for PID coefficients: ```toml -[config_variables] +[configuration.variables] Proportional = {type = "Real"} Integral = {type = "Real"} Derivative = {type = "Real"} @@ -739,7 +739,7 @@ Derivative = {type = "Real"} Integer variable can be used to define The maximum length of file names in a file-system: ```toml -[config_variables] +[configuration.variables] Max_Filename_Length = {type = "Integer", first = 5, last = 128} ``` @@ -748,7 +748,7 @@ Max_Filename_Length = {type = "Integer", first = 5, last = 128} Crate configuration also generates a GPR project file, therefore it can be used to control which units are compiled in the project. ```toml -[config_variables] +[configuration.variables] Sort_Algorithm = {type = "Enum", values = ["bubble", "quick", "merge"]} ``` diff --git a/doc/user-changes.md b/doc/user-changes.md index d927b016..889145c9 100644 --- a/doc/user-changes.md +++ b/doc/user-changes.md @@ -6,7 +6,30 @@ stay on top of `alr` new features. ## Release `1.1` -No changes yet since the release of `1.0`. +### Configuration of crates + +PR [#699](https://github.com/alire-project/alire/pull/679). +PR [#673](https://github.com/alire-project/alire/pull/673). + +Pre-compilation parameterization of source files can be now achieved by +declaring variables and initial constant values for these variables in the +Alire manifests. This allows customizing code in both the root crate and +dependencies. For example: + +```toml +[configuration.variables] +Device_Name = {type = "String", default = "no device name"} +Debug_Level = {type = "Enum", values = ["Info", "Debug", "Warn", "Error"], default = "Warn"} +Buffer_Size = {type = "Integer", first = 0, last = 1024, default = 256} + +[configuration.values] +crate_1.var1 = 42 +crate_1.var2 = true +crate_2.var1 = "Debug" +``` + +Check more examples and details in the catalog specification section ["Using +configuration"](https://github.com/mosteo/alire/blob/master/doc/catalog-format-spec.md#using-crate-configuration). ## Release `1.0` diff --git a/src/alire/alire-conditional_trees.adb b/src/alire/alire-conditional_trees.adb index f6c4c0a0..1fb986ad 100644 --- a/src/alire/alire-conditional_trees.adb +++ b/src/alire/alire-conditional_trees.adb @@ -1,5 +1,7 @@ with Ada.Containers.Indefinite_Ordered_Maps; +with Alire.TOML_Adapters; + with GNAT.IO; package body Alire.Conditional_Trees is @@ -252,6 +254,15 @@ package body Alire.Conditional_Trees is end if; end "or"; + ------------ + -- Append -- + ------------ + + procedure Append (L : in out Tree; R : Tree) is + begin + L := L and R; + end Append; + ---------------- -- Leaf_Count -- ---------------- @@ -531,7 +542,23 @@ package body Alire.Conditional_Trees is -- dependencies) -- Array values with same key are consolidated in a single array -- (e.g., actions, which are created as an array of tables). + begin + + -- Get properties given as nested tables out of the way first, by + -- getting the top-level key and using the nested table as the + -- actual value. + + if (for some Char of Key => Char = '.') then + Tree_TOML_Add (Table, + Key => Utils.Head (Key, '.'), + Val => TOML_Adapters.Create_Table + (Utils.Tail (Key, '.'), Val)); + return; + end if; + + -- Regular processing of a top-level property + pragma Assert (Table.Kind = TOML.TOML_Table); if Table.Has (Key) then declare diff --git a/src/alire/alire-conditional_trees.ads b/src/alire/alire-conditional_trees.ads index 558b987f..2b701adb 100644 --- a/src/alire/alire-conditional_trees.ads +++ b/src/alire/alire-conditional_trees.ads @@ -202,7 +202,10 @@ package Alire.Conditional_Trees with Preelaborate is -- Concatenation function "and" (L : Tree; R : Values) return Tree is - ("and" (L, New_Value (R))); + ("and" (L, New_Value (R))); + + procedure Append (L : in out Tree; R : Tree); + -- Same as L := L and R; function "or" (L, R : Tree) return Tree; @@ -536,5 +539,7 @@ private -- dependencies) -- Array values with same key are consolidated in a single array -- (e.g., actions, which are created as an array of tables). + -- Keys containing one dot are split as nested tables. More than one dot + -- is an error. end Alire.Conditional_Trees; diff --git a/src/alire/alire-crate_configuration.adb b/src/alire/alire-crate_configuration.adb index 63f3f669..c5c7c7fd 100644 --- a/src/alire/alire-crate_configuration.adb +++ b/src/alire/alire-crate_configuration.adb @@ -6,18 +6,14 @@ with Ada.Characters.Handling; with Alire_Early_Elaboration; with Alire.Solutions; with Alire.Roots; -with Alire.Utils.TTY; with Alire.Origins; -with GNAT.IO; - with Alire.Directories; with TOML; use TOML; package body Alire.Crate_Configuration is - package TTY renames Utils.TTY; package TIO renames Ada.Text_IO; ---------- @@ -30,22 +26,9 @@ package body Alire.Crate_Configuration is Solution : constant Solutions.Solution := Root.Solution; begin - -- Warnings when setting up an incomplete environment - if not Solution.Is_Complete then - Trace.Debug ("Generating incomplete environment" - & " because of missing dependencies"); - - -- Normally we would generate a warning, but since that will pollute - -- the output making it unusable, for once we write directly to - -- stderr (unless quiet is in effect): - - if not Alire_Early_Elaboration.Switch_Q then - GNAT.IO.Put_Line - (GNAT.IO.Standard_Error, - TTY.Warn ("warn:") & " Generating incomplete environment" - & " because of missing dependencies"); - end if; + Trace.Warning ("Generating possibly incomplete configuration" + & " because of missing dependencies"); end if; for Rel of Solution.Releases.Including (Root.Release) loop @@ -74,22 +57,9 @@ package body Alire.Crate_Configuration is Solution : constant Solutions.Solution := Root.Solution; begin - -- Warnings when setting up an incomplete environment - if not Solution.Is_Complete then - Trace.Debug ("Generating incomplete environment" + Trace.Warning ("Generating possibly incomplete configuration" & " because of missing dependencies"); - - -- Normally we would generate a warning, but since that will pollute - -- the output making it unusable, for once we write directly to - -- stderr (unless quiet is in effect): - - if not Alire_Early_Elaboration.Switch_Q then - GNAT.IO.Put_Line - (GNAT.IO.Standard_Error, - TTY.Warn ("warn:") & " Generating incomplete environment" - & " because of missing dependencies"); - end if; end if; for Rel of Solution.Releases.Including (Root.Release) loop diff --git a/src/alire/alire-properties-configurations.adb b/src/alire/alire-properties-configurations.adb index 4777310d..fb37643c 100644 --- a/src/alire/alire-properties-configurations.adb +++ b/src/alire/alire-properties-configurations.adb @@ -734,7 +734,7 @@ package body Alire.Properties.Configurations is -- Assignements_From_TOML -- ---------------------------- - function Assignements_From_TOML (From : TOML_Adapters.Key_Queue) + function Assignments_From_TOML (From : TOML_Adapters.Key_Queue) return Conditional.Properties is use Conditional.For_Properties; @@ -751,7 +751,7 @@ package body Alire.Properties.Configurations is begin if Raw.Kind /= TOML_Table then Raise_Checked_Error - (TOML_Keys.Config_Sets & " assignements must be a table"); + (TOML_Keys.Config_Values & " assignements must be a table"); end if; Val.Crate := +Crate; @@ -772,7 +772,7 @@ package body Alire.Properties.Configurations is Raw : constant TOML_Value := From.Pop; begin if Raw.Kind /= TOML_Table then - raise Checked_Error with TOML_Keys.Config_Sets & " must be a table"; + raise Checked_Error with TOML_Keys.Config_Values & " must be a table"; end if; return Props : Conditional.Properties do @@ -781,6 +781,52 @@ package body Alire.Properties.Configurations is Raw.Unset (Item.Key); end loop; end return; - end Assignements_From_TOML; + end Assignments_From_TOML; + + ---------------------------- + -- Config_Entry_From_TOML -- + ---------------------------- + + function Config_Entry_From_TOML (From : TOML_Adapters.Key_Queue) + return Conditional.Properties + is + Config : constant TOML_Adapters.Key_Queue := + From.Descend + (From.Checked_Pop + (TOML_Keys.Configuration, TOML_Table), + TOML_Keys.Configuration); + + begin + return Props : Conditional.Properties do + while True loop + declare + Val : TOML_Value; + Key : constant String := Config.Pop (Val); + Nested : Conditional.Properties; + -- For nested tables under [configuration] + begin + exit when Key = ""; + + if Key = Utils.Tail (TOML_Keys.Config_Vars, '.') then + Nested := Definitions_From_TOML + (From.Descend (Key, Val, "variables")); + elsif Key = Utils.Tail (TOML_Keys.Config_Values, '.') then + Nested := Assignments_From_TOML + (From.Descend (Key, Val, "settings")); + else + Raise_Checked_Error ("Unknown configuration entry: " + & Key); + end if; + + Props.Append (Nested); + end; + end loop; + + if Props.Is_Empty then + Props := Conditional.New_Property + (Config_Entry'(Property with null record)); + end if; + end return; + end Config_Entry_From_TOML; end Alire.Properties.Configurations; diff --git a/src/alire/alire-properties-configurations.ads b/src/alire/alire-properties-configurations.ads index 792b4298..272579ee 100644 --- a/src/alire/alire-properties-configurations.ads +++ b/src/alire/alire-properties-configurations.ads @@ -9,7 +9,37 @@ with TOML; package Alire.Properties.Configurations with Preelaborate is + -- Configuration looks like this: + -- [configuration] + -- # Top-level options here + -- generate_c = false + -- [configuration.variables] + -- # Variables declared here + -- test = { type = "Boolean" } + -- [configuration.values] + -- # Assignments made here + -- crate.test = false + + -- To be able to have a top-level [conf] entry and dynamic expressions, + -- without significantly changing the parsing internals, there is a + -- top-level property [configuration] that internally parses the nested + -- variables/settings tables. So, in practice, only this top-level entry + -- is called by the index loading machinery, and in consequence only the + -- top-level [configuration] can be dynamic: + + -- [configuration] + -- [configuration.'case(os)'.windows.variables] + -- etc. + + -- This top-level loader fools the caller by returning not only its own + -- type of property, but also the children tables as same-level properties + -- (top-level, or under a case). + + type Config_Entry is new Properties.Property with null record; + -- This property is the [configuration] itself + type Config_Type_Definition (<>) is new Properties.Property with private; + -- [configuration.variables] function Valid (This : Config_Type_Definition; Val : TOML.TOML_Value) @@ -39,18 +69,22 @@ package Alire.Properties.Configurations with Preelaborate is Value : TOML.TOML_Value; end record; - package Assignement_List_Pck + package Assignment_List_Pck is new Ada.Containers.Doubly_Linked_Lists (Assignment); type Config_Value_Assignment is new Properties.Property with record Crate : Ada.Strings.Unbounded.Unbounded_String; - List : Assignement_List_Pck.List; + List : Assignment_List_Pck.List; end record; + -- [configuration.settings] + + function Config_Entry_From_TOML (From : TOML_Adapters.Key_Queue) + return Conditional.Properties; function Definitions_From_TOML (From : TOML_Adapters.Key_Queue) return Conditional.Properties; - function Assignements_From_TOML (From : TOML_Adapters.Key_Queue) + function Assignments_From_TOML (From : TOML_Adapters.Key_Queue) return Conditional.Properties; private @@ -79,7 +113,7 @@ private overriding function Key (This : Config_Type_Definition) return String - is (Alire.TOML_Keys.Config_Vars); + is (TOML_Keys.Config_Vars); overriding function Image (This : Config_Type_Definition) return String; @@ -95,7 +129,7 @@ private overriding function Key (This : Config_Value_Assignment) return String - is (Alire.TOML_Keys.Config_Sets); + is (Alire.TOML_Keys.Config_Values); overriding function To_TOML (This : Config_Value_Assignment) return TOML.TOML_Value; @@ -106,4 +140,24 @@ private overriding function To_YAML (This : Config_Value_Assignment) return String; + -- top-level configuration -- + + overriding + function Key (This : Config_Entry) return String + is (TOML_Keys.Configuration); + + overriding + function To_TOML (This : Config_Entry) return TOML.TOML_Value + is (TOML.Create_Table); + -- Empty for now + + overriding + function Image (This : Config_Entry) return String + is ("Configuration: no modifiers"); + -- In the future, we may have other settings here + + overriding + function To_YAML (This : Config_Entry) return String + is ("Configuration: no modifiers"); + end Alire.Properties.Configurations; diff --git a/src/alire/alire-properties-from_toml.adb b/src/alire/alire-properties-from_toml.adb index 80d08e19..8e6296df 100644 --- a/src/alire/alire-properties-from_toml.adb +++ b/src/alire/alire-properties-from_toml.adb @@ -63,8 +63,8 @@ package body Alire.Properties.From_TOML is end if; -- Actually load the property: - Props := Props and Loaders (Prop) - (From.Descend (Key, Val, Key)); + Props := Props and + Loaders (Prop) (From.Descend (Key, Val, Key)); end if; else diff --git a/src/alire/alire-properties-from_toml.ads b/src/alire/alire-properties-from_toml.ads index bab0988c..71ac9f0e 100644 --- a/src/alire/alire-properties-from_toml.ads +++ b/src/alire/alire-properties-from_toml.ads @@ -16,8 +16,7 @@ package Alire.Properties.From_TOML is type Property_Keys is (Actions, Authors, Auto_GPR_With, - Config_Variables, - Config_Settings, + Configuration, Description, Environment, Executables, @@ -106,12 +105,8 @@ package Alire.Properties.From_TOML is Authors => Labeled.From_TOML'Access, Auto_GPR_With => Bool.From_TOML'Access, Description => Labeled.From_TOML'Access, - - Config_Variables => - Properties.Configurations.Definitions_From_TOML'Access, - Config_Settings => - Properties.Configurations.Assignements_From_TOML'Access, - + Configuration => + Properties.Configurations.Config_Entry_From_TOML'Access, Environment => Properties.Environment.From_TOML'Access, Executables => Labeled.From_TOML'Access, @@ -136,12 +131,8 @@ package Alire.Properties.From_TOML is Loaders_During_Case : constant array (Property_Keys) of Property_Loader := (Actions => Properties.Actions.From_TOML'Access, - - Config_Variables => - Properties.Configurations.Definitions_From_TOML'Access, - Config_Settings => - Properties.Configurations.Assignements_From_TOML'Access, - + Configuration => + Properties.Configurations.Config_Entry_From_TOML'Access, Environment => Properties.Environment.From_TOML'Access, Executables => Labeled.From_TOML_Executable_Cases'Access, GPR_Set_Externals => Scenarios.From_TOML_Cases'Access, diff --git a/src/alire/alire-releases.adb b/src/alire/alire-releases.adb index a8d0e438..a7e5af23 100644 --- a/src/alire/alire-releases.adb +++ b/src/alire/alire-releases.adb @@ -640,6 +640,7 @@ package body Alire.Releases is File_Name); exception when E : others => + Log_Exception (E); -- As this file is edited manually, it may not load for many reasons Raise_Checked_Error (Errors.Wrap ("Failed to load " & File_Name, Errors.Get (E))); @@ -729,6 +730,8 @@ package body Alire.Releases is return From.Report_Extra_Keys; exception when E : others => + Log_Exception (E); + TOML_Expressions.Strict_Enums := Strict_Before; case Source is @@ -884,8 +887,10 @@ package body Alire.Releases is "short_description: " & Utils.YAML.YAML_Stringify (R.Description) & ASCII.LF & "dependencies: " & R.Dependencies.To_YAML & ASCII.LF & - "config_variables: " & Props_To_YAML (R.Config_Variables) & ASCII.LF & - "config_settings: " & Props_To_YAML (R.Config_Settings) & ASCII.LF; + "configuration_variables: " & + Props_To_YAML (R.Config_Variables) & ASCII.LF & + "configuration_values: " & + Props_To_YAML (R.Config_Settings) & ASCII.LF; end To_YAML; ------------- diff --git a/src/alire/alire-releases.ads b/src/alire/alire-releases.ads index 6c35f2d9..070c5374 100644 --- a/src/alire/alire-releases.ads +++ b/src/alire/alire-releases.ads @@ -451,7 +451,7 @@ private function Config_Settings (R : Release) return Alire.Properties.Vector is (Conditional.Enumerate (R.Properties).Filter - (Alire.TOML_Keys.Config_Sets)); + (Alire.TOML_Keys.Config_Values)); use all type Origins.Kinds; function Unique_Folder (R : Release) return Folder_String diff --git a/src/alire/alire-roots-optional.adb b/src/alire/alire-roots-optional.adb index 2be86cc8..2db8e1e0 100644 --- a/src/alire/alire-roots-optional.adb +++ b/src/alire/alire-roots-optional.adb @@ -48,6 +48,7 @@ package body Alire.Roots.Optional is exception when E : others => Trace.Debug ("Unloadable root found at " & Path); + Log_Exception (E); return Outcome_Failure (Errors.Get (E), Broken, diff --git a/src/alire/alire-toml_adapters.adb b/src/alire/alire-toml_adapters.adb index 8d2b23ea..3a0b75e7 100644 --- a/src/alire/alire-toml_adapters.adb +++ b/src/alire/alire-toml_adapters.adb @@ -72,6 +72,20 @@ package body Alire.TOML_Adapters is end return; end Checked_Pop; + ------------------ + -- Create_Table -- + ------------------ + + function Create_Table (Key : String; + Value : TOML.TOML_Value) + return TOML.TOML_Value + is + begin + return Table : constant TOML.TOML_Value := TOML.Create_Table do + Table.Set (Key, Value); + end return; + end Create_Table; + ---------- -- From -- ---------- @@ -87,12 +101,8 @@ package body Alire.TOML_Adapters is function From (Key : String; Value : TOML.TOML_Value; Context : String) return Key_Queue - is - Table : constant TOML.TOML_Value := TOML.Create_Table; - begin - Table.Set (Key, Value); - return From (Table, Context); - end From; + is (From (Create_Table (Key, Value), + Context)); ------------- -- Descend -- diff --git a/src/alire/alire-toml_adapters.ads b/src/alire/alire-toml_adapters.ads index a8021cdf..821f1117 100644 --- a/src/alire/alire-toml_adapters.ads +++ b/src/alire/alire-toml_adapters.ads @@ -5,6 +5,13 @@ with TOML; use all type TOML.Any_Value_Kind; package Alire.TOML_Adapters with Preelaborate is + function Create_Table (Key : String; + Value : TOML.TOML_Value) + return TOML.TOML_Value with + Pre => (for all Char of Key => Char /= '.'), + Post => Create_Table'Result.Kind in TOML.TOML_Table; + -- Create a table with a single key and value + type Key_Queue is tagged private; -- Helper type that simplifies keeping track of processed keys during load. -- Also encapsulates a context that can be used to pinpoint errors better. @@ -91,8 +98,9 @@ package Alire.TOML_Adapters with Preelaborate is Kind : TOML.Any_Value_Kind) return String; -- For constructions like [parent.child.grandchild], where we known that -- only one child can exist. Will raise Checked_Error if any of these - -- happens: Queue is not a table; Queue doesn't have exactly one key; - -- Value is not of the expected Kind. Returns the single Key. + -- happens: Queue is not a table; Queue doesn't have exactly one key; Value + -- is not of the expected Kind. Returns the single key child. Value is set + -- to grandchild. function Unwrap (Queue : Key_Queue) return TOML.TOML_Value; -- Return the internal value as-is (with any already popped keys missing). diff --git a/src/alire/alire-toml_keys.ads b/src/alire/alire-toml_keys.ads index 00366865..4dd3d610 100644 --- a/src/alire/alire-toml_keys.ads +++ b/src/alire/alire-toml_keys.ads @@ -10,8 +10,9 @@ package Alire.TOML_Keys with Preelaborate is Auto_GPR_With : constant String := "auto-gpr-with"; Available : constant String := "available"; Compiler : constant String := "compiler"; - Config_Vars : constant String := "config_variables"; - Config_Sets : constant String := "config_settings"; + Configuration : constant String := "configuration"; + Config_Vars : constant String := "configuration.variables"; + Config_Values : constant String := "configuration.values"; Depends_On : constant String := "depends-on"; Description : constant String := "description"; Distribution : constant String := "distribution"; diff --git a/testsuite/fix-text.sh b/testsuite/fix-text.sh new file mode 100755 index 00000000..6550ba68 --- /dev/null +++ b/testsuite/fix-text.sh @@ -0,0 +1,11 @@ +# Replace $1 by $2 in place, recursively + +old="$1" +new="$2" + +if [ "$old" == "" ] || [ "$new" == "" ]; then + echo use: $0 ' ' + exit 1 +fi + +grep -rl . | parallel sed -i "s/${old}/${new}/g" {} diff --git a/testsuite/fixtures/basic_index/he/hello/hello-1.0.1.toml b/testsuite/fixtures/basic_index/he/hello/hello-1.0.1.toml index 382ce61f..e67e218c 100644 --- a/testsuite/fixtures/basic_index/he/hello/hello-1.0.1.toml +++ b/testsuite/fixtures/basic_index/he/hello/hello-1.0.1.toml @@ -12,7 +12,7 @@ tags = ["tag1", "other-tag"] [[depends-on]] libhello = "^1.0" -[config_variables] +[configuration.variables] Var1={type="Boolean"} Var2={type="String", default="str"} Var3={type="Enum", values=["A", "B"], default="A"} @@ -21,7 +21,7 @@ Var5={type="Integer", first=-1, last=1, default=0} Var7={type="Real", default=0.0} Var6={type="Real", first=-1.0, last=1.0, default=0.0} -[config_settings] +[configuration.values] hello.Var1=true # So far it is possible for a crate to set its own var libhello.Var1=false diff --git a/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml b/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml index 9258c911..8d6cc0e2 100644 --- a/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml +++ b/testsuite/fixtures/basic_index/li/libhello/libhello-1.0.0.toml @@ -4,7 +4,7 @@ version = "1.0.0" maintainers = ["alejandro@mosteo.com"] maintainers-logins = ["mylogin"] -[config_variables] +[configuration.variables] Var1={type="Boolean", default=true} [gpr-externals] diff --git a/testsuite/tests/crate_config/basic/my_index/index/li/libcrate_config/libcrate_config-1.0.0.toml b/testsuite/tests/crate_config/basic/my_index/index/li/libcrate_config/libcrate_config-1.0.0.toml index eb70107d..b881f485 100644 --- a/testsuite/tests/crate_config/basic/my_index/index/li/libcrate_config/libcrate_config-1.0.0.toml +++ b/testsuite/tests/crate_config/basic/my_index/index/li/libcrate_config/libcrate_config-1.0.0.toml @@ -8,7 +8,7 @@ maintainers-logins = ["mylogin"] [origin] url = "file:../../../libcrate_config_src" -[config_variables] +[configuration.variables] Var_Bool = {type="Boolean", default=true} Var_String = {type="String", default="Test string."} Var_Int = {type="Integer", first=-42, last=42, default=-1} diff --git a/testsuite/tests/index/bad-config-vars/manifest.toml b/testsuite/tests/index/bad-config-vars/manifest.toml index 831bf38b..f5cc205c 100644 --- a/testsuite/tests/index/bad-config-vars/manifest.toml +++ b/testsuite/tests/index/bad-config-vars/manifest.toml @@ -11,4 +11,4 @@ maintainers-logins = ["mylogin"] [origin] url = "file:." -[config_variables] +[configuration.variables] diff --git a/testsuite/tests/index/bad-config-vars/test.py b/testsuite/tests/index/bad-config-vars/test.py index 1439944f..47bba445 100644 --- a/testsuite/tests/index/bad-config-vars/test.py +++ b/testsuite/tests/index/bad-config-vars/test.py @@ -47,7 +47,7 @@ os.remove(os.path.join("my_index", "index", "he", "hello_world", ".gitignore")) check_error('var1=["plop"]', 'variable definition must be a table') -check_error('var1={}', "config_variables.var1:") +check_error('var1={}', "configuration.variables.var1:") check_error('var1={}', "'type' missing") check_error('var1={type=42}', "'type' must be string") check_error('var1={type=""}', "Invalid configuration type ''," diff --git a/testsuite/tests/show/jekyll/test.py b/testsuite/tests/show/jekyll/test.py index 37101cfe..cee9485f 100644 --- a/testsuite/tests/show/jekyll/test.py +++ b/testsuite/tests/show/jekyll/test.py @@ -22,14 +22,14 @@ assert_eq( 'version: "1.0.1"\n' 'short_description: "\\"Hello, world!\\" demonstration project"\n' 'dependencies: [{crate: "libhello", version: "^1.0"}]\n' - 'config_variables: [{name: \'Var1\', type: \'Boolean\'},\n' + 'configuration_variables: [{name: \'Var1\', type: \'Boolean\'},\n' '{name: \'Var2\', type: \'String\', default: "str"},\n' '{name: \'Var3\', type: \'Enum (A, B)\', default: "A"},\n' '{name: \'Var4\', type: \'Integer range -9223372036854775808 .. 9223372036854775807\', default: "0"},\n' '{name: \'Var5\', type: \'Integer range -1 .. 1\', default: "0"},\n' '{name: \'Var6\', type: \'Real range -1.00000000000000E+00 .. 1.00000000000000E+00\', default: "0.00000000000000E+00"},\n' '{name: \'Var7\', type: \'Real range -inf .. +inf\', default: "0.00000000000000E+00"}]\n' - 'config_settings: [{crate: \'hello\', settings: [{name: \'Var1\', value: "TRUE"}]},\n' + 'configuration_values: [{crate: \'hello\', settings: [{name: \'Var1\', value: "TRUE"}]},\n' '{crate: \'libhello\', settings: [{name: \'Var1\', value: "FALSE"}]}]\n' '\n' '---\n' -- 2.39.5