Mostly done, deviation to attmempt full recursive conditions

This commit is contained in:
Alejandro R Mosteo
2018-03-02 12:49:33 +01:00
parent 3790c74113
commit c2c996504a
5 changed files with 107 additions and 119 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ with Alire.Requisites;
generic
type Values is private;
with function "&" (L, R : Values) return Values with Unreferenced; -- used in child vectors
-- FIXME: we'll have to keep an eye on the overhead of this (append to be considered)
-- FIXME: we'll have to keep an eye on the overhead of this (append to be considered instead)
package Alire.Conditional with Preelaborate is
type Conditional_Value (<>) is tagged private;
+2
View File
@@ -4,6 +4,8 @@ with Alire.Dependencies.Vectors;
with Alire.Properties;
with Alire.Requisites;
private with Semantic_Versioning;
package Alire.Conditions with Preelaborate is
package For_Dependencies is new Conditional (Dependencies.Vectors.Vector,
+63 -118
View File
@@ -22,7 +22,7 @@ with Semantic_Versioning;
package Alire.Index is
Releases : Containers.Release_Set;
Catalog : Containers.Release_Set;
subtype Release_Dependencies is Conditions.Dependencies.Vector;
subtype Release_Properties is Conditions.Properties.Vector;
@@ -76,64 +76,52 @@ package Alire.Index is
function V (Semantic_Version : String) return Semver.Version
renames Semver.New_Version;
function On (Name : Project_Name; Versions : Semver.Version_Set)
return Conditions.Dependencies.Vector is
(Conditions.Dependencies.New_Unconditional
(Dependencies.Vectors.New_Dependency (Name, Versions)));
-- This shortcut is mostly for use here, since version sets will usually be
-- constructed directly with a project, using one of the following
function On (Name : Project_Name;
Versions : Semver.Version_Set)
return Conditions.Dependencies.Vector renames Releases.On;
-- We provide two easy shortcut forms:
-- One, using another release, from which we'll take name and version
-- The advantage is that strong typing is used
-- Two, using a name plus a textual version
-- Simpler if there's no exact release matching the versions we want to say
-- Also needed for the generated _alr files which don't know package names
-- The advantage is that strong typing is used
-- Two, using textual name plus version
-- Simpler if there's no exact release matching the versions we want to say
-- Also needed for the generated _alr files which don't know about package names
function Current (R : Release) return Release_Dependencies is
(On (R.Project,
Semver.Within_Major (Semver.New_Version (Semver.Major (R.Version)))));
(On (R.Project, Semver.Within_Major (Semver.New_Version (Semver.Major (R.Version)))));
-- Within the major of R,
-- it will accept the newest/oldest version according to the resolution policy (by default, newest)
-- Note: it might be older than R itself
generic
with function Condition (V : Semver.Version) return Semver.Version_Set;
function From_Release (R : Release) return Release_Dependencies;
-- Just another shortcut for the following declarations
function Within_Major is new From_Release (Semver.Within_Major);
function Within_Minor is new From_Release (Semver.Within_Minor);
function Within_Major (R : Release) return Release_Dependencies is
(On (R.Project, Semver.Within_Major (R.Version)));
function Within_Minor (R : Release) return Release_Dependencies is
(On (R.Project, Semver.Within_Minor (R.Version)));
function At_Least (R : Release) return Dependencies;
function At_Most (R : Release) return Dependencies;
function Less_Than (R : Release) return Dependencies;
function More_Than (R : Release) return Dependencies;
function Exactly (R : Release) return Dependencies;
function Except (R : Release) return Dependencies;
-- These take a release and use its name and version to derive a dependency
function Within_Major is new Releases.From_Release (Semver.Within_Major);
function Within_Minor is new Releases.From_Release (Semver.Within_Minor);
function At_Least is new Releases.From_Release (Semver.At_Least);
function At_Most is new Releases.From_Release (Semver.At_Most);
function Less_Than is new Releases.From_Release (Semver.Less_Than);
function More_Than is new Releases.From_Release (Semver.More_Than);
function Exactly is new Releases.From_Release (Semver.Exactly);
function Except is new Releases.From_Release (Semver.Except);
subtype Version is Semantic_Versioning.Version;
subtype Version_Set is Semantic_Versioning.Version_Set;
function Current (P : Project_Name) return Dependencies;
-- Will accept the newest/oldest version according to the resolution policy (by default, newest)
function Current (P : Project_Name) return Release_Dependencies is (On (P, Semver.Any));
-- These take a project name and a version string
function Within_Major is new Releases.From_Names (Semver.Within_Major);
function Within_Minor is new Releases.From_Names (Semver.Within_Minor);
function At_Least is new Releases.From_Names (Semver.At_Least);
function At_Most is new Releases.From_Names (Semver.At_Most);
function Less_Than is new Releases.From_Names (Semver.Less_Than);
function More_Than is new Releases.From_Names (Semver.More_Than);
function Exactly is new Releases.From_Names (Semver.Exactly);
function Except is new Releases.From_Names (Semver.Except);
function Within_Major (P : Project_Name; V : Version) return Dependencies;
function Within_Minor (P : Project_Name; V : Version) return Dependencies;
function At_Least (P : Project_Name; V : Version) return Dependencies;
function At_Most (P : Project_Name; V : Version) return Dependencies;
function Less_Than (P : Project_Name; V : Version) return Dependencies;
function More_Than (P : Project_Name; V : Version) return Dependencies;
function Exactly (P : Project_Name; V : Version) return Dependencies;
function Except (P : Project_Name; V : Version) return Dependencies;
-- Shortcuts for properties/requisites:
------------------
-- PROPERTIES --
------------------
-- (as vectors of conditionals) --
use all type Alire.Dependencies.Vectors.Vector;
use all type GPR.Value;
@@ -143,13 +131,20 @@ package Alire.Index is
use all type Platforms.Distributions;
use all type Platforms.Operating_Systems;
use all type Properties.Property'Class;
use all type Release_Dependencies;
use all type Release_Properties;
use all type Requisites.Tree;
-- Function for introducing conditional properties
-- Function for introducing conditional properties depending on platform conditions
function If_Platform (Condition : Requisites.Tree;
When_True : Dependencies.Vector;
When_False : Dependencies.Vector := Dependencies.Vectors.No_Dependencies)
return Release_Dependencies;
function If_Platform (Condition : Requisites.Tree;
When_True : Properties.Vector;
When_False : Properties.Vector := Properties.No_Properties) return Release_Properties;
When_False : Properties.Vector := Properties.No_Properties)
return Release_Properties;
-- Attributes (named pairs of label-value)
-- We need them as Properties.Vector (inside conditionals) but also as
@@ -173,16 +168,19 @@ package Alire.Index is
function Website is new PL.Generic_New_Label (Properties.Labeled.Website);
function Website is new PL.Unconditional_New_Label (Properties.Labeled.Website);
function U (Prop : Properties.Vector) return Conditions.Properties.Vector
renames Conditions.Properties.New_Unconditional;
-- Non-label attributes require a custom builder function
function GPR_Free_Scenario (Name : String) return Properties.Vector is (+Properties.Scenarios.New_Variable (GPR.Free_Variable (Name)));
function GPR_Free_Scenario (Name : String) return Conditions.Properties.Vector is (Conditions.Properties.New_Unconditional (GPR_Free_Scenario (Name)));
function GPR_Free_Scenario (Name : String) return Conditions.Properties.Vector is (U (GPR_Free_Scenario (Name)));
function GPR_Scenario (Name : String; Values : GPR.Value_Vector) return Properties.Vector is (+Properties.Scenarios.New_Variable (GPR.Enum_Variable (Name, Values)));
function GPR_Scenario (Name : String; Values : GPR.Value_Vector) return Conditions.Properties.Vector is (Conditions.Properties.New_Unconditional (GPR_Scenario (Name, Values)));
function GPR_Scenario (Name : String; Values : GPR.Value_Vector) return Conditions.Properties.Vector is (U (GPR_Scenario (Name, Values)));
function License (L : Licensing.Licenses) return Properties.Vector is (+Properties.Licenses.Values.New_Property (L));
function License (L : Licensing.Licenses) return Conditions.Properties.Vector is (Conditions.Properties.New_Unconditional (License (L)));
function License (L : Licensing.Licenses) return Conditions.Properties.Vector is (U (License (L)));
function "and" (D1, D2 : Dependencies.Vector) return Dependencies.Vector renames Alire.Dependencies.Vectors."and";
function "and" (P1, P2 : Properties.Vector) return Properties.Vector renames Alire.Properties."and";
@@ -193,7 +191,9 @@ package Alire.Index is
-- function Requires (R : Requisites.Requisite'Class) return Requisites.Tree;
-- function "+" (R : Requisites.Requisite'Class) return Requisites.Tree renames Requires;
-- Specific shortcuts:
------------------
-- REQUISITES --
------------------
function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree
renames Requisites.Platform.Compiler_Is_At_Least;
@@ -225,77 +225,22 @@ package Alire.Index is
private
function From_Release (R : Release) return Release_Dependencies is
(On (R.Project, Condition (R.Version)));
-- Body for the generic above
-- function Verifies (P : Properties.Property'Class) return Properties.Vector is
-- (Properties.To_Vector (P, 1));
--
-- function Requires (R : Requisites.Requisite'Class) return Requisites.Tree is
-- (Requisites.Trees.Leaf (R));
use Semantic_Versioning;
function Current (R : Release) return Dependencies is
(New_Dependency (R.Project, Within_Major (New_Version (Major (R.Version)))));
function Within_Major (R : Release) return Dependencies is
(New_Dependency (R.Project, Within_Major (R.Version)));
function Within_Minor (R : Release) return Dependencies is
(New_Dependency (R.Project, Within_Minor (R.Version)));
function At_Least (R : Release) return Dependencies is
(New_Dependency (R.Project, At_Least (R.Version)));
function At_Most (R : Release) return Dependencies is
(New_Dependency (R.Project, At_Most (R.Version)));
function Less_Than (R : Release) return Dependencies is
(New_Dependency (R.Project, Less_Than (R.Version)));
function More_Than (R : Release) return Dependencies is
(New_Dependency (R.Project, More_Than (R.Version)));
function Exactly (R : Release) return Dependencies is
(New_Dependency (R.Project, Exactly (R.Version)));
function Except (R : Release) return Dependencies is
(New_Dependency (R.Project, Except (R.Version)));
function Current (P : Project_Name) return Dependencies is
(New_Dependency (P, At_Least (V ("0.0.0"))));
function Within_Major (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, Within_Major (V)));
function Within_Minor (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, Within_Minor (V)));
function At_Least (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, At_Least (V)));
function At_Most (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, At_Most (V)));
function Less_Than (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, Less_Than (V)));
function More_Than (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, More_Than (V)));
function Exactly (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, Exactly (V)));
function Except (P : Project_Name; V : Version) return Dependencies is
(New_Dependency (P, Except (V)));
function Verifies (P : Properties.Property'Class) return Properties.Vector is
(Properties.To_Vector (P, 1));
function Requires (R : Requisites.Requisite'Class) return Requisites.Tree is
(Requisites.Trees.Leaf (R));
function If_Platform (Condition : Requisites.Tree;
When_True : Dependencies.Vector;
When_False : Dependencies.Vector := Dependencies.Vectors.No_Dependencies)
return Release_Dependencies is
(Conditions.Dependencies.New_Conditional (Condition, When_True, When_False));
function If_Platform (Condition : Requisites.Tree;
When_True : Properties.Vector;
When_False : Properties.Vector := Properties.No_Properties) return Release_Properties is
When_False : Properties.Vector := Properties.No_Properties)
return Release_Properties is
(Conditions.Properties.New_Conditional (Condition, When_True, When_False));
end Alire.Index;
+31
View File
@@ -1,5 +1,6 @@
with Alire.Conditions;
with Alire.Dependencies;
with Alire.Dependencies.Vectors;
with Alire.Milestones;
with Alire.Origins;
with Alire.Properties;
@@ -60,6 +61,21 @@ package Alire.Releases with Preelaborate is
function Property_Contains (R : Release; Str : String) return Boolean;
-- True if some property contains the given string
-- Dependency generation helpers
function On (Name : Project_Name;
Versions : Semantic_Versioning.Version_Set)
return Conditions.Dependencies.Vector;
generic
with function Condition (V : Semantic_Versioning.Version) return Semantic_Versioning.Version_Set;
function From_Release (R : Release) return Conditions.Dependencies.Vector;
generic
with function Condition (V : Semantic_Versioning.Version) return Semantic_Versioning.Version_Set;
function From_Names (P : Project_Name;
V : Semantic_Versioning.Version_String) return Conditions.Dependencies.Vector;
private
@@ -125,5 +141,20 @@ private
Image (R.Version) & "_" &
(if R.Origin.Id'Length <= 8 then R.Origin.Id
else R.Origin.Id (R.Origin.Id'First .. R.Origin.Id'First + 7)));
-- Dependency helpers
function On (Name : Project_Name;
Versions : Semantic_Versioning.Version_Set)
return Conditions.Dependencies.Vector is
(Conditions.Dependencies.New_Unconditional -- A conditional (without condition) dependency vector
(Dependencies.Vectors.New_Dependency (Name, Versions))); -- A dependency vector
function From_Release (R : Release) return Conditions.Dependencies.Vector is
(On (R.Project, Condition (R.Version)));
function From_Names (P : Project_Name;
V : Semantic_Versioning.Version_String) return Conditions.Dependencies.Vector is
(On (P, Condition (Semantic_Versioning.New_Version (V))));
end Alire.Releases;