Skip to content

Commit

Permalink
Make msys live inside overridden config path by default (alire-projec…
Browse files Browse the repository at this point in the history
…t#1589)

* Don't run OS initialization during elaboration

As this makes impossible to tweak such initialization with `alr config`.

* Make msys live inside overriden config path by default

* Better explanation in alr.py

* Fix config loading before Windows builtins
  • Loading branch information
mosteo authored Feb 28, 2024
1 parent ca875b7 commit 8996b85
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/alire/alire-config-edit-early_load.adb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ package body Alire.Config.Edit.Early_Load is
Alire.Config.Edit.Load_Config;
end Load_Config;

begin
Load_Config;
end Alire.Config.Edit.Early_Load;
2 changes: 1 addition & 1 deletion src/alire/alire-config-edit-early_load.ads
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Alire.Config.Edit.Early_Load is
package Alire.Config.Edit.Early_Load with Elaborate_Body is

procedure Load_Config;
-- For internal use of Alire_Early_Elaboration, DO NOT CALL otherwise.
Expand Down
4 changes: 4 additions & 0 deletions src/alire/alire-platforms-folders.ads
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ 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
-- account user overriding of the config location.

function Config return Absolute_Path;
-- Folder where alire will store its global configuration, indexes, and
-- any other global data. Deleting it is akin to running alr afresh for
Expand Down
6 changes: 4 additions & 2 deletions src/alire/os_windows/alire-config-builtins-windows.ads
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
with Alire.Platforms.Folders;
-- Ensure config is loaded for some defaults below
with Alire.Config.Edit.Early_Load;
pragma Unreferenced (Alire.Config.Edit.Early_Load);

package Alire.Config.Builtins.Windows is

Expand All @@ -19,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 => Platforms.Folders.Cache / "msys64",
Def => Config.Edit.Cache_Path / "msys64",
Help =>
"Directory where Alire will detect and/or install" &
" msys2 system package manager. (Windows only)");
Expand Down
11 changes: 11 additions & 0 deletions testsuite/drivers/alr.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ def prepare_env(config_dir, env):
# We pass config location explicitly in the following calls since env is
# not yet applied (it's just a dict to be passed later to subprocess)

if platform.system() == "Windows":
# Disable msys inadvertent installation
run_alr("-c", config_dir, "config", "--global",
"--set", "msys2.do_not_install", "true")

# And configure the one set up in the environment so it is used by
# tests that need it.
run_alr("-c", config_dir, "config", "--global",
"--set", "msys2.install_dir",
os.path.join(os.environ.get("LocalAppData"), "alire", "msys64"))

# Disable autoconfig of the community index, to prevent unintended use of
# it in tests, besides the overload of fetching it
run_alr("-c", config_dir, "config", "--global",
Expand Down

0 comments on commit 8996b85

Please sign in to comment.