Skip to content

Commit

Permalink
Completed migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Aug 23, 2023
1 parent aa585c0 commit 08fef71
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 62 deletions.
25 changes: 0 additions & 25 deletions src/alire/alire-config-edit.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions src/alire/alire-config.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions src/alire/os_windows/alire-config-builtins-windows.ads
Original file line number Diff line number Diff line change
@@ -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;
37 changes: 9 additions & 28 deletions src/alire/os_windows/alire-platforms-current__windows.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 08fef71

Please sign in to comment.