diff --git a/src/alire/alire-config-edit.ads b/src/alire/alire-config-edit.ads index 15991400b..5157573f1 100644 --- a/src/alire/alire-config-edit.ads +++ b/src/alire/alire-config-edit.ads @@ -79,31 +79,6 @@ package Alire.Config.Edit is return Boolean; -- Check that the combination satisfies builtin rules - Builtins : constant array (Natural range <>) of Builtin_Entry := - ( - (+Keys.Msys2_Do_Not_Install, - Cfg_Bool, - +("If true, Alire will not try to automatically" & - " install msys2 system package manager. (Windows only)")), - - (+Keys.Msys2_Install_Dir, - Cfg_Absolute_Path, - +("Directory where Alire will detect and/or install" & - " msys2 system package manager. (Windows only)")), - - (+Keys.Msys2_Installer, - Cfg_String, - +("Filename of the executable msys2 installer, " & - "e.g. 'msys2-x86_64-20220319.exe'. (Windows only)")), - - (+Keys.Msys2_Installer_URL, - Cfg_String, - +("URL of the executable msys2 installer, " & - "e.g. 'https://github.com/msys2/msys2-installer/releases/" & - "download/2022-03-19/msys2-x86_64-20220319.exe'. (Windows only)")) - - ); - private procedure Load_Config; diff --git a/src/alire/alire-config.ads b/src/alire/alire-config.ads index 59a788d03..8e7536942 100644 --- a/src/alire/alire-config.ads +++ b/src/alire/alire-config.ads @@ -83,15 +83,6 @@ package Alire.Config is return Builtin_Option with Pre => Help /= "" or not Public; - package Keys is - use CLIC.Config; - - Msys2_Do_Not_Install : constant Config_Key := "msys2.do_not_install"; - Msys2_Install_Dir : constant Config_Key := "msys2.install_dir"; - Msys2_Installer : constant Config_Key := "msys2.installer"; - Msys2_Installer_URL : constant Config_Key := "msys2.installer_url"; - end Keys; - private type Builtin_Option is tagged record diff --git a/src/alire/os_windows/alire-config-builtins-windows.ads b/src/alire/os_windows/alire-config-builtins-windows.ads new file mode 100644 index 000000000..c787506f2 --- /dev/null +++ b/src/alire/os_windows/alire-config-builtins-windows.ads @@ -0,0 +1,41 @@ +with Alire.Platforms.Folders; + +package Alire.Config.Builtins.Windows is + + Default_Msys2_Installer : constant String := "msys2-x86_64-20221216.exe"; + Default_Msys2_Installer_URL : constant String := + "https://github.com/msys2/msys2-installer/releases/download/2022-12-16/" + & Default_Msys2_Installer; + + -- MSYS2 + + Msys2_Do_Not_Install : constant Builtin := New_Builtin + (Key => "msys2.do_not_install", + Def => False, + Help => + "If true, Alire will not try to automatically" & + " install msys2 system package manager. (Windows only)"); + + Msys2_Install_Dir : constant Builtin := New_Builtin + (Key => "msys2.install_dir", + Kind => Cfg_Absolute_Path, + Def => Platforms.Folders.Cache / "msys64", + Help => + "Directory where Alire will detect and/or install" & + " msys2 system package manager. (Windows only)"); + + Msys2_Installer : constant Builtin := New_Builtin + (Key => "msys2.installer", + Kind => Cfg_String, + Def => Default_Msys2_Installer, + Help => + "Filename of the executable msys2 installer. (Windows only)"); + + Msys2_Installer_URL : constant Builtin := New_Builtin + (Key => "msys2.installer_url", + Kind => Cfg_String, + Def => Default_Msys2_Installer_URL, + Help => + "URL of the executable msys2 installer. (Windows only)"); + +end Alire.Config.Builtins.Windows; diff --git a/src/alire/os_windows/alire-platforms-current__windows.adb b/src/alire/os_windows/alire-platforms-current__windows.adb index d56796f4c..0151159b4 100644 --- a/src/alire/os_windows/alire-platforms-current__windows.adb +++ b/src/alire/os_windows/alire-platforms-current__windows.adb @@ -5,9 +5,7 @@ with AAA.Strings; with Alire.Environment; with Alire.OS_Lib; use Alire.OS_Lib; -with Alire.Config; -with Alire.Config.Edit; -with Alire.Platforms.Folders; +with Alire.Config.Builtins.Windows; with Alire.Errors; with GNATCOLL.VFS; @@ -16,13 +14,6 @@ with CLIC.User_Input; package body Alire.Platforms.Current is - package Cfg renames Config; - - Default_Msys2_Installer : constant String := "msys2-x86_64-20221216.exe"; - Default_Msys2_Installer_URL : constant String := - "https://github.com/msys2/msys2-installer/releases/download/2022-12-16/" - & Default_Msys2_Installer; - -- Windows implementation Distrib_Detected : Boolean := False; @@ -172,7 +163,7 @@ package body Alire.Platforms.Current is use CLIC.User_Input; begin - if Cfg.DB.Get (Cfg.Keys.Msys2_Do_Not_Install, False) then + if Config.Builtins.Windows.Msys2_Do_Not_Install.Get then -- User already requested that msys2 should not be installed @@ -207,8 +198,7 @@ package body Alire.Platforms.Current is Default => No) = Yes then -- Save user choice in the global config - Cfg.Edit.Set_Globally (Key => Cfg.Keys.Msys2_Do_Not_Install, - Value => "true"); + Config.Builtins.Windows.Msys2_Do_Not_Install.Set_Globally ("true"); end if; -- We are not allowed to install @@ -263,10 +253,10 @@ package body Alire.Platforms.Current is end Download_File; Msys2_Installer : constant String := - Cfg.DB.Get (Cfg.Keys.Msys2_Installer, Default_Msys2_Installer); + Config.Builtins.Windows.Msys2_Installer.Get; Msys2_Installer_URL : constant String := - Cfg.DB.Get (Cfg.Keys.Msys2_Installer_URL, Default_Msys2_Installer_URL); + Config.Builtins.Windows.Msys2_Installer_URL.Get; Result : Alire.Outcome; begin @@ -298,22 +288,17 @@ package body Alire.Platforms.Current is return Alire.Outcome_Failure ("Cannot setup msys2 environment"); end; - if not Cfg.DB.Defined (Cfg.Keys.Msys2_Install_Dir) then + if Config.Builtins.Windows.Msys2_Install_Dir.Is_Empty then -- Save msys2 install dir in the global config - Cfg.Edit.Set_Globally (Key => Cfg.Keys.Msys2_Install_Dir, - Value => Install_Dir); + Config.Builtins.Windows.Msys2_Install_Dir.Set_Globally (Install_Dir); end if; -- Load msys2 environment to attempt first full update according to -- official setup instructions at: -- https://www.msys2.org/wiki/MSYS2-installation/ declare - Default_Install_Dir : constant Alire.Absolute_Path := - Platforms.Folders.Cache / "msys64"; - Cfg_Install_Dir : constant String := - Cfg.DB.Get (Cfg.Keys.Msys2_Install_Dir, - Default_Install_Dir); + Config.Builtins.Windows.Msys2_Install_Dir.Get; begin Set_Msys2_Env (Cfg_Install_Dir); end; @@ -384,12 +369,8 @@ package body Alire.Platforms.Current is procedure Setup_Msys2 is Result : Alire.Outcome; - Default_Install_Dir : constant Alire.Absolute_Path := - Platforms.Folders.Cache / "msys64"; - Cfg_Install_Dir : constant String := - Cfg.DB.Get (Cfg.Keys.Msys2_Install_Dir, - Default_Install_Dir); + Config.Builtins.Windows.Msys2_Install_Dir.Get; Pacman : constant String := Alire.OS_Lib.Subprocess.Locate_In_Path ("pacman");