Changes for Forbidden dependencies
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
with Alire.Containers;
|
||||
with Alire.Releases;
|
||||
|
||||
package Alire.Conditional.Operations is
|
||||
|
||||
function Contains (Tree : Dependencies; R : Releases.Release) return Boolean;
|
||||
|
||||
function Contains_Some (Tree : Dependencies;
|
||||
Map : Containers.Release_Map) return Boolean;
|
||||
-- If any in Map is also in Tree
|
||||
|
||||
private
|
||||
|
||||
use Conditional.For_Dependencies;
|
||||
|
||||
function Contains (Tree : Dependencies;
|
||||
R : Releases.Release) return Boolean is
|
||||
(for some I in Tree.Iterate =>
|
||||
Tree (I).Kind = Value and then
|
||||
R.Satisfies (Tree (I).Value));
|
||||
|
||||
function Contains_Some (Tree : Dependencies;
|
||||
Map : Containers.Release_Map) return Boolean is
|
||||
(for some R of Map => Contains (Tree, R));
|
||||
|
||||
end Alire.Conditional.Operations;
|
||||
@@ -11,11 +11,18 @@ package Alire.Conditional with Preelaborate is
|
||||
Dependencies.Image);
|
||||
subtype Dependencies is For_Dependencies.Tree;
|
||||
|
||||
subtype Platform_Dependencies is Conditional.Dependencies
|
||||
with Dynamic_Predicate => Platform_Dependencies.Is_Unconditional;
|
||||
-- A plain tree without conditions (but might have OR nodes)
|
||||
|
||||
subtype Forbidden_Dependencies is Platform_Dependencies
|
||||
with Dynamic_Predicate => not Forbidden_Dependencies.Contains_ORs;
|
||||
-- A plain tree without conditions or alternatives
|
||||
|
||||
function New_Dependency (Name : Alire.Project;
|
||||
Versions : Semantic_Versioning.Version_Set)
|
||||
return Dependencies;
|
||||
|
||||
|
||||
package For_Properties is new Conditional_Trees (Properties.Property'Class,
|
||||
Properties.Image_Classwide);
|
||||
subtype Properties is For_Properties.Tree;
|
||||
|
||||
@@ -20,6 +20,7 @@ package Alire.Conditional_Trees with Preelaborate is
|
||||
Iterator_Element => Tree,
|
||||
Constant_Indexing => Indexed_Element;
|
||||
-- Recursive type that stores conditions (requisites) and values/further conditions if they are met or not
|
||||
-- Iteration is only over direct children, when the tree is AND/OR list
|
||||
|
||||
function Leaf_Count (This : Tree) return Natural;
|
||||
|
||||
@@ -149,7 +150,7 @@ package Alire.Conditional_Trees with Preelaborate is
|
||||
|
||||
private
|
||||
|
||||
type Inner_Node is abstract tagged null record;
|
||||
type Inner_Node is interface;
|
||||
|
||||
function Image (Node : Inner_Node) return String is abstract;
|
||||
|
||||
|
||||
@@ -41,6 +41,19 @@ package body Alire.Releases is
|
||||
end return;
|
||||
end Extending;
|
||||
|
||||
----------------
|
||||
-- Forbidding --
|
||||
----------------
|
||||
|
||||
function Forbidding (Base : Release;
|
||||
Forbidden : Conditional.Forbidden_Dependencies)
|
||||
return Release is
|
||||
begin
|
||||
return Extended : Release := Base do
|
||||
Extended.Forbidden := Forbidden;
|
||||
end return;
|
||||
end Forbidding;
|
||||
|
||||
--------------
|
||||
-- Renaming --
|
||||
--------------
|
||||
@@ -111,6 +124,7 @@ package body Alire.Releases is
|
||||
Version => Base.Version,
|
||||
Origin => Base.Origin,
|
||||
Dependencies => Base.Dependencies,
|
||||
Forbidden => Base.Forbidden,
|
||||
Properties => Base.Properties,
|
||||
Priv_Props => Base.Priv_Props,
|
||||
Available => Base.Available)
|
||||
@@ -165,6 +179,7 @@ package body Alire.Releases is
|
||||
Origin => Origin,
|
||||
Notes => Notes,
|
||||
Dependencies => Dependencies,
|
||||
Forbidden => Conditional.For_Dependencies.Empty,
|
||||
Properties => Properties,
|
||||
Priv_Props => Private_Properties,
|
||||
Available => Available);
|
||||
@@ -187,6 +202,7 @@ package body Alire.Releases is
|
||||
Origin => Origin,
|
||||
Notes => "",
|
||||
Dependencies => Dependencies,
|
||||
Forbidden => Conditional.For_Dependencies.Empty,
|
||||
Properties => Properties,
|
||||
Priv_Props => Conditional.For_Properties.Empty,
|
||||
Available => Requisites.Booleans.Always_True);
|
||||
@@ -440,6 +456,7 @@ package body Alire.Releases is
|
||||
Origin => R.Origin,
|
||||
Notes => R.Notes,
|
||||
Dependencies => R.Dependencies.Evaluate (P),
|
||||
Forbidden => R.Forbidden.Evaluate (P),
|
||||
Properties => R.Properties.Evaluate (P),
|
||||
Priv_Props => R.Priv_Props.Evaluate (P),
|
||||
Available => (if R.Available.Check (P)
|
||||
|
||||
@@ -80,6 +80,11 @@ package Alire.Releases with Preelaborate is
|
||||
Version : Semantic_Versioning.Version;
|
||||
Origin : Origins.Origin) return Release;
|
||||
-- Takes a release and replaces version and origin
|
||||
|
||||
function Forbidding (Base : Release;
|
||||
Forbidden : Conditional.Forbidden_Dependencies)
|
||||
return Release;
|
||||
-- Add forbidden dependencies to a release
|
||||
|
||||
function Whenever (R : Release; P : Properties.Vector) return Release;
|
||||
-- Materialize conditions in a Release once the whatever properties are known
|
||||
@@ -96,6 +101,10 @@ package Alire.Releases with Preelaborate is
|
||||
-- The actual project name to be used during dependency resolution
|
||||
-- (But nowhere else)
|
||||
|
||||
function Forbids (R : Release;
|
||||
P : Alire.Properties.Vector)
|
||||
return Conditional.Dependencies;
|
||||
|
||||
function Is_Extension (R : Release) return Boolean;
|
||||
|
||||
function Notes (R : Release) return Description_String; -- Specific to release
|
||||
@@ -202,6 +211,7 @@ private
|
||||
Origin : Origins.Origin;
|
||||
Notes : Description_String (1 .. Notes_Len);
|
||||
Dependencies : Conditional.Dependencies;
|
||||
Forbidden : Conditional.Dependencies;
|
||||
Properties : Conditional.Properties;
|
||||
Priv_Props : Conditional.Properties;
|
||||
Available : Requisites.Tree;
|
||||
@@ -241,6 +251,11 @@ private
|
||||
return Conditional.Dependencies is
|
||||
(R.Dependencies.Evaluate (P));
|
||||
|
||||
function Forbids (R : Release;
|
||||
P : Alire.Properties.Vector)
|
||||
return Conditional.Dependencies is
|
||||
(R.Forbidden.Evaluate (P));
|
||||
|
||||
function Properties (R : Release) return Conditional.Properties is
|
||||
(R.Properties);
|
||||
|
||||
|
||||
+6
-4
@@ -12,13 +12,15 @@ package Alire.Types with Preelaborate is
|
||||
subtype Dependency is Dependencies.Dependency;
|
||||
-- A single dependency on a single project+versions
|
||||
|
||||
subtype Platform_Dependencies is Conditional.Dependencies
|
||||
with Dynamic_Predicate => Platform_Dependencies.Is_Unconditional;
|
||||
-- A plain tree without conditions (but might have OR nodes)
|
||||
|
||||
subtype Abstract_Dependencies is Conditional.Dependencies;
|
||||
-- Conditional dependencies as yet unmaterialized for a precise platform
|
||||
|
||||
subtype Platform_Dependencies is Conditional.Platform_Dependencies;
|
||||
-- A plain tree without conditions (but might have OR nodes)
|
||||
|
||||
subtype Forbidden_Dependencies is Conditional.Forbidden_Dependencies;
|
||||
-- A plain tree without conditions or alternatives
|
||||
|
||||
function No_Dependencies return Conditional.Dependencies
|
||||
renames Conditional.For_Dependencies.Empty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user