Skip to content

Commit

Permalink
Remove old release-sharing mechanism remnants (#1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo authored Sep 13, 2023
1 parent afd9397 commit 698a712
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 150 deletions.
6 changes: 0 additions & 6 deletions src/alire/alire-dependencies-states.adb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ package body Alire.Dependencies.States is
Pinned : constant String := "pinned";
Reason : constant String := "reason";
Release : constant String := "release";
Shared : constant String := "shared";
Transitivity : constant String := "transitivity";
Versions : constant String := "versions";

Expand Down Expand Up @@ -124,8 +123,6 @@ package body Alire.Dependencies.States is
"release: " & (+Crate)),
Manifest.Index,
Strict => False)); -- because it may come from elsewhere
Data.Shared :=
From.Checked_Pop (Keys.Shared, TOML_Boolean).As_Boolean;
end case;

return Data;
Expand Down Expand Up @@ -194,9 +191,6 @@ package body Alire.Dependencies.States is
(Keys.Release,
This.Fulfilled.Release.Constant_Reference.To_TOML
(Manifest.Index));
Table.Set
(Keys.Shared,
Create_Boolean (This.Fulfilled.Shared));
end case;
end To_TOML;

Expand Down
21 changes: 3 additions & 18 deletions src/alire/alire-dependencies-states.ads
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ package Alire.Dependencies.States is
-- Modify transitivity in a copy of Base

function Solving (Base : State;
Using : Releases.Release;
Shared : Boolean := False)
Using : Releases.Release)
return State
with Pre => Using.Provides (Base.Crate);
-- Uses release to fulfill this dependency in a copy of Base
Expand Down Expand Up @@ -108,8 +107,6 @@ package Alire.Dependencies.States is
function Is_Provided (This : State) return Boolean;
-- True when the release name is different from the dependency crate

function Is_Shared (This : State) return Boolean;

function Is_User_Pinned (This : State) return Boolean;
-- From the POV of users, pinning to version or linking to dir is a pin

Expand Down Expand Up @@ -227,7 +224,6 @@ private
Opt_Rel : Stored_Release; -- This might not be filled-in
when Solved =>
Release : Stored_Release; -- This is always valid
Shared : Boolean; -- The release is from shared install
when Missed =>
Reason : Missed_Reasons := Skipped; -- Until solving is attempted
when others => null;
Expand Down Expand Up @@ -319,9 +315,6 @@ private
& (if This.Has_Release
then ",release"
else "")
& (if This.Is_Shared
then ",installed"
else "")
else "")
& (if This.Pinning.Pinned
then ",pin=" & This.Pinning.Version.Image
Expand Down Expand Up @@ -353,9 +346,6 @@ private
function Is_Provided (This : State) return Boolean
is (This.Has_Release and then This.Release.Name /= This.Crate);

function Is_Shared (This : State) return Boolean
is (This.Fulfilled.Fulfillment = Solved and then This.Fulfilled.Shared);

function Is_Solved (This : State) return Boolean
is (This.Fulfilled.Fulfillment = Solved);

Expand Down Expand Up @@ -538,14 +528,12 @@ private
-------------

function Solving (Base : State;
Using : Releases.Release;
Shared : Boolean := False)
Using : Releases.Release)
return State
is (Base.As_Dependency with
Name_Len => Base.Name_Len,
Fulfilled => (Fulfillment => Solved,
Release => To_Holder (Using),
Shared => Shared),
Release => To_Holder (Using)),
Pinning => Base.Pinning,
Transitivity => Base.Transitivity);

Expand Down Expand Up @@ -582,9 +570,6 @@ private
& (if This.Has_Release
then "," & TTY.OK ("release")
else "")
& (if This.Is_Shared
then "," & TTY.Emph ("installed")
else "")
else "")
& (if This.Pinning.Pinned
then "," & TTY.Emph ("pin")
Expand Down
24 changes: 0 additions & 24 deletions src/alire/alire-solutions-diffs.adb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package body Alire.Solutions.Diffs is
Unpinned, -- A release being unpinned
Unchanged, -- An unchanged dependency/release
Missing, -- A missing dependency
Shared, -- A release used from the shared installed releases
Binary -- A binary, system or external release
);

Expand All @@ -42,7 +41,6 @@ package body Alire.Solutions.Diffs is
when Unpinned => TTY.Emph (U ("🎈")), -- alts: 𐩒🎈
when Unchanged => TTY.OK (U ("=")),
when Missing => TTY.Error (U ("")), -- alts: ⚠️❗‼️
when Shared => TTY.Emph (U ("♻️ ")), -- alts: ♻♻️♼🫴
when Binary => TTY.Warn (U ("📦")))
else
(case Change is
Expand All @@ -55,7 +53,6 @@ package body Alire.Solutions.Diffs is
when Unpinned => U ("o"),
when Unchanged => U ("="),
when Missing => U ("!"),
when Shared => U ("i"),
when Binary => U ("b")
));

Expand Down Expand Up @@ -179,25 +176,6 @@ package body Alire.Solutions.Diffs is
end if;
end Fulfil_Change;

--------------------
-- Sharing_Change --
--------------------

procedure Sharing_Change is
begin
if (not Has_Former or else not Former.Is_Shared)
and then Has_Latter and then Latter.Is_Shared
then
Add_Change (Chg, Icon (Shared), TTY.Emph ("installed"));

elsif Has_Former and then Former.Is_Shared
and then Has_Latter and then not Latter.Is_Shared
then
Add_Change (Chg, "", TTY.Emph ("local"));

end if;
end Sharing_Change;

--------------------------
-- transitivity_changed --
--------------------------
Expand Down Expand Up @@ -369,8 +347,6 @@ package body Alire.Solutions.Diffs is

Fulfil_Change;

Sharing_Change;

Provider_Change;

Transitivity_Changed;
Expand Down
14 changes: 5 additions & 9 deletions src/alire/alire-solutions.adb
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ package body Alire.Solutions is
Release : Alire.Releases.Release;
Env : Properties.Vector;
For_Dependency : Optional.Crate_Name := Optional.Crate_Names.Empty;
Add_Dependency : Boolean := False;
Shared : Boolean := False)
Add_Dependency : Boolean := False)
return Solution
is
Dep_Name : constant Crate_Name := (if Add_Dependency
Expand Down Expand Up @@ -459,8 +458,7 @@ package body Alire.Solutions is
Result.Dependencies :=
Result.Dependencies.Including
(Result.State (Dep_Name).Solving
(Release.Whenever (Env),
Shared => Shared));
(Release.Whenever (Env)));
-- TODO: remove this Whenever once dynamic expr can be exported
elsif Result.State (Dep_Name).Is_Hinted then
Result := Result.Hinting (Result.State (Dep_Name).As_Dependency);
Expand All @@ -484,7 +482,7 @@ package body Alire.Solutions is
Result.Dependencies :=
Result.Dependencies.Including
(This.State (Dep.Crate)
.Solving (Release.Whenever (Env), Shared => Shared));
.Solving (Release.Whenever (Env)));
end if;
end loop;

Expand Down Expand Up @@ -743,8 +741,6 @@ package body Alire.Solutions is
else "")
& (if Dep.Is_Pinned or else Dep.Is_Linked
then TTY.Emph (" (pinned)")
elsif Dep.Is_Shared
then TTY.Emph (" (installed)")
else "")
& (if Detailed
then " (origin: "
Expand Down Expand Up @@ -1466,10 +1462,10 @@ package body Alire.Solutions is
begin

-- Visit first dependencies that do not have releases (and hence no
-- dependencies) or that are preinstalled.
-- dependencies).

for Dep of This.Dependencies loop
if not Dep.Has_Release or else Dep.Is_Shared then
if not Dep.Has_Release then
Visit (Dep);
end if;
end loop;
Expand Down
3 changes: 1 addition & 2 deletions src/alire/alire-solutions.ads
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ package Alire.Solutions is
Release : Alire.Releases.Release;
Env : Properties.Vector;
For_Dependency : Optional.Crate_Name := Optional.Crate_Names.Empty;
Add_Dependency : Boolean := False;
Shared : Boolean := False)
Add_Dependency : Boolean := False)
return Solution
with Pre =>
Add_Dependency xor
Expand Down
57 changes: 10 additions & 47 deletions src/alire/alire-solver.adb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ package body Alire.Solver is
-- to select the solver behavior (e.g. stop after the first complete
-- solution is found).

Installed : constant Releases.Containers.Release_Set :=
Tools : constant Releases.Containers.Release_Set :=
Toolchains.Available
(Detect_Externals =>
Options.Detecting = Detect);
Expand Down Expand Up @@ -396,8 +396,7 @@ package body Alire.Solver is
------------------

procedure Expand_Value (Dep : Dependencies.Dependency;
Raw_Dep : Dependencies.Dependency;
Allow_Shared : Boolean) is
Raw_Dep : Dependencies.Dependency) is
-- Dep is the unique dependency in the solution that aglutinates
-- all dependencies on the same crate that have been seen to date.
-- Raw_Dep, instead, is the simple dependency that is being tested
Expand Down Expand Up @@ -509,11 +508,11 @@ package body Alire.Solver is

Trace.Debug
("SOLVER: gnat PASS " & Boolean'
(Installed.Contains (R))'Image
(Tools.Contains (R))'Image
& " for " & R.Milestone.TTY_Image
& " due to installed compiler availability.");

return Installed.Contains (R);
return Tools.Contains (R);

else

Expand All @@ -530,10 +529,8 @@ package body Alire.Solver is
-----------

procedure Check (R : Release;
Is_Shared : Boolean;
Is_Reused : Boolean)
is
use all type Origins.Kinds;
begin

-- Special compiler checks are hardcoded when the dependency is
Expand Down Expand Up @@ -614,7 +611,6 @@ package body Alire.Solver is
("SOLVER: dependency FROZEN: " & R.Milestone.Image &
" to satisfy " & Dep.TTY_Image &
(if Is_Reused then " with REUSED" else "") &
(if Is_Shared then " with INSTALLED" else "") &
(if not R.Provides.Is_Empty
then " also providing " & R.Provides.Image_One_Line
else "") &
Expand All @@ -632,10 +628,7 @@ package body Alire.Solver is
Solution => Solution.Including
(R, Props,
For_Dependency =>
Optional.Crate_Names.Unit (Dep.Crate),
Shared =>
Is_Shared or else
R.Origin.Kind = Binary_Archive)));
Optional.Crate_Names.Unit (Dep.Crate))));
end;
end if;
end Check;
Expand Down Expand Up @@ -741,7 +734,7 @@ package body Alire.Solver is

Trace.Debug ("SOLVER short-cutting due to version pin"
& " with valid release in index");
Check (Release, Is_Shared => False, Is_Reused => False);
Check (Release, Is_Reused => False);
end loop;

-- There may be no satisfying releases, or even so the
Expand Down Expand Up @@ -788,22 +781,6 @@ package body Alire.Solver is
-- will have to), we should do this globally since this is
-- information common to all search states.

------------------
-- Check_Shared --
------------------

procedure Check_Shared is
begin

-- Solve with all installed dependencies that satisfy it

for R of reverse Installed.Satisfying (Dep) loop
Satisfiable := True;
Check (R, Is_Shared => True, Is_Reused => False);
end loop;

end Check_Shared;

use type Alire.Dependencies.Dependency;

---------------------
Expand Down Expand Up @@ -893,8 +870,6 @@ package body Alire.Solver is
for In_Sol of Solution.Dependencies_Providing (Dep.Crate) loop
if In_Sol.Has_Release then
Check (In_Sol.Release,
Is_Shared =>
In_Sol.Is_Shared,
Is_Reused => True);
end if;
end loop;
Expand All @@ -903,17 +878,6 @@ package body Alire.Solver is

end if;

if Allow_Shared then

-- There is a shared release we can use for this dependency; we
-- prefer this option first. If more solutions than the first
-- complete one are sought, we can still try without the shared
-- release.

Check_Shared;

end if;

if Pins.Depends_On (Dep.Crate) and then
Pins.State (Dep.Crate).Is_Pinned
then
Expand Down Expand Up @@ -959,9 +923,9 @@ package body Alire.Solver is
(R.Satisfies (Dep)
and then
(Dep.Crate /= GNAT_Crate or else
Installed.Contains (R)));
Tools.Contains (R)));

Check (R, Is_Shared => False, Is_Reused => False);
Check (R, Is_Reused => False);
end Consider;
begin
Trace.Debug ("SOLVER: considering"
Expand Down Expand Up @@ -1191,10 +1155,10 @@ package body Alire.Solver is
-- Add or merge dependency
.Dependency (State.Target.Value.Crate),
-- And use it in expansion
Raw_Dep => State.Target.Value,
Raw_Dep => State.Target.Value
-- We also pass the plain dependency for the
-- Seen collection inside the search state.
Allow_Shared => Options.Sharing = Allow_Shared);
);

elsif State.Target.Is_Vector then
if State.Target.Conjunction = Anded then
Expand Down Expand Up @@ -1362,7 +1326,6 @@ package body Alire.Solver is
Exhaustive => Options.Exhaustive,
Detecting => Options.Detecting,
Hinting => Options.Hinting,
Sharing => Options.Sharing,
Timeout => Options.Timeout,
Timeout_More => Options.Timeout_More,
Elapsed => Timer.Elapsed,
Expand Down
5 changes: 0 additions & 5 deletions src/alire/alire-solver.ads
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ package Alire.Solver is
-- releases will be used normally; otherwise a crate with only externals
-- will always cause failure.

type Sharing_Policies is (Allow_Shared, Only_Local);
-- * Allow_Shared: crates in the shared config can appear in solutions.
-- * Only_Local: only crates in the local workspace will be used.

type Timeout_Policies is
(Ask, -- Normal interaction with user
Stop, -- Abort at first timeout
Expand Down Expand Up @@ -134,7 +130,6 @@ package Alire.Solver is
-- only the given Completeness is used.
Detecting : Detection_Policies := Detect;
Hinting : Hinting_Policies := Hint;
Sharing : Sharing_Policies := Allow_Shared;
On_Timeout : Timeout_Policies := Ask;

Timeout : Duration := 5.0;
Expand Down
Loading

0 comments on commit 698a712

Please sign in to comment.