Skip to content

Commit

Permalink
Workaround via leaky pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Feb 20, 2025
1 parent 4033db5 commit fa3ba15
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 33 deletions.
33 changes: 9 additions & 24 deletions src/alire/alire-releases.adb
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ package body Alire.Releases is
then Sort_Compilers (L, R)
else Standard_Sorting (L, R));

------------
-- Adjust --
------------

overriding procedure Adjust (This : in out Release) is
begin
if This.Imported.Is_Present then
This.Imported := This.Imported.Clone;
end if;
end Adjust;

--------------------
-- All_Properties --
--------------------
Expand Down Expand Up @@ -485,8 +474,7 @@ package body Alire.Releases is

return Replacement : constant Release
(Base.Name.Length, New_Notes'Length) :=
(Parent with
Prj_Len => Base.Name.Length,
(Prj_Len => Base.Name.Length,
Notes_Len => New_Notes'Length,
Name => Base.Name,
Notes => New_Notes,
Expand Down Expand Up @@ -543,8 +531,7 @@ package body Alire.Releases is
Properties : Conditional.Properties;
Available : Conditional.Availability)
return Release
is (Parent with
Prj_Len => Name.Length,
is (Prj_Len => Name.Length,
Notes_Len => Notes'Length,
Name => Name,
Version => Version,
Expand All @@ -556,7 +543,7 @@ package body Alire.Releases is
Forbidden => Conditional.For_Dependencies.Empty,
Properties => Properties,
Available => Available,
Imported => TOML.No_TOML_Value);
Imported => No_TOML_Value);

-----------------------
-- New_Empty_Release --
Expand All @@ -578,8 +565,7 @@ package body Alire.Releases is
Properties : Conditional.Properties :=
Default_Properties)
return Release is
(Parent with
Prj_Len => Name.Length,
(Prj_Len => Name.Length,
Notes_Len => 0,
Name => Name,
Version => +"0.0.0",
Expand All @@ -591,7 +577,7 @@ package body Alire.Releases is
Forbidden => Conditional.For_Dependencies.Empty,
Properties => Properties,
Available => Conditional.Empty,
Imported => TOML.No_TOML_Value
Imported => No_TOML_Value
);

-------------------------
Expand Down Expand Up @@ -872,7 +858,7 @@ package body Alire.Releases is
-- missing for releases being created from scratch during `alr
-- init`, but there's no way for a user to get us here until
-- after the release has been reloaded from its manifest.
Formatting.Print (R.Imported);
Formatting.Print (R.Imported.all);
else
if R.Properties.Is_Unconditional then
Formatting.Print
Expand Down Expand Up @@ -1067,7 +1053,7 @@ package body Alire.Releases is
-- expressions unresolved. Keep a copy since TOML is using reference
-- semantics.

This.Imported := From.Unwrap.Clone;
This.Imported.all := From.Unwrap.Clone;

-- Extract the version ASAP to show it properly during logging

Expand Down Expand Up @@ -1312,8 +1298,7 @@ package body Alire.Releases is
function Whenever (R : Release;
P : Alire.Properties.Vector)
return Release
is (Parent with
Prj_Len => R.Prj_Len,
is (Prj_Len => R.Prj_Len,
Notes_Len => R.Notes_Len,
Name => R.Name,
Version => R.Version,
Expand All @@ -1326,7 +1311,7 @@ package body Alire.Releases is
Properties => R.Properties.Evaluate (P),
Available => R.Available.Evaluate (P),

Imported => TOML.No_TOML_Value
Imported => No_TOML_Value
-- We are discarding information above, so the imported information
-- would no longer match.
);
Expand Down
14 changes: 6 additions & 8 deletions src/alire/alire-releases.ads
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ with Semantic_Versioning;

with TOML;

private with Ada.Finalization;
private with Alire.OS_Lib;
private with Alire.Utils.TTY;
private with CLIC.TTY;
Expand Down Expand Up @@ -399,13 +398,14 @@ private
return Alire.Properties.Vector;
-- Properties that R has under platform properties P

subtype Parent is Ada.Finalization.Controlled;
-- We need to make Release Controlled to work around a bug in GNAT<14. See
-- field Imported for more.
type TOML_Value_Ptr is access TOML.TOML_Value;

function No_TOML_Value return TOML_Value_Ptr
is (new TOML.TOML_Value'(TOML.No_TOML_Value));

type Release (Prj_Len,
Notes_Len : Natural)
is new Parent and Interfaces.Yamlable
is new Interfaces.Yamlable
with record
Name : Crate_Name (Prj_Len);
Version : Semantic_Versioning.Version;
Expand All @@ -418,7 +418,7 @@ private
Properties : Conditional.Properties;
Available : Conditional.Availability;

Imported : TOML.TOML_Value;
Imported : TOML_Value_Ptr := No_TOML_Value;
-- For releases loaded from a manifest, this is the original structured
-- data that generated it, in which case Imported.Is_Present.
--
Expand All @@ -431,8 +431,6 @@ private
-- value on Adjust.
end record;

overriding procedure Adjust (This : in out Release);

function From_TOML (This : in out Release;
From : TOML_Adapters.Key_Queue;
Source : Manifest.Sources;
Expand Down
2 changes: 1 addition & 1 deletion testsuite/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

clear
python3 run.py --show-time-info -M1 "$@"
python3 run.py -j$(nproc) --show-time-info -M1 "$@"

0 comments on commit fa3ba15

Please sign in to comment.