Skip to content

Commit

Permalink
Merge remote-tracking branch 'alire/master' into feat/bug-box
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Feb 27, 2024
2 parents fb01b7a + d6c2572 commit 26bd57e
Show file tree
Hide file tree
Showing 35 changed files with 194 additions and 76 deletions.
32 changes: 24 additions & 8 deletions alire_common.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,30 @@ abstract project Alire_Common is
Style_Check_Switches := ();
case Style_Check_Mode is
when "enabled" => Style_Check_Switches :=
("-gnatwe", -- Warnings as errors
"-gnatyd", -- no DOS line terminators
"-gnatyI", -- no IN mode
"-gnatyO", -- all overrides
"-gnatyS", -- separate lines after THEN/ELSE
"-gnatyu", -- no unnecessary blank lines
"-gnatyx", -- no extra parens around conditionals
"-gnaty-s"); -- relax fwd decl
( "-gnatwe" -- Warnings as errors
,"-gnaty3" -- Specify indentation level of 3
,"-gnatya" -- Check attribute casing
,"-gnatyA" -- Use of array index numbers in array attributes
,"-gnatyB" -- Check Boolean operators
,"-gnatyb" -- Blanks not allowed at statement end
,"-gnatyc" -- Check comments
,"-gnatye" -- Check end/exit labels
,"-gnatyf" -- No form feeds or vertical tabs
,"-gnatyh" -- No horizontal tabs
,"-gnatyi" -- Check if-then layout
,"-gnatyI" -- check mode IN keywords
,"-gnatyk" -- Check keyword casing
,"-gnatyl" -- Check layout
,"-gnatym" -- Check maximum line length
,"-gnatyn" -- Check casing of entities in Standard
,"-gnatyO" -- Check all overriding subprograms explicitly marked
,"-gnatyp" -- Check pragma casing
,"-gnatyr" -- Check identifier references casing
,"-gnatyS" -- Check no statements after THEN/ELSE
,"-gnatyt" -- Check token spacing
,"-gnatyu" -- Check unnecessary blank lines
,"-gnatyx" -- Check extra parentheses
);
when "disabled" => Style_Check_Switches := ();
end case;

Expand Down
17 changes: 17 additions & 0 deletions doc/user-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ stay on top of `alr` new features.

## Release `2.0-dev`

### Cache and toolchain storage location overridding

PR [#1593](https://github.com/alire-project/alire/pull/1593)

The cache directory can now be set independently of the configuration
directory, by setting the `cache.dir` config builtin to an absolute path. For
example:
```
alr config --global --set cache.dir /path/to/my/global/cache
```
Since the cache by default also contains installed toolchains, which may not be
needed to be moved elsewhere, the `toolchain.dir` can be used to dissociate
toolchain location from cache location in a similar way:
```
alr config --global --set toolchain.dir /path/to/my/toolchains
```

### New switch `alr build --stop-after=<build stage>`

PR [#1573](https://github.com/alire-project/alire/pull/1573)
Expand Down
6 changes: 4 additions & 2 deletions src/alire/alire-conditional.adb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ package body Alire.Conditional is
return Result : Boolean := True do
for Child of T loop
case T.Conjunction is
when Anded => Result := Result and Eval_Children (Child);
when Ored => Result := Result or Eval_Children (Child);
when Anded =>
Result := Result and then Eval_Children (Child);
when Ored =>
Result := Result or else Eval_Children (Child);
end case;
end loop;
end return;
Expand Down
16 changes: 16 additions & 0 deletions src/alire/alire-config-builtins.ads
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ package Alire.Config.Builtins is
-- Builtins --
--------------

-- CACHE

Cache_Dir : constant Builtin := New_Builtin
(Key => "cache.dir",
Kind => Cfg_Absolute_Path,
Def => "",
Help =>
"Directory where Alire will store its cache.");

-- DEPENDENCIES

Dependencies_Git_Keep_Repository : constant Builtin := New_Builtin
Expand Down Expand Up @@ -107,6 +116,13 @@ package Alire.Config.Builtins is
"If true, and assistant to select the default toolchain will run "
& "when first needed.");

Toolchain_Dir : constant Builtin := New_Builtin
(Key => "toolchain.dir",
Kind => Cfg_Absolute_Path,
Def => "",
Help =>
"Directory where Alire will store its toolchains.");

Toolchain_External : constant Builtin := New_Builtin
(Key => "toolchain.external",
Def => True,
Expand Down
9 changes: 6 additions & 3 deletions src/alire/alire-config-edit.adb
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ package body Alire.Config.Edit is
----------------

function Cache_Path return Absolute_Path
is (if Path = Default_Config_Path
then Platforms.Folders.Cache
else Path / Paths.Cache_Folder_Inside_Working_Folder);
is (if Builtins.Cache_Dir.Get /= "" then
Builtins.Cache_Dir.Get
elsif Path /= Default_Config_Path then
Path / Paths.Cache_Folder_Inside_Working_Folder
else
Platforms.Folders.Cache);

--------------
-- Set_Path --
Expand Down
9 changes: 5 additions & 4 deletions src/alire/alire-config-edit.ads
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ package Alire.Config.Edit is
-- * Default per-platform path (see alire-platforms-*)

function Cache_Path return Absolute_Path;
-- The location for data that will be recreated if missing; defaults to
-- Platforms.Folders.Cache; if Path above is overridden, the cache will
-- be inside the config folder so as to keep that configuration completely
-- isolated.
-- The location for data that will be recreated if missing; its value in
-- precedence order is:
-- 1) Config builtin 'cache.dir'
-- 2) if Path above is overridden, Path/cache
-- 3) Platforms.Folders.Cache

procedure Set_Path (Path : Absolute_Path);
-- Override global config folder path
Expand Down
4 changes: 2 additions & 2 deletions src/alire/alire-config.ads
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ package Alire.Config is
Public : Boolean := True;
Check : CLIC.Config.Check_Import := null)
return Builtin_Option
with Pre => Help /= "" or not Public;
with Pre => Help /= "" or else not Public;

function New_Builtin (Key : CLIC.Config.Config_Key;
Def : Boolean;
Help : String := "";
Public : Boolean := True;
Check : CLIC.Config.Check_Import := null)
return Builtin_Option
with Pre => Help /= "" or not Public;
with Pre => Help /= "" or else not Public;

private

Expand Down
3 changes: 2 additions & 1 deletion src/alire/alire-directories.adb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ package body Alire.Directories is
-- like "/c/alire". This is for peace of mind.

if Path'Length < 8 then
Recoverable_User_Error ("Suspicious deletion request for path: " & Path);
Recoverable_User_Error
("Suspicious deletion request for path: " & Path);
end if;

if Exists (Path) then
Expand Down
21 changes: 12 additions & 9 deletions src/alire/alire-errors.adb
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ package body Alire.Errors is
if Line /= "" then
Trace.Error
((if I > Lines.First_Index then " " else "")
-- Indentation
-- Indentation

& (if I < Lines.Last_Index and Line (Line'Last) = '.'
& (if I < Lines.Last_Index and then Line (Line'Last) = '.'
then Line (Line'First .. Line'Last - 1)
else Line)
-- The error proper, trimming unwanted final '.'
Expand Down Expand Up @@ -261,10 +261,10 @@ package body Alire.Errors is

Caller : constant Positive :=
5 + Stack_Offset - (if Stack_Trace /= "" then 2 else 0);
-- The minus 2 is because in stacks obtained from the original exception:
-- 1) Except name 2) exec name 3) stack start
-- If instead we use AAA.Debug.Stack_Trace:
-- 1) Except name 2) exec name 3) AAA.Debug 4) here 5) caller
-- The minus 2 is because in stacks obtained from an exception:
-- 1) Except name 2) exec name 3) stack start
-- If instead we use AAA.Debug.Stack_Trace:
-- 1) Except name 2) exec name 3) AAA.Debug 4) here 5) caller

URL : constant String
:= "https://github.com/alire-project/alire/issues/new?title=[Bug%20box]";
Expand All @@ -282,11 +282,14 @@ package body Alire.Errors is
end Put;

begin
Trace.Debug (AAA.Debug.Stack_Trace);
if Stack_Trace = "" then
Trace.Debug (AAA.Debug.Stack_Trace);
end if;
-- Otherwise, the exception has been logged elsewhere

Put ("******************* BEGIN Alire bug detected *******************");
Put ("Location : "
& (if integer (Stack.Length) >= Caller
& (if Integer (Stack.Length) >= Caller
then Stack (Caller)
else "<unknown>"));

Expand All @@ -297,7 +300,7 @@ package body Alire.Errors is
Put ("Report at : " & URL);

if Log_Level < Debug or else not Log_Debug then
Put ("Re-run with `-vv -d` for a full stack trace.");
Put ("Re-run with `-vv -d` for a full log and stack trace.");
end if;

if Recoverable then
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-index_on_disk-git.ads
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package Alire.Index_On_Disk.Git is
function New_Handler (Origin : URL;
Name : Restricted_Name;
Parent : Any_Path) return Index with
Pre => AAA.Strings.Has_Prefix (Origin, "git+") or
Pre => AAA.Strings.Has_Prefix (Origin, "git+") or else
AAA.Strings.Has_Prefix (Origin, "git@");

overriding
Expand Down
5 changes: 2 additions & 3 deletions src/alire/alire-index_on_disk.adb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ package body Alire.Index_On_Disk is
return Outcome_Success;
exception
when E : others =>
return Outcome_From_Exception
(E, "Could not delete index directory: " & This.Metadata_Directory);
return Outcome_From_Exception (E, "Could not delete index directory");
end Delete;

----------
Expand Down Expand Up @@ -219,7 +218,7 @@ package body Alire.Index_On_Disk is
(Origin (Origin'First + File_Prefix'Length .. Origin'Last));
elsif Origin (Origin'First) = '/'
or else not (AAA.Strings.Contains (Origin, "@")
or AAA.Strings.Contains (Origin, "+"))
or else AAA.Strings.Contains (Origin, "+"))
then
return Process_Local_Index (Origin);
end if;
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-index_on_disk.ads
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ package Alire.Index_On_Disk is
Result : out Outcome;
Priority : Priorities := Default_Priority)
return Index'Class
with Post => Name in Restricted_Name or not Result.Success;
with Post => Name in Restricted_Name or else not Result.Success;
pragma Warnings (On);
-- Factory function.
-- Name is a user given name used to denote the index (like a git origin).
Expand Down
11 changes: 6 additions & 5 deletions src/alire/alire-publish.adb
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ package body Alire.Publish is
-- Safeguard to avoid tests creating a live pull request, unless
-- explicitly desired
if OS_Lib.Getenv (Environment.Testsuite, "unset") /= "unset"
and then OS_Lib.Getenv (Environment.Testsuite_Allow, "unset") = "unset"
and then
OS_Lib.Getenv (Environment.Testsuite_Allow, "unset") = "unset"
then
raise Constraint_Error
with "Attempting to go online to create a PR during tests";
Expand Down Expand Up @@ -631,9 +632,9 @@ package body Alire.Publish is
Git : constant VCSs.Git.VCS := VCSs.Git.Handler;
Is_Repo : constant Boolean := Git.Is_Repository (Base_Path (Context));
Archive : constant Relative_Path := Target_Dir / (Milestone & ".tgz");
-- We used to use tbz2 for locally tar'ed files, but that has an implicit
-- dependency on bzip2 that we are not managing yet, so for now we err on
-- the safe side of built-in tar gzip capabilities.
-- We used to use tbz2 for locally tar'ed files, but that has an
-- implicit dependency on bzip2 that we are not managing yet, so for
-- now we err on the safe side of built-in tar gzip capabilities.

-----------------
-- Git_Archive --
Expand Down Expand Up @@ -1111,7 +1112,7 @@ package body Alire.Publish is
-- already. No matter what, it will be checked again on the
-- deployed sources step.

if Revision = "" or Revision = "HEAD" then
if Revision = "" or else Revision = "HEAD" then
declare
Tmp_Context : Data := (Options => Options, others => <>);
begin
Expand Down
6 changes: 3 additions & 3 deletions src/alire/alire-roots.adb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ package body Alire.Roots is

function Stop_Build (Wanted, Actual : Builds.Stop_Points) return Boolean
is
use type Builds.Stop_Points;
use type Builds.Stop_Points;
begin
if Wanted <= Actual then
Trace.Debug ("Stopping build as requested at stage: " & Wanted'Image);
Expand Down Expand Up @@ -270,7 +270,7 @@ package body Alire.Roots is
begin
This.Build_Prepare (Saved_Profiles => Saved_Profiles,
Force_Regen => False,
Stop_After => stop_after);
Stop_After => Stop_After);

if Stop_Build (Stop_After, Actual => Generation) then
return True;
Expand Down Expand Up @@ -447,7 +447,7 @@ package body Alire.Roots is
Prefix => Prefix,
Recursive => False,
Quiet => True,
Force => (Force or
Force => (Force or else
Action in Reinstall | Replace));

-- Say something if after installing a crate it
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-solutions-diffs.adb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ package body Alire.Solutions.Diffs is
if Has_Latter and then Latter.Is_Provided
and then
(not Has_Former or else
(Former.Has_Release and Then
(Former.Has_Release and then
Former.Release.Name_Str /= Latter.Release.Name_Str))
then
Add_Change (Chg, "", TTY.Italic (Latter.Release.Name.As_String));
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-solutions.ads
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ package Alire.Solutions is
-- exact versions. NOTE that the original dependency is thus lost in this
-- info.

function Pins (This : Solution) return dependency_Map;
function Pins (This : Solution) return Dependency_Map;
-- return all version-pinned dependencies as plain dependencies for a exact
-- version. NOTE that the original dependency is thus lost.

Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-solver.adb
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ package body Alire.Solver is
and then
not Unavailable_Direct_Deps.Contains
(Solution.Dependency (Crate))
-- Because no release fulfills it, so "complete"
-- Because no release fulfills it, so "complete"
then
return False;
end if;
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-toml_adapters.ads
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ package Alire.TOML_Adapters with Preelaborate is
function "+" (Vect : AAA.Strings.Vector) return TOML.TOML_Value;

function To_Array (V : TOML.TOML_Value) return TOML.TOML_Value with
Pre => V.Kind in TOML.Atom_Value_Kind or V.Kind = TOML.TOML_Array,
Pre => V.Kind in TOML.Atom_Value_Kind or else V.Kind = TOML.TOML_Array,
Post => To_Array'Result.Kind = TOML.TOML_Array;
-- Take an atom value and return an array of a single element
-- If already an array, do nothing
Expand Down
4 changes: 3 additions & 1 deletion src/alire/alire-toolchains.adb
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@ package body Alire.Toolchains is
----------

function Path return Absolute_Path
is (Config.Edit.Cache_Path / "toolchains");
is (if Config.Builtins.Toolchain_Dir.Get /= ""
then Config.Builtins.Toolchain_Dir.Get
else Config.Edit.Cache_Path / "toolchains");

------------
-- Deploy --
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-toolchains.ads
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ package Alire.Toolchains is

function Path return Absolute_Path;
-- Returns the base folder in which all toolchain releases live, defaults
-- to <cache>/toolchains
-- to <cache>/toolchains, overridable via config builtin `toolchain.dir`

procedure Deploy (Release : Releases.Release;
Location : Any_Path := Path);
Expand Down
4 changes: 2 additions & 2 deletions src/alire/alire-utils-regex.adb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package body Alire.Utils.Regex is

function Escape (Literal : String) return String is
Targets : constant String := "\()[].*+?^";
Result : Ustring;
use Ustrings;
Result : UString;
use UStrings;
begin
for Char of Literal loop
if (for some Nono of Targets => Char = Nono) then
Expand Down
3 changes: 2 additions & 1 deletion src/alire/alire-utils-tools.adb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ package body Alire.Utils.Tools is
when Easy_Graph =>
(if Distribution in Centos | Fedora | Rhel | Suse
then "perl-Graph-Easy"
elsif Distribution /= Msys2 and Distribution /= Arch
elsif Distribution /= Msys2 and then
Distribution /= Arch
then "libgraph-easy-perl"
else ""),
when Git | Tar | Unzip | Curl =>
Expand Down
Loading

0 comments on commit 26bd57e

Please sign in to comment.