From d57b71c67e8e151ef0ba008a797d3e80267c3439 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 11 Mar 2024 12:34:16 +0100 Subject: [PATCH] Refactor `Alire.Config.*` as `Alire.Settings.*` (#1622) * Refactor `Alire.Config.*` as `Alire.Settings.*` * Refactor Windows-only files --- RELEASING.md | 1 + src/alire/alire-builds.adb | 8 ++-- src/alire/alire-config-edit-early_load.adb | 14 ------- src/alire/alire-crate_configuration.adb | 6 +-- src/alire/alire-index.ads | 9 +++-- src/alire/alire-index_on_disk-loading.adb | 16 ++++---- src/alire/alire-index_on_disk-updates.adb | 18 ++++----- src/alire/alire-index_on_disk-updates.ads | 6 +-- src/alire/alire-origins-deployers-git.adb | 4 +- src/alire/alire-paths-vault.ads | 4 +- src/alire/alire-platforms-current.ads | 11 +++--- src/alire/alire-platforms-folders.ads | 2 +- src/alire/alire-publish.adb | 8 ++-- src/alire/alire-releases.adb | 6 +-- src/alire/alire-roots.adb | 2 +- src/alire/alire-selftest.adb | 24 ++++++------ ...iltins.ads => alire-settings-builtins.ads} | 6 +-- ...g-checks.adb => alire-settings-checks.adb} | 4 +- ...g-checks.ads => alire-settings-checks.ads} | 4 +- src/alire/alire-settings-edit-early_load.adb | 14 +++++++ ...ads => alire-settings-edit-early_load.ads} | 6 +-- ...onfig-edit.adb => alire-settings-edit.adb} | 16 ++++---- ...onfig-edit.ads => alire-settings-edit.ads} | 12 +++--- .../{alire-config.adb => alire-settings.adb} | 14 +++---- .../{alire-config.ads => alire-settings.ads} | 12 +++--- src/alire/alire-solutions.adb | 4 +- src/alire/alire-toml_index.adb | 8 ++-- src/alire/alire-toolchains.adb | 39 ++++++++++--------- src/alire/alire-toolchains.ads | 22 ++++++----- .../alire-utils-user_input-query_config.adb | 10 ++--- src/alire/alire_early_elaboration.adb | 6 +-- .../alire-platforms-current__windows.adb | 20 +++++----- ...ds => alire-settings-builtins-windows.ads} | 10 ++--- src/alr/alr-commands-clean.adb | 4 +- src/alr/alr-commands-edit.adb | 12 +++--- src/alr/alr-commands-get.adb | 6 +-- src/alr/alr-commands-index.adb | 10 ++--- src/alr/alr-commands-init.adb | 4 +- src/alr/alr-commands-settings.adb | 33 ++++++++-------- src/alr/alr-commands-toolchain.adb | 25 ++++++------ src/alr/alr-commands-version.adb | 10 ++--- src/alr/alr-commands.adb | 16 ++++---- 42 files changed, 239 insertions(+), 227 deletions(-) delete mode 100644 src/alire/alire-config-edit-early_load.adb rename src/alire/{alire-config-builtins.ads => alire-settings-builtins.ads} (98%) rename src/alire/{alire-config-checks.adb => alire-settings-checks.adb} (87%) rename src/alire/{alire-config-checks.ads => alire-settings-checks.ads} (73%) create mode 100644 src/alire/alire-settings-edit-early_load.adb rename src/alire/{alire-config-edit-early_load.ads => alire-settings-edit-early_load.ads} (55%) rename src/alire/{alire-config-edit.adb => alire-settings-edit.adb} (96%) rename src/alire/{alire-config-edit.ads => alire-settings-edit.ads} (91%) rename src/alire/{alire-config.adb => alire-settings.adb} (94%) rename src/alire/{alire-config.ads => alire-settings.ads} (94%) rename src/alire/os_windows/{alire-config-builtins-windows.ads => alire-settings-builtins-windows.ads} (85%) diff --git a/RELEASING.md b/RELEASING.md index 198b74d3..e58d31f8 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,6 +1,7 @@ ## Checklist for releasing a new version 1. [ ] Update version in `Alire.Version`. +1. [ ] Run local-only tests (`/testsuite/run-dev-sh`) 1. [ ] Create test release in own fork. - To verify builds succeed. - As the Windows build can rarely fail, this provides a backup .exe diff --git a/src/alire/alire-builds.adb b/src/alire/alire-builds.adb index f632b95f..22b0c971 100644 --- a/src/alire/alire-builds.adb +++ b/src/alire/alire-builds.adb @@ -1,7 +1,7 @@ with AAA.Strings; -with Alire.Config.Builtins; -with Alire.Config.Edit; +with Alire.Settings.Builtins; +with Alire.Settings.Edit; with Alire.Directories; with Alire.Flags; with Alire.Paths.Vault; @@ -18,7 +18,7 @@ package body Alire.Builds is ---------------------------- function Sandboxed_Dependencies return Boolean - is (not Config.Builtins.Dependencies_Shared.Get); + is (not Settings.Builtins.Dependencies_Shared.Get); ---------- -- Sync -- @@ -83,7 +83,7 @@ package body Alire.Builds is ---------- function Path return Absolute_Path - is (Config.Edit.Cache_Path + is (Settings.Edit.Cache_Path / Paths.Build_Folder_Inside_Working_Folder); ---------- diff --git a/src/alire/alire-config-edit-early_load.adb b/src/alire/alire-config-edit-early_load.adb deleted file mode 100644 index e0df70e5..00000000 --- a/src/alire/alire-config-edit-early_load.adb +++ /dev/null @@ -1,14 +0,0 @@ -package body Alire.Config.Edit.Early_Load is - - ----------------- - -- Load_Config -- - ----------------- - - procedure Load_Config is - begin - Alire.Config.Edit.Load_Config; - end Load_Config; - -begin - Load_Config; -end Alire.Config.Edit.Early_Load; diff --git a/src/alire/alire-crate_configuration.adb b/src/alire/alire-crate_configuration.adb index e9677653..c886c523 100644 --- a/src/alire/alire-crate_configuration.adb +++ b/src/alire/alire-crate_configuration.adb @@ -11,7 +11,7 @@ with Alire.Solutions; with Alire.Roots; with Alire.Origins; with Alire.Warnings; -with Alire.Config.Edit; +with Alire.Settings.Edit; with Alire.Properties.Build_Profiles; with Alire.Properties.Build_Switches; @@ -955,7 +955,7 @@ package body Alire.Crate_Configuration is ------------------------- function Last_Build_Profiles return Profile_Maps.Map is - Str : constant String := Config.DB.Get ("last_build_profile", ""); + Str : constant String := Settings.DB.Get ("last_build_profile", ""); Profiles : Parsed_Profiles; begin Profiles := Parse_Profiles (Str, Accept_Wildcards => False); @@ -1059,7 +1059,7 @@ package body Alire.Crate_Configuration is (String'(Key (I).As_String & Profile_Assign & Element (I)'Image)); end loop; - Config.Edit.Set_Locally ("last_build_profile", + Settings.Edit.Set_Locally ("last_build_profile", Profiles.Flatten (Profile_Split)); end Save_Last_Build_Profiles; diff --git a/src/alire/alire-index.ads b/src/alire/alire-index.ads index c9a70627..2e581d03 100644 --- a/src/alire/alire-index.ads +++ b/src/alire/alire-index.ads @@ -2,7 +2,7 @@ private with Alire_Early_Elaboration; pragma Elaborate_All (Alire_Early_Elaboration); pragma Unreferenced (Alire_Early_Elaboration); -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Crates.Containers; with Alire.Dependencies; with Alire.Origins; @@ -16,12 +16,13 @@ with Semantic_Versioning.Extended; package Alire.Index is - Community_Host : constant String := Config.Builtins.Index_Host.Get; + Community_Host : constant String := Settings.Builtins.Index_Host.Get; - Community_Organization : constant String := Config.Builtins.Index_Owner.Get; + Community_Organization : constant String := + Settings.Builtins.Index_Owner.Get; Community_Repo_Name : constant String - := Config.Builtins.Index_Repository_Name.Get; + := Settings.Builtins.Index_Repository_Name.Get; Community_Repo : constant URL := "git+" & Community_Host diff --git a/src/alire/alire-index_on_disk-loading.adb b/src/alire/alire-index_on_disk-loading.adb index 1051bac1..e9ff9ad9 100644 --- a/src/alire/alire-index_on_disk-loading.adb +++ b/src/alire/alire-index_on_disk-loading.adb @@ -1,8 +1,8 @@ with Ada.Directories; with Ada.Text_IO; -with Alire.Config.Builtins; -with Alire.Config.Edit; +with Alire.Settings.Builtins; +with Alire.Settings.Edit; with Alire.Containers; with Alire.Index; with Alire.Index_On_Disk.Updates; @@ -189,7 +189,7 @@ package body Alire.Index_On_Disk.Loading is Result : Outcome with Warnings => Off; -- Spurious warning to be silenced in Debian stable/Ubuntu LTS GNATs. Indexes : constant Set := - Find_All (Config.Edit.Indexes_Directory, + Find_All (Settings.Edit.Indexes_Directory, Result, Cached => False); use Sets; @@ -205,15 +205,15 @@ package body Alire.Index_On_Disk.Loading is return Add (Origin => Alire.Index.Community_Repo & "#" & Alire.Index.Community_Branch, Name => Alire.Index.Community_Name, - Under => Config.Edit.Indexes_Directory, + Under => Settings.Edit.Indexes_Directory, Before => Before); end Actually_Add; begin - if not Config.Builtins.Index_Auto_Community.Get then + if not Settings.Builtins.Index_Auto_Community.Get then Warnings.Warn_Once ("Not configuring the community index, disabled via " - & Config.Builtins.Index_Auto_Community.Key); + & Settings.Builtins.Index_Auto_Community.Key); return Outcome_Success; end if; @@ -257,7 +257,7 @@ package body Alire.Index_On_Disk.Loading is ------------------ function Default_Path return Absolute_Path - is (Config.Edit.Indexes_Directory); + is (Settings.Edit.Indexes_Directory); ----------- -- Setup -- @@ -420,7 +420,7 @@ package body Alire.Index_On_Disk.Loading is if From.Is_Empty and then Path = "" then Load (Crate, Detect_Externals, Strict, From, - Config.Edit.Indexes_Directory); + Settings.Edit.Indexes_Directory); return; elsif Path /= "" then Setup (Path); diff --git a/src/alire/alire-index_on_disk-updates.adb b/src/alire/alire-index_on_disk-updates.adb index c22ec959..29a0b980 100644 --- a/src/alire/alire-index_on_disk-updates.adb +++ b/src/alire/alire-index_on_disk-updates.adb @@ -1,14 +1,14 @@ with Ada.Calendar; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Index_On_Disk.Loading; with CLIC.User_Input; package body Alire.Index_On_Disk.Updates is - package Builtins renames Config.Builtins; - subtype Int is Config.Config_Int; + package Builtins renames Settings.Builtins; + subtype Int is Settings.Config_Int; Epoch : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 2017, @@ -21,7 +21,7 @@ package body Alire.Index_On_Disk.Updates is ----------------- procedure Auto_Update - (Under : Absolute_Path := Config.Edit.Indexes_Directory) + (Under : Absolute_Path := Settings.Edit.Indexes_Directory) is Wait : constant Int := Builtins.Index_Auto_Update.Get; @@ -52,13 +52,13 @@ package body Alire.Index_On_Disk.Updates is Valid => (Yes | No => True, others => False), Default => Yes) = Yes then - Builtins.Index_Auto_Update_Asked.Set (Config.Global, True); + Builtins.Index_Auto_Update_Asked.Set (Settings.Global, True); return True; else Put_Info ("Understood, Alire will not perform automatic updates."); Trace.Debug ("Index auto-refresh disabled by user"); - Builtins.Index_Auto_Update.Set (Config.Global, 0); - Builtins.Index_Auto_Update_Asked.Set (Config.Global, True); + Builtins.Index_Auto_Update.Set (Settings.Global, 0); + Builtins.Index_Auto_Update_Asked.Set (Settings.Global, True); return False; end if; end User_Approves; @@ -122,7 +122,7 @@ package body Alire.Index_On_Disk.Updates is ---------------- function Update_All - (Under : Absolute_Path := Config.Edit.Indexes_Directory) return Outcome + (Under : Absolute_Path := Settings.Edit.Indexes_Directory) return Outcome is Result : Outcome; Indexes : constant Loading.Set := Loading.Find_All (Under, Result); @@ -163,7 +163,7 @@ package body Alire.Index_On_Disk.Updates is use Ada.Calendar; begin Trace.Debug ("Index auto-refresh timestamp updated"); - Builtins.Index_Last_Update.Set (Config.Global, + Builtins.Index_Last_Update.Set (Settings.Global, Int (Clock - Epoch)); end Reset_Update_Time; diff --git a/src/alire/alire-index_on_disk-updates.ads b/src/alire/alire-index_on_disk-updates.ads index ceac9389..ed2f70b6 100644 --- a/src/alire/alire-index_on_disk-updates.ads +++ b/src/alire/alire-index_on_disk-updates.ads @@ -1,13 +1,13 @@ -with Alire.Config.Edit; +with Alire.Settings.Edit; package Alire.Index_On_Disk.Updates is procedure Auto_Update - (Under : Absolute_Path := Config.Edit.Indexes_Directory); + (Under : Absolute_Path := Settings.Edit.Indexes_Directory); -- Check last update timestamp and update if necessary function Update_All - (Under : Absolute_Path := Config.Edit.Indexes_Directory) return Outcome; + (Under : Absolute_Path := Settings.Edit.Indexes_Directory) return Outcome; -- Find and update all indexes at given location procedure Reset_Update_Time; diff --git a/src/alire/alire-origins-deployers-git.adb b/src/alire/alire-origins-deployers-git.adb index e3a4d1d5..2fc62c45 100644 --- a/src/alire/alire-origins-deployers-git.adb +++ b/src/alire/alire-origins-deployers-git.adb @@ -1,4 +1,4 @@ -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Directories; with Alire.VCSs.Git; @@ -15,7 +15,7 @@ package body Alire.Origins.Deployers.Git is begin VCSs.Git.Handler.Clone (This.Base.URL_With_Commit, Folder).Assert; - if Config.Builtins.Dependencies_Git_Keep_Repository.Get then + if Settings.Builtins.Dependencies_Git_Keep_Repository.Get then Trace.Debug ("Keeping git repo from " & This.Base.TTY_URL_With_Commit & " at " & TTY.URL (Folder)); diff --git a/src/alire/alire-paths-vault.ads b/src/alire/alire-paths-vault.ads index 23d4f317..0c6b1eeb 100644 --- a/src/alire/alire-paths-vault.ads +++ b/src/alire/alire-paths-vault.ads @@ -1,4 +1,4 @@ -with Alire.Config.Edit; +with Alire.Settings.Edit; package Alire.Paths.Vault is @@ -10,7 +10,7 @@ package Alire.Paths.Vault is -- are run there (see Alire.Builds). function Path return Absolute_Path - is (Config.Edit.Cache_Path + is (Settings.Edit.Cache_Path / Release_Folder_Inside_Working_Folder); end Alire.Paths.Vault; diff --git a/src/alire/alire-platforms-current.ads b/src/alire/alire-platforms-current.ads index 913b311a..bc632742 100644 --- a/src/alire/alire-platforms-current.ads +++ b/src/alire/alire-platforms-current.ads @@ -1,6 +1,6 @@ private with AAA.Enum_Tools; -private with Alire.Config.Builtins; +private with Alire.Settings.Builtins; limited with Alire.Environment; private with Alire.OS_Lib.Subprocess; private with Alire.Platforms.Common; @@ -92,13 +92,14 @@ private Platforms.Distribution_Unknown -- Overridden detection - elsif Config.Builtins.Distribution_Override.Get /= "" then - (if Is_Valid_Distro (Config.Builtins.Distribution_Override.Get) then - Distributions'Value (Config.Builtins.Distribution_Override.Get) + elsif Settings.Builtins.Distribution_Override.Get /= "" then + (if Is_Valid_Distro (Settings.Builtins.Distribution_Override.Get) then + Distributions'Value + (Settings.Builtins.Distribution_Override.Get) else Return_With_Warning ("Invalid distribution override: " - & Config.Builtins.Distribution_Override.Get, + & Settings.Builtins.Distribution_Override.Get, Result => Platforms.Distribution_Unknown)) -- Regular detection diff --git a/src/alire/alire-platforms-folders.ads b/src/alire/alire-platforms-folders.ads index 456866be..f330cf74 100644 --- a/src/alire/alire-platforms-folders.ads +++ b/src/alire/alire-platforms-folders.ads @@ -3,7 +3,7 @@ package Alire.Platforms.Folders is -- This spec must be fulfilled by bodies for each different OS we support -- IMPORTANT NOTE: these are not intended to be used directly in most - -- cases; instead, use the ones in Alire.Config.Edit that take into + -- cases; instead, use the ones in Alire.Settings.Edit that take into -- account user overriding of the config location. function Config return Absolute_Path; diff --git a/src/alire/alire-publish.adb b/src/alire/alire-publish.adb index a0aa7d4e..0edcc4b2 100644 --- a/src/alire/alire-publish.adb +++ b/src/alire/alire-publish.adb @@ -3,7 +3,7 @@ with Ada.Text_IO; with AAA.Strings; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Crates; with Alire.Environment; with Alire.Errors; @@ -578,12 +578,12 @@ package body Alire.Publish is then raise Early_Stop; end if; - elsif not Config.Builtins.User_Github_Login.Is_Empty then + elsif not Settings.Builtins.User_Github_Login.Is_Empty then Put_Info ("Please upload this file to " & TTY.URL (Index.Community_Host & "/" - & Config.Builtins.User_Github_Login.Get & "/" + & Settings.Builtins.User_Github_Login.Get & "/" & Index.Community_Repo_Name & "/upload/" & Index.Community_Branch & "/" @@ -810,7 +810,7 @@ package body Alire.Publish is -- User has an account - if Config.Builtins.User_Github_Login.Is_Empty then + if Settings.Builtins.User_Github_Login.Is_Empty then Put_Info ("Publishing to the community index" & " requires a GitHub account."); else diff --git a/src/alire/alire-releases.adb b/src/alire/alire-releases.adb index 95aa11ef..1858480f 100644 --- a/src/alire/alire-releases.adb +++ b/src/alire/alire-releases.adb @@ -1,7 +1,7 @@ with Ada.Directories; with Ada.Text_IO; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Crates; with Alire.Directories; with Alire.Defaults; @@ -85,7 +85,7 @@ package body Alire.Releases is Newline : constant String := ASCII.LF & " "; begin for Dep of This.Flat_Dependencies loop - if Config.Builtins.Warning_Caret.Get + if Settings.Builtins.Warning_Caret.Get and then AAA.Strings.Contains (Dep.Versions.Image, "^0") then @@ -98,7 +98,7 @@ package body Alire.Releases is & "The suspicious dependency is: " & TTY.Version (Dep.Image) & Newline & "You can disable this warning by setting the option " - & TTY.Emph (Config.Builtins.Warning_Caret.Key) & " to false.", + & TTY.Emph (Settings.Builtins.Warning_Caret.Key) & " to false.", Warnings.Caret_Or_Tilde); return True; end if; diff --git a/src/alire/alire-roots.adb b/src/alire/alire-roots.adb index 0f4d1a29..be9ea1d4 100644 --- a/src/alire/alire-roots.adb +++ b/src/alire/alire-roots.adb @@ -669,7 +669,7 @@ package body Alire.Roots is Guard : Directories.Guard (Directories.Enter (Path (This))) with Unreferenced; -- At some point inside the configuration generation process the config - -- is loaded and Config.Edit.Filepath requires being inside the root, + -- is loaded and Settings.Edit.Filepath requires being inside the root, -- which can't be directly used because of circularities. begin This.Load_Configuration; diff --git a/src/alire/alire-selftest.adb b/src/alire/alire-selftest.adb index cdaf422a..a6ae8780 100644 --- a/src/alire/alire-selftest.adb +++ b/src/alire/alire-selftest.adb @@ -1,4 +1,4 @@ -with Alire.Config.Edit; +with Alire.Settings.Edit; with Alire.Utils.Regex; with Alire.VCSs.Git; @@ -13,28 +13,28 @@ package body Alire.Selftest is Key : constant String := "test_key"; Val : constant String := "nominal"; begin - Config.Edit.Set_Globally (Key, Val); - pragma Assert (Config.DB.Defined (Key)); - pragma Assert (Config.DB.Get (Key, "snafu") = Val); + Settings.Edit.Set_Globally (Key, Val); + pragma Assert (Settings.DB.Defined (Key)); + pragma Assert (Settings.DB.Get (Key, "snafu") = Val); -- Check typed storing -- Raw storing of integer - Config.Edit.Set_Globally (Key, "777"); - pragma Assert (Integer (Config.DB.Get (Key, 0)) = 777); + Settings.Edit.Set_Globally (Key, "777"); + pragma Assert (Integer (Settings.DB.Get (Key, 0)) = 777); -- Raw storing of boolean - Config.Edit.Set_Globally (Key, "true"); - pragma Assert (Config.DB.Get (Key, False) = True); + Settings.Edit.Set_Globally (Key, "true"); + pragma Assert (Settings.DB.Get (Key, False) = True); -- Typed storing of boolean - Config.Edit.Set_Boolean (Config.Global, Key, False); - pragma Assert (Config.DB.Get (Key, True) = False); + Settings.Edit.Set_Boolean (Settings.Global, Key, False); + pragma Assert (Settings.DB.Get (Key, True) = False); -- Raw storing of boolean with wrong type - Config.Edit.Set_Globally (Key, "True"); + Settings.Edit.Set_Globally (Key, "True"); -- This causes a string to be stored, as in TOML only "true" is bool - pragma Assert (Config.DB.Get (Key, "False") = "True"); + pragma Assert (Settings.DB.Get (Key, "False") = "True"); end Check_Config_Changes; diff --git a/src/alire/alire-config-builtins.ads b/src/alire/alire-settings-builtins.ads similarity index 98% rename from src/alire/alire-config-builtins.ads rename to src/alire/alire-settings-builtins.ads index 745d0573..d4c87f6a 100644 --- a/src/alire/alire-config-builtins.ads +++ b/src/alire/alire-settings-builtins.ads @@ -1,6 +1,6 @@ -with Alire.Config.Checks; +with Alire.Settings.Checks; -package Alire.Config.Builtins is +package Alire.Settings.Builtins is subtype Builtin is Builtin_Option; @@ -205,4 +205,4 @@ package Alire.Config.Builtins is "using a compatible index with a lower version than the newest" & " known."); -end Alire.Config.Builtins; +end Alire.Settings.Builtins; diff --git a/src/alire/alire-config-checks.adb b/src/alire/alire-settings-checks.adb similarity index 87% rename from src/alire/alire-config-checks.adb rename to src/alire/alire-settings-checks.adb index b86edbfd..e8fb2413 100644 --- a/src/alire/alire-config-checks.adb +++ b/src/alire/alire-settings-checks.adb @@ -2,7 +2,7 @@ with AAA.Enum_Tools; with Alire.Platforms; -package body Alire.Config.Checks is +package body Alire.Settings.Checks is function Is_Valid is new AAA.Enum_Tools.Is_Valid (Alire.Platforms.Known_Distributions); @@ -17,4 +17,4 @@ package body Alire.Config.Checks is is (Value.Kind in TOML.TOML_String and then Is_Valid (Value.As_String)); -end Alire.Config.Checks; +end Alire.Settings.Checks; diff --git a/src/alire/alire-config-checks.ads b/src/alire/alire-settings-checks.ads similarity index 73% rename from src/alire/alire-config-checks.ads rename to src/alire/alire-settings-checks.ads index a5f971ec..a25a48cb 100644 --- a/src/alire/alire-config-checks.ads +++ b/src/alire/alire-settings-checks.ads @@ -1,9 +1,9 @@ with TOML; -package Alire.Config.Checks is +package Alire.Settings.Checks is function Valid_Distro (Key : CLIC.Config.Config_Key; Value : TOML.TOML_Value) return Boolean; -end Alire.Config.Checks; +end Alire.Settings.Checks; diff --git a/src/alire/alire-settings-edit-early_load.adb b/src/alire/alire-settings-edit-early_load.adb new file mode 100644 index 00000000..de3ed913 --- /dev/null +++ b/src/alire/alire-settings-edit-early_load.adb @@ -0,0 +1,14 @@ +package body Alire.Settings.Edit.Early_Load is + + ------------------- + -- Load_Settings -- + ------------------- + + procedure Load_Settings is + begin + Alire.Settings.Edit.Load_Config; + end Load_Settings; + +begin + Load_Settings; +end Alire.Settings.Edit.Early_Load; diff --git a/src/alire/alire-config-edit-early_load.ads b/src/alire/alire-settings-edit-early_load.ads similarity index 55% rename from src/alire/alire-config-edit-early_load.ads rename to src/alire/alire-settings-edit-early_load.ads index 73656602..4c6cafe5 100644 --- a/src/alire/alire-config-edit-early_load.ads +++ b/src/alire/alire-settings-edit-early_load.ads @@ -1,7 +1,7 @@ -package Alire.Config.Edit.Early_Load with Elaborate_Body is +package Alire.Settings.Edit.Early_Load with Elaborate_Body is - procedure Load_Config; + procedure Load_Settings; -- For internal use of Alire_Early_Elaboration, DO NOT CALL otherwise. -- This should be hidden but that would require a non-trivial refactoring. -end Alire.Config.Edit.Early_Load; +end Alire.Settings.Edit.Early_Load; diff --git a/src/alire/alire-config-edit.adb b/src/alire/alire-settings-edit.adb similarity index 96% rename from src/alire/alire-config-edit.adb rename to src/alire/alire-settings-edit.adb index b7a846fb..3303e53f 100644 --- a/src/alire/alire-config-edit.adb +++ b/src/alire/alire-settings-edit.adb @@ -1,16 +1,16 @@ with Ada.Text_IO; -with Alire.Config.Builtins; with Alire.Environment; with Alire.Paths; with Alire.Platforms.Folders; with Alire.Platforms.Current; +with Alire.Settings.Builtins; with Alire.Utils; with CLIC.Config.Edit; with CLIC.Config.Load; -package body Alire.Config.Edit is +package body Alire.Settings.Edit is use Ada.Strings.Unbounded; use AAA.Strings; @@ -57,7 +57,7 @@ package body Alire.Config.Edit is -- Set -- --------- - procedure Set (Level : Config.Level; + procedure Set (Level : Settings.Level; Key : CLIC.Config.Config_Key; Value : String; Check : CLIC.Config.Check_Import := null) @@ -73,7 +73,7 @@ package body Alire.Config.Edit is -- Unset -- ----------- - procedure Unset (Level : Config.Level; + procedure Unset (Level : Settings.Level; Key : CLIC.Config.Config_Key) is begin @@ -92,7 +92,7 @@ package body Alire.Config.Edit is -- Set_Boolean -- ----------------- - procedure Set_Boolean (Level : Config.Level; + procedure Set_Boolean (Level : Settings.Level; Key : CLIC.Config.Config_Key; Value : Boolean; Check : CLIC.Config.Check_Import := null) @@ -114,7 +114,7 @@ package body Alire.Config.Edit is begin case Lvl is when Global => - return Alire.Config.Edit.Path / "config.toml"; + return Alire.Settings.Edit.Path / "config.toml"; when Local => declare Candidate : constant String := @@ -154,7 +154,7 @@ package body Alire.Config.Edit is -- Set variables elsewhere Platforms.Current.Disable_Distribution_Detection := - Config.Builtins.Distribution_Disable_Detection.Get; + Settings.Builtins.Distribution_Disable_Detection.Get; if Platforms.Current.Disable_Distribution_Detection then Trace.Debug ("Distribution detection disabled by configuration"); end if; @@ -318,4 +318,4 @@ package body Alire.Config.Edit is end loop; end Print_Builtins_Doc; -end Alire.Config.Edit; +end Alire.Settings.Edit; diff --git a/src/alire/alire-config-edit.ads b/src/alire/alire-settings-edit.ads similarity index 91% rename from src/alire/alire-config-edit.ads rename to src/alire/alire-settings-edit.ads index b1055b7e..13959746 100644 --- a/src/alire/alire-config-edit.ads +++ b/src/alire/alire-settings-edit.ads @@ -6,7 +6,7 @@ with CLIC.Config; with TOML; -package Alire.Config.Edit is +package Alire.Settings.Edit is -- Shortcuts that use the standard config locations. These interpret the -- value in string as a TOML type whenever possible. @@ -19,14 +19,14 @@ package Alire.Config.Edit is Value : String; Check : CLIC.Config.Check_Import := null); - procedure Set (Level : Config.Level; + procedure Set (Level : Settings.Level; Key : CLIC.Config.Config_Key; Value : String; Check : CLIC.Config.Check_Import := null); -- Typed alternatives - procedure Set_Boolean (Level : Config.Level; + procedure Set_Boolean (Level : Settings.Level; Key : CLIC.Config.Config_Key; Value : Boolean; Check : CLIC.Config.Check_Import := null); @@ -35,7 +35,7 @@ package Alire.Config.Edit is -- here all non-preelaborable things related to config loading. This -- way, querying stays preelaborable. - procedure Unset (Level : Config.Level; + procedure Unset (Level : Settings.Level; Key : CLIC.Config.Config_Key); -- Unset a key at a level; silently succeed even if the key was undefined. @@ -66,7 +66,7 @@ package Alire.Config.Edit is -- Return path of the configuration file corresponding to the given -- configuration level. - -- Support for built-in config variables. See Alire.Config.Builtins also. + -- Support for built-in config variables. See Alire.Settings.Builtins also. function Builtins_Info return AAA.Strings.Vector; -- Return a String_Vector with the documentation of builtin configuration @@ -88,4 +88,4 @@ private -- the program-wide configuration ready. This is done during startup from -- Alire_Early_Elaboration so config is available ASAP. -end Alire.Config.Edit; +end Alire.Settings.Edit; diff --git a/src/alire/alire-config.adb b/src/alire/alire-settings.adb similarity index 94% rename from src/alire/alire-config.adb rename to src/alire/alire-settings.adb index 5b5de143..c5d21d5c 100644 --- a/src/alire/alire-config.adb +++ b/src/alire/alire-settings.adb @@ -1,6 +1,6 @@ -with Alire.Config.Edit; +with Alire.Settings.Edit; -package body Alire.Config is +package body Alire.Settings is -------- -- DB -- @@ -61,7 +61,7 @@ package body Alire.Config is --------- procedure Set (This : Builtin_Option; - Level : Config.Level; + Level : Settings.Level; Value : String) is begin @@ -73,7 +73,7 @@ package body Alire.Config is --------- procedure Set (This : Builtin_Option; - Level : Config.Level; + Level : Settings.Level; Value : Boolean) is begin @@ -85,7 +85,7 @@ package body Alire.Config is --------- procedure Set (This : Builtin_Option; - Level : Config.Level; + Level : Settings.Level; Value : Config_Int) is begin @@ -97,7 +97,7 @@ package body Alire.Config is ----------- procedure Unset (This : Builtin_Option; - Level : Config.Level) + Level : Settings.Level) is begin Edit.Unset (Level, +This.Key); @@ -182,4 +182,4 @@ package body Alire.Config is Public => Public, Check => Check)); -end Alire.Config; +end Alire.Settings; diff --git a/src/alire/alire-config.ads b/src/alire/alire-settings.ads similarity index 94% rename from src/alire/alire-config.ads rename to src/alire/alire-settings.ads index 5082ea52..66597784 100644 --- a/src/alire/alire-config.ads +++ b/src/alire/alire-settings.ads @@ -6,7 +6,7 @@ with Alire.OS_Lib; use Alire.OS_Lib.Operators; with CLIC.Config; -package Alire.Config is +package Alire.Settings is function DB return access constant CLIC.Config.Instance; @@ -49,19 +49,19 @@ package Alire.Config is procedure Set_Globally (This : Builtin_Option; Value : String); procedure Set (This : Builtin_Option; - Level : Config.Level; + Level : Settings.Level; Value : String); procedure Set (This : Builtin_Option; - Level : Config.Level; + Level : Settings.Level; Value : Boolean); procedure Set (This : Builtin_Option; - Level : Config.Level; + Level : Settings.Level; Value : Config_Int); procedure Unset (This : Builtin_Option; - Level : Config.Level); + Level : Settings.Level); function New_Builtin (Key : CLIC.Config.Config_Key; Kind : Builtin_Kind; @@ -115,4 +115,4 @@ private All_Builtins : Builtin_Maps.Map; -end Alire.Config; +end Alire.Settings; diff --git a/src/alire/alire-solutions.adb b/src/alire/alire-solutions.adb index e0ea1db4..8e5228c4 100644 --- a/src/alire/alire-solutions.adb +++ b/src/alire/alire-solutions.adb @@ -1,6 +1,6 @@ with Ada.Containers; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Crates; with Alire.Dependencies.Diffs; with Alire.Dependencies.Graphs; @@ -1402,7 +1402,7 @@ package body Alire.Solutions is -- Do nothing when deps are being removed. - if not Config.Builtins.Solver_Autonarrow.Get or else + if not Settings.Builtins.Solver_Autonarrow.Get or else not Diff.Removed.Is_Empty then return New_Deps; diff --git a/src/alire/alire-toml_index.adb b/src/alire/alire-toml_index.adb index 54de246b..07c3aac6 100644 --- a/src/alire/alire-toml_index.adb +++ b/src/alire/alire-toml_index.adb @@ -1,6 +1,6 @@ with Ada.Directories; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Crates; with Alire.Directories; with Alire.Loading; @@ -113,7 +113,7 @@ package body Alire.TOML_Index is use type Semantic_Versioning.Version; Warn_Of_Old_Compatible : constant Boolean := - Config.Builtins.Warning_Old_Index.Get; + Settings.Builtins.Warning_Old_Index.Get; ---------------------- -- Compare_Branches -- @@ -130,7 +130,7 @@ package body Alire.TOML_Index is & TTY.Emph (Alire.Index.Branch_Kind) & "' but your community index branch is '" & TTY.Emph (Local) & "'", - Disable_Setting => Config.Builtins.Warning_Old_Index.Key); + Disable_Setting => Settings.Builtins.Warning_Old_Index.Key); Suggest_Update := True; end if; end Compare_Branches; @@ -190,7 +190,7 @@ package body Alire.TOML_Index is & ") is older than the newest supported by alr (" & Alire.Index.Version.Image & ")", Disable_Setting => - Config.Builtins.Warning_Old_Index.Key); + Settings.Builtins.Warning_Old_Index.Key); Suggest_Update := True; elsif not Alire.Index.Valid_Versions.Contains (Loading_Index_Version) then diff --git a/src/alire/alire-toolchains.adb b/src/alire/alire-toolchains.adb index 45c6d215..08a118e4 100644 --- a/src/alire/alire-toolchains.adb +++ b/src/alire/alire-toolchains.adb @@ -3,7 +3,7 @@ with AAA.Text_IO; with Ada.Containers.Indefinite_Vectors; with Ada.Directories; -with Alire.Config.Edit; +with Alire.Settings.Edit; with Alire.Directories; with Alire.Index; with Alire.Manifest; @@ -44,7 +44,7 @@ package body Alire.Toolchains is -- Assistant -- --------------- - procedure Assistant (Level : Config.Level; + procedure Assistant (Level : Settings.Level; Allow_Incompatible : Boolean := False; First_Run : Boolean := False) is package Release_Vectors is new @@ -403,14 +403,15 @@ package body Alire.Toolchains is -- Set_As_Default -- -------------------- - procedure Set_As_Default (Release : Releases.Release; Level : Config.Level) + procedure Set_As_Default (Release : Releases.Release; + Level : Settings.Level) is begin - Alire.Config.Edit.Set + Alire.Settings.Edit.Set (Level, Key => Tool_Key (Release.Name), Value => Release.Milestone.Image); - Alire.Config.Edit.Set_Boolean + Alire.Settings.Edit.Set_Boolean (Level, Key => Tool_Key (Release.Name, For_Is_External), Value => not Release.Origin.Is_Index_Provided); @@ -420,10 +421,11 @@ package body Alire.Toolchains is -- Set_Automatic_Assistant -- ----------------------------- - procedure Set_Automatic_Assistant (Enabled : Boolean; Level : Config.Level) + procedure Set_Automatic_Assistant (Enabled : Boolean; + Level : Settings.Level) is begin - Config.Builtins.Toolchain_Assistant.Set (Level, Enabled); + Settings.Builtins.Toolchain_Assistant.Set (Level, Enabled); end Set_Automatic_Assistant; ------------------------ @@ -431,7 +433,7 @@ package body Alire.Toolchains is ------------------------ function Tool_Is_Configured (Crate : Crate_Name) return Boolean - is (Config.DB.Defined (Tool_Key (Crate))); + is (Settings.DB.Defined (Tool_Key (Crate))); --------------------- -- Tool_Dependency -- @@ -467,12 +469,12 @@ package body Alire.Toolchains is ----------------- procedure Unconfigure (Crate : Crate_Name; - Level : Config.Level; + Level : Settings.Level; Fail_If_Unset : Boolean := True) is begin - if CLIC.Config.Defined (Config.DB.all, Tool_Key (Crate)) and then + if CLIC.Config.Defined (Settings.DB.all, Tool_Key (Crate)) and then not CLIC.Config.Edit.Unset - (Config.Edit.Filepath (Level), + (Settings.Edit.Filepath (Level), Tool_Key (Crate)) then declare @@ -490,12 +492,13 @@ package body Alire.Toolchains is -- Remove caching of external condition too for consistency - if CLIC.Config.Defined (Config.DB.all, Tool_Key (Crate, For_Is_External)) + if CLIC.Config.Defined (Settings.DB.all, + Tool_Key (Crate, For_Is_External)) then Trace.Debug ("Unsetting " & Tool_Key (Crate, For_Is_External) & ": " & CLIC.Config.Edit.Unset - (Config.Edit.Filepath (Level), + (Settings.Edit.Filepath (Level), Tool_Key (Crate, For_Is_External))'Image); end if; end Unconfigure; @@ -605,9 +608,9 @@ package body Alire.Toolchains is ---------- function Path return Absolute_Path - is (if Config.Builtins.Toolchain_Dir.Get /= "" - then Config.Builtins.Toolchain_Dir.Get - else Config.Edit.Cache_Path / "toolchains"); + is (if Settings.Builtins.Toolchain_Dir.Get /= "" + then Settings.Builtins.Toolchain_Dir.Get + else Settings.Edit.Cache_Path / "toolchains"); ------------ -- Deploy -- @@ -717,9 +720,9 @@ package body Alire.Toolchains is -- So remove it at any level. We currently do not have a way to know -- from which level we have to remove this configuration. - Toolchains.Unconfigure (Release.Name, Config.Global, + Toolchains.Unconfigure (Release.Name, Settings.Global, Fail_If_Unset => False); - Toolchains.Unconfigure (Release.Name, Config.Local, + Toolchains.Unconfigure (Release.Name, Settings.Local, Fail_If_Unset => False); Invalidate_Available_Cache; diff --git a/src/alire/alire-toolchains.ads b/src/alire/alire-toolchains.ads index 31c9c026..51b44f3e 100644 --- a/src/alire/alire-toolchains.ads +++ b/src/alire/alire-toolchains.ads @@ -2,7 +2,7 @@ with Ada.Containers.Indefinite_Ordered_Sets; with AAA.Strings; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Dependencies; with Alire.Errors; with Alire.Milestones; @@ -30,7 +30,7 @@ package Alire.Toolchains is function Any_Tool (Crate : Crate_Name) return Dependencies.Dependency; -- Returns a dependency on crate* - procedure Assistant (Level : Config.Level; + procedure Assistant (Level : Settings.Level; Allow_Incompatible : Boolean := False; First_Run : Boolean := False); -- Runs the interactive assistant to select the default toolchain. By @@ -43,12 +43,14 @@ package Alire.Toolchains is -- plain `gnat`. This way we need not to litter the callers with similar -- transformations, as we always want whatever gnat_XXX is used for "gnat". - procedure Set_Automatic_Assistant (Enabled : Boolean; Level : Config.Level); + procedure Set_Automatic_Assistant (Enabled : Boolean; + Level : Settings.Level); -- Enable/Disable the automatic assistant on next run function Assistant_Enabled return Boolean; - procedure Set_As_Default (Release : Releases.Release; Level : Config.Level); + procedure Set_As_Default (Release : Releases.Release; + Level : Settings.Level); -- Mark the given release as the default to be used. Does not check that it -- be already installed. @@ -83,7 +85,7 @@ package Alire.Toolchains is -- manually). procedure Unconfigure (Crate : Crate_Name; - Level : Config.Level; + Level : Settings.Level; Fail_If_Unset : Boolean := True); -- Set the crate as not configured. If not set and Fail_If_Unset, raise @@ -160,7 +162,7 @@ private ----------------------- function Assistant_Enabled return Boolean - is (Config.Builtins.Toolchain_Assistant.Get); + is (Settings.Builtins.Toolchain_Assistant.Get); ---------------------- -- Tool_Is_External -- @@ -168,7 +170,7 @@ private function Tool_Is_External (Crate : Crate_Name) return Boolean is (Boolean'Value - (Config.DB.Get_As_String -- because it could be stored as bool or string + (Settings.DB.Get_As_String -- because it could be stored as bool or str (Tool_Key (Crate, For_Is_External), "True"))); -------------- @@ -182,8 +184,8 @@ private then Tool_Key (GNAT_Crate, Kind) else CLIC.Config.Config_Key ((case Kind is - when For_Use => Config.Builtins.Toolchain_Use.Key, - when For_Is_External => Config.Builtins.Toolchain_External.Key) + when For_Use => Settings.Builtins.Toolchain_Use.Key, + when For_Is_External => Settings.Builtins.Toolchain_External.Key) & "." & Crate.As_String)); -------------------- @@ -191,6 +193,6 @@ private -------------------- -- Return the milestone stored by the user for this tool function Tool_Milestone (Crate : Crate_Name) return Milestones.Milestone - is (Milestones.New_Milestone (Config.DB.Get (Tool_Key (Crate), ""))); + is (Milestones.New_Milestone (Settings.DB.Get (Tool_Key (Crate), ""))); end Alire.Toolchains; diff --git a/src/alire/alire-utils-user_input-query_config.adb b/src/alire/alire-utils-user_input-query_config.adb index fed2561e..50e110c3 100644 --- a/src/alire/alire-utils-user_input-query_config.adb +++ b/src/alire/alire-utils-user_input-query_config.adb @@ -1,4 +1,4 @@ -with Alire.Config.Edit; +with Alire.Settings.Edit; with CLIC.User_Input; use CLIC.User_Input; package body Alire.Utils.User_Input.Query_Config is @@ -13,17 +13,17 @@ package body Alire.Utils.User_Input.Query_Config is Validation : String_Validation_Access) return String is - use Alire.Config; + use Alire.Settings; begin - if Config.DB.Defined (Config_Key) then - return Config.DB.Get (Config_Key, Default); + if Settings.DB.Defined (Config_Key) then + return Settings.DB.Get (Config_Key, Default); else declare Result : constant String := Query_String (Question, Default, Validation); begin if Result /= Default then - Alire.Config.Edit.Set_Globally (Config_Key, Result); + Alire.Settings.Edit.Set_Globally (Config_Key, Result); end if; return Result; diff --git a/src/alire/alire_early_elaboration.adb b/src/alire/alire_early_elaboration.adb index 94765f2e..ae97124d 100644 --- a/src/alire/alire_early_elaboration.adb +++ b/src/alire/alire_early_elaboration.adb @@ -2,7 +2,7 @@ with AAA.Strings; with Ada.Directories; -with Alire.Config.Edit.Early_Load; +with Alire.Settings.Edit.Early_Load; with GNAT.Command_Line; with GNAT.OS_Lib; @@ -98,7 +98,7 @@ package body Alire_Early_Elaboration is Early_Error ("Given configuration path is not a directory: " & Path); else - Alire.Config.Edit.Set_Path (Adirs.Full_Name (Path)); + Alire.Settings.Edit.Set_Path (Adirs.Full_Name (Path)); end if; end Set_Config_Path; @@ -199,7 +199,7 @@ package body Alire_Early_Elaboration is end if; -- Load config ASAP - Alire.Config.Edit.Early_Load.Load_Config; + Alire.Settings.Edit.Early_Load.Load_Settings; end Early_Switch_Detection; ------------------- diff --git a/src/alire/os_windows/alire-platforms-current__windows.adb b/src/alire/os_windows/alire-platforms-current__windows.adb index bc136d10..d4ccb314 100644 --- a/src/alire/os_windows/alire-platforms-current__windows.adb +++ b/src/alire/os_windows/alire-platforms-current__windows.adb @@ -8,7 +8,7 @@ pragma Unreferenced (Alire_Early_Elaboration); with Alire.Environment; with Alire.OS_Lib; use Alire.OS_Lib; -with Alire.Config.Builtins.Windows; +with Alire.Settings.Builtins.Windows; with Alire.Errors; with GNATCOLL.VFS; @@ -154,7 +154,7 @@ package body Alire.Platforms.Current is use CLIC.User_Input; begin - if Config.Builtins.Windows.Msys2_Do_Not_Install.Get then + if Settings.Builtins.Windows.Msys2_Do_Not_Install.Get then -- User already requested that msys2 should not be installed @@ -189,7 +189,8 @@ package body Alire.Platforms.Current is Default => No) = Yes then -- Save user choice in the global config - Config.Builtins.Windows.Msys2_Do_Not_Install.Set_Globally ("true"); + Settings + .Builtins.Windows.Msys2_Do_Not_Install.Set_Globally ("true"); end if; -- We are not allowed to install @@ -244,10 +245,10 @@ package body Alire.Platforms.Current is end Download_File; Msys2_Installer : constant String := - Config.Builtins.Windows.Msys2_Installer.Get; + Settings.Builtins.Windows.Msys2_Installer.Get; Msys2_Installer_URL : constant String := - Config.Builtins.Windows.Msys2_Installer_URL.Get; + Settings.Builtins.Windows.Msys2_Installer_URL.Get; Result : Alire.Outcome; begin @@ -285,9 +286,10 @@ package body Alire.Platforms.Current is return Alire.Outcome_Failure ("Cannot setup msys2 environment"); end; - if Config.Builtins.Windows.Msys2_Install_Dir.Is_Empty then + if Settings.Builtins.Windows.Msys2_Install_Dir.Is_Empty then -- Save msys2 install dir in the global config - Config.Builtins.Windows.Msys2_Install_Dir.Set_Globally (Install_Dir); + Settings + .Builtins.Windows.Msys2_Install_Dir.Set_Globally (Install_Dir); end if; -- Load msys2 environment to attempt first full update according to @@ -295,7 +297,7 @@ package body Alire.Platforms.Current is -- https://www.msys2.org/wiki/MSYS2-installation/ declare Cfg_Install_Dir : constant String := - Config.Builtins.Windows.Msys2_Install_Dir.Get; + Settings.Builtins.Windows.Msys2_Install_Dir.Get; begin Set_Msys2_Env (Cfg_Install_Dir); end; @@ -367,7 +369,7 @@ package body Alire.Platforms.Current is Result : Alire.Outcome; Cfg_Install_Dir : constant String := - Config.Builtins.Windows.Msys2_Install_Dir.Get; + Settings.Builtins.Windows.Msys2_Install_Dir.Get; Pacman : constant String := Alire.OS_Lib.Subprocess.Locate_In_Path ("pacman"); diff --git a/src/alire/os_windows/alire-config-builtins-windows.ads b/src/alire/os_windows/alire-settings-builtins-windows.ads similarity index 85% rename from src/alire/os_windows/alire-config-builtins-windows.ads rename to src/alire/os_windows/alire-settings-builtins-windows.ads index ef3d2b42..f6a2d90a 100644 --- a/src/alire/os_windows/alire-config-builtins-windows.ads +++ b/src/alire/os_windows/alire-settings-builtins-windows.ads @@ -1,8 +1,8 @@ -- Ensure config is loaded for some defaults below -with Alire.Config.Edit.Early_Load; -pragma Unreferenced (Alire.Config.Edit.Early_Load); +with Alire.Settings.Edit.Early_Load; +pragma Unreferenced (Alire.Settings.Edit.Early_Load); -package Alire.Config.Builtins.Windows is +package Alire.Settings.Builtins.Windows is Default_Msys2_Installer : constant String := "msys2-x86_64-20221216.exe"; Default_Msys2_Installer_URL : constant String := @@ -21,7 +21,7 @@ package Alire.Config.Builtins.Windows is Msys2_Install_Dir : constant Builtin := New_Builtin (Key => "msys2.install_dir", Kind => Cfg_Absolute_Path, - Def => Config.Edit.Cache_Path / "msys64", + Def => Settings.Edit.Cache_Path / "msys64", Help => "Directory where Alire will detect and/or install" & " msys2 system package manager. (Windows only)"); @@ -40,4 +40,4 @@ package Alire.Config.Builtins.Windows is Help => "URL of the executable msys2 installer. (Windows only)"); -end Alire.Config.Builtins.Windows; +end Alire.Settings.Builtins.Windows; diff --git a/src/alr/alr-commands-clean.adb b/src/alr/alr-commands-clean.adb index 33412006..d2291873 100644 --- a/src/alr/alr-commands-clean.adb +++ b/src/alr/alr-commands-clean.adb @@ -1,6 +1,6 @@ with Ada.Directories; -with Alire.Config.Edit; +with Alire.Settings.Edit; with Alire.Directories; with Alire.Paths; with Alire.Platforms.Current; @@ -66,7 +66,7 @@ package body Alr.Commands.Clean is -- Configuration-wide cache, where interrupted binary downloads dwell... Alire.Directories.Traverse_Tree - (Start => Alire.Config.Edit.Path, + (Start => Alire.Settings.Edit.Path, Doing => Add_Target'Access, Recurse => True); diff --git a/src/alr/alr-commands-edit.adb b/src/alr/alr-commands-edit.adb index d0de9820..36758d15 100644 --- a/src/alr/alr-commands-edit.adb +++ b/src/alr/alr-commands-edit.adb @@ -1,7 +1,7 @@ with Ada.Containers; with Alire; use Alire; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.OS_Lib.Subprocess; with Alire.Platforms.Current; @@ -21,11 +21,11 @@ package body Alr.Commands.Edit is use Trace; begin if Cmd /= "" then - Config.Set_Globally (Config.Builtins.Editor_Cmd, Cmd); + Settings.Set_Globally (Settings.Builtins.Editor_Cmd, Cmd); Put_Info ("'" & TTY.Terminal (Cmd) & "' is now set as the editor command."); else - Config.Builtins.Editor_Cmd.Unset (Alire.Config.Global); + Settings.Builtins.Editor_Cmd.Unset (Alire.Settings.Global); Put_Info ("The editor command has been unset."); end if; @@ -64,7 +64,7 @@ package body Alr.Commands.Edit is use AAA.Strings; use CLIC.User_Input; - package Builtins renames Alire.Config.Builtins; + package Builtins renames Alire.Settings.Builtins; type Editor_Choice is (VScode, GNATstudio, Other); @@ -177,9 +177,9 @@ package body Alr.Commands.Edit is is use Ada.Containers; use GNAT.Strings; - use Alire.Config; + use Alire.Settings; - package Builtins renames Alire.Config.Builtins; + package Builtins renames Alire.Settings.Builtins; begin if Args.Count /= 0 then Reportaise_Wrong_Arguments (Cmd.Name & " doesn't take arguments"); diff --git a/src/alr/alr-commands-get.adb b/src/alr/alr-commands-get.adb index 3f1145d9..7ca2b122 100644 --- a/src/alr/alr-commands-get.adb +++ b/src/alr/alr-commands-get.adb @@ -1,6 +1,6 @@ with Ada.Directories; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Dependencies; with Alire.Directories; with Alire.Index; @@ -161,8 +161,8 @@ package body Alr.Commands.Get is Trace.Info ("Because --only was used, automatic dependency" & " retrieval is disabled in this workspace:" & " use `alr update` to apply dependency changes"); - Alire.Config.Builtins.Update_Manually_Only.Set (Alire.Config.Local, - True); + Alire.Settings.Builtins.Update_Manually_Only.Set + (Alire.Settings.Local, True); if not CLIC.User_Input.Not_Interactive then Alire.Roots.Print_Nested_Crates (Cmd.Root.Path); diff --git a/src/alr/alr-commands-index.adb b/src/alr/alr-commands-index.adb index a5a470e3..9f261746 100644 --- a/src/alr/alr-commands-index.adb +++ b/src/alr/alr-commands-index.adb @@ -1,6 +1,6 @@ with AAA.Table_IO; -with Alire.Config.Edit; +with Alire.Settings.Edit; with Alire.Index; with Alire.Index_On_Disk.Loading; with Alire.Index_On_Disk.Updates; @@ -32,7 +32,7 @@ package body Alr.Commands.Index is Alire.Index_On_Disk.Loading.Add (Origin => Cmd.Add.all, Name => Cmd.Name.all, - Under => Alire.Config.Edit.Indexes_Directory, + Under => Alire.Settings.Edit.Indexes_Directory, Before => Before); begin Trace.Debug ("Index before ID = " & Before); @@ -50,7 +50,7 @@ package body Alr.Commands.Index is Result : Alire.Outcome; Indexes : constant Index_Load.Set := Index_Load.Find_All - (Alire.Config.Edit.Indexes_Directory, Result); + (Alire.Settings.Edit.Indexes_Directory, Result); Found : Boolean := False; begin if not Result.Success then @@ -153,7 +153,7 @@ package body Alr.Commands.Index is Result : Alire.Outcome; Indexes : constant Index_Load.Set := Index_Load.Find_All - (Alire.Config.Edit.Indexes_Directory, Result); + (Alire.Settings.Edit.Indexes_Directory, Result); Table : AAA.Table_IO.Table; Count : Natural := 0; @@ -301,7 +301,7 @@ package body Alr.Commands.Index is procedure Update_All is Result : constant Alire.Outcome := Index_Updates.Update_All - (Alire.Config.Edit.Indexes_Directory); + (Alire.Settings.Edit.Indexes_Directory); begin if not Result.Success then Reportaise_Command_Failed (Alire.Message (Result)); diff --git a/src/alr/alr-commands-init.adb b/src/alr/alr-commands-init.adb index f5235437..0895c203 100644 --- a/src/alr/alr-commands-init.adb +++ b/src/alr/alr-commands-init.adb @@ -4,7 +4,7 @@ with Ada.Directories; with Ada.Wide_Wide_Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; -with Alire.Config.Builtins; +with Alire.Settings.Builtins; with Alire.Roots.Optional; with Alire.Utils.User_Input.Query_Config; @@ -580,7 +580,7 @@ package body Alr.Commands.Init is procedure Execute (Cmd : in out Command; Args : AAA.Strings.Vector) is - use Alire.Config; + use Alire.Settings; Info : Crate_Init_Info; begin diff --git a/src/alr/alr-commands-settings.adb b/src/alr/alr-commands-settings.adb index 932bd802..5043460d 100644 --- a/src/alr/alr-commands-settings.adb +++ b/src/alr/alr-commands-settings.adb @@ -1,5 +1,5 @@ -with Alire.Config; -with Alire.Config.Edit; +with Alire.Settings; +with Alire.Settings.Edit; with Alire.Root; with CLIC.Config.Info; @@ -17,9 +17,9 @@ package body Alr.Commands.Settings is is Enabled : Natural := 0; - Lvl : constant Alire.Config.Level := (if Cmd.Global - then Alire.Config.Global - else Alire.Config.Local); + Lvl : constant Alire.Settings.Level := (if Cmd.Global + then Alire.Settings.Global + else Alire.Settings.Local); begin -- Check no multi-action @@ -44,7 +44,7 @@ package body Alr.Commands.Settings is end if; if Cmd.Builtins_Doc then - Alire.Config.Edit.Print_Builtins_Doc; + Alire.Settings.Edit.Print_Builtins_Doc; return; end if; @@ -59,13 +59,13 @@ package body Alr.Commands.Settings is when 0 => Trace.Always (CLIC.Config.Info.List - (Alire.Config.DB.all, + (Alire.Settings.DB.all, Filter => ".*", Show_Origin => Cmd.Show_Origin).Flatten (ASCII.LF)); when 1 => Trace.Always (CLIC.Config.Info.List - (Alire.Config.DB.all, + (Alire.Settings.DB.all, Filter => Args.First_Element, Show_Origin => Cmd.Show_Origin).Flatten (ASCII.LF)); when others => @@ -83,8 +83,9 @@ package body Alr.Commands.Settings is Args.First_Element & "'"); end if; - if Alire.Config.DB.Defined (Args.First_Element) then - Trace.Always (Alire.Config.DB.Get_As_String (Args.First_Element)); + if Alire.Settings.DB.Defined (Args.First_Element) then + Trace.Always + (Alire.Settings.DB.Get_As_String (Args.First_Element)); else Reportaise_Command_Failed ("Setting key '" & Args.First_Element & @@ -108,15 +109,15 @@ package body Alr.Commands.Settings is -- Check explicitly for booleans to store the proper TOML type -- regardless of the capitalization used by the user. if Is_Boolean (Val) then - Alire.Config.Edit.Set_Boolean + Alire.Settings.Edit.Set_Boolean (Lvl, Key, Boolean'Value (Val), - Check => Alire.Config.Edit.Valid_Builtin'Access); + Check => Alire.Settings.Edit.Valid_Builtin'Access); else - Alire.Config.Edit.Set + Alire.Settings.Edit.Set (Lvl, Key, Val, - Check => Alire.Config.Edit.Valid_Builtin'Access); + Check => Alire.Settings.Edit.Valid_Builtin'Access); end if; end; @@ -134,7 +135,7 @@ package body Alr.Commands.Settings is end if; if not CLIC.Config.Edit.Unset - (Alire.Config.Edit.Filepath (Lvl), Key) + (Alire.Settings.Edit.Filepath (Lvl), Key) then Reportaise_Command_Failed ("Cannot unset setting key"); end if; @@ -173,7 +174,7 @@ package body Alr.Commands.Settings is .New_Line .Append ("Built-in settings:") .New_Line - .Append (Alire.Config.Edit.Builtins_Info)); + .Append (Alire.Settings.Edit.Builtins_Info)); -------------------- -- Setup_Switches -- diff --git a/src/alr/alr-commands-toolchain.adb b/src/alr/alr-commands-toolchain.adb index ed1994a8..b5f78188 100644 --- a/src/alr/alr-commands-toolchain.adb +++ b/src/alr/alr-commands-toolchain.adb @@ -1,7 +1,7 @@ with AAA.Table_IO; -with Alire.Config.Edit; +with Alire.Settings.Edit; with Alire.Containers; with Alire.Dependencies; with Alire.Errors; @@ -237,8 +237,8 @@ package body Alr.Commands.Toolchain is Alire.Toolchains.Set_As_Default (Rel, Level => (if Cmd.Local - then Alire.Config.Local - else Alire.Config.Global)); + then Alire.Settings.Local + else Alire.Settings.Global)); Alire.Put_Info (Rel.Milestone.TTY_Image & " set as default in " & TTY.Emph (if Cmd.Local then "local" else "global") @@ -276,7 +276,7 @@ package body Alr.Commands.Toolchain is if Alire.Toolchains.Available.Is_Empty then Trace.Info ("Nothing installed in configuration prefix " - & TTY.URL (Alire.Config.Edit.Path)); + & TTY.URL (Alire.Settings.Edit.Path)); return; end if; @@ -344,10 +344,11 @@ package body Alr.Commands.Toolchain is -- Dispatch to subcommands if Cmd.Disable then - Alire.Toolchains.Set_Automatic_Assistant (False, - (if Cmd.Local - then Alire.Config.Local - else Alire.Config.Global)); + Alire.Toolchains.Set_Automatic_Assistant + (False, + (if Cmd.Local + then Alire.Settings.Local + else Alire.Settings.Global)); Alire.Put_Info ("Assistant disabled in " & TTY.Emph (if Cmd.Local then "local" else "global") @@ -367,8 +368,8 @@ package body Alr.Commands.Toolchain is if Args.Count = 0 then Alire.Toolchains.Assistant ((if Cmd.Local - then Alire.Config.Local - else Alire.Config.Global), + then Alire.Settings.Local + else Alire.Settings.Global), Allow_Incompatible => Alire.Force); else @@ -384,8 +385,8 @@ package body Alr.Commands.Toolchain is Alire.Toolchains.Set_Automatic_Assistant (False, (if Cmd.Local - then Alire.Config.Local - else Alire.Config.Global)); + then Alire.Settings.Local + else Alire.Settings.Global)); Trace.Detail ("Assistant disabled in " & TTY.Emph (if Cmd.Local then "local" else "global") diff --git a/src/alr/alr-commands-version.adb b/src/alr/alr-commands-version.adb index 16629f42..a0d73117 100644 --- a/src/alr/alr-commands-version.adb +++ b/src/alr/alr-commands-version.adb @@ -1,5 +1,5 @@ with Alire.Builds; -with Alire.Config.Edit; +with Alire.Settings.Edit; with Alire.Directories; with Alire.Index; with Alire.Index_On_Disk.Loading; @@ -41,7 +41,7 @@ package body Alr.Commands.Version is Index_Outcome : Alire.Outcome; Indexes : constant Alire.Index_On_Disk.Loading.Set := Alire.Index_On_Disk.Loading.Find_All - (Alire.Config.Edit.Indexes_Directory, Index_Outcome); + (Alire.Settings.Edit.Indexes_Directory, Index_Outcome); Root : Alire.Roots.Optional.Root := Alire.Roots.Optional.Search_Root (Alire.Directories.Current); @@ -72,9 +72,9 @@ package body Alr.Commands.Version is Table.Append ("").New_Row; Table.Append ("CONFIGURATION").New_Row; - Table.Append ("config folder:").Append (Alire.Config.Edit.Path).New_Row; + Table.Append ("config folder:").Append (Settings.Edit.Path).New_Row; Table.Append ("cache folder:") - .Append (Alire.Config.Edit.Cache_Path).New_Row; + .Append (Alire.Settings.Edit.Cache_Path).New_Row; Table.Append ("vault folder:").Append (Paths.Vault.Path).New_Row; Table.Append ("build folder:").Append (Build_Path).New_Row; Table.Append ("temp folder:") @@ -87,7 +87,7 @@ package body Alr.Commands.Version is Table.Append ("compatible index versions:") .Append (Alire.Index.Valid_Versions.Image).New_Row; Table.Append ("indexes folder:") - .Append (Alire.Config.Edit.Indexes_Directory).New_Row; + .Append (Alire.Settings.Edit.Indexes_Directory).New_Row; Table.Append ("indexes metadata:") .Append (if Index_Outcome.Success then "OK" diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index 96a77f62..3aa8afa6 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -8,8 +8,8 @@ with CLIC.User_Input; with Alire.Platforms; with Alire_Early_Elaboration; -with Alire.Config.Builtins; -with Alire.Config.Edit; +with Alire.Settings.Builtins; +with Alire.Settings.Edit; with Alire.Errors; with Alire.Index_On_Disk.Loading; with Alire.Index_On_Disk.Updates; @@ -207,7 +207,7 @@ package body Alr.Commands is procedure Create_Alire_Folders is use GNATCOLL.VFS; begin - Make_Dir (Create (+Alire.Config.Edit.Path)); + Make_Dir (Create (+Alire.Settings.Edit.Path)); end Create_Alire_Folders; -------------------------- @@ -302,9 +302,9 @@ package body Alr.Commands is Unchecked : Alire.Roots.Optional.Root renames Cmd.Optional_Root; Manual_Only : constant Boolean := - Alire.Config.Builtins.Update_Manually_Only.Get; + Alire.Settings.Builtins.Update_Manually_Only.Get; - package Conf renames Alire.Config; + package Conf renames Alire.Settings; begin -- If the root has been already loaded, then all following checks have @@ -498,11 +498,11 @@ package body Alr.Commands is then -- Just verify that early processing catched it pragma Assert - (Alire.Config.Edit.Path = + (Alire.Settings.Edit.Path = Ada.Directories.Full_Name (Command_Line_Config_Path.all), "Unexpected mismatch of config paths:" & Alire.New_Line - & "Early: " & Alire.Config.Edit.Path + & "Early: " & Alire.Settings.Edit.Path & Alire.New_Line & "Late : " & Command_Line_Config_Path.all); end if; @@ -543,7 +543,7 @@ package body Alr.Commands is Set_Builtin_Aliases; - Sub_Cmd.Load_Aliases (Alire.Config.DB.all); + Sub_Cmd.Load_Aliases (Alire.Settings.DB.all); Sub_Cmd.Execute; Log ("alr " & Sub_Cmd.What_Command & " done", Detail); -- 2.39.5