Conditional props/deps seemingly working

This commit is contained in:
Alejandro R Mosteo
2018-03-02 19:36:37 +01:00
parent ad943967e5
commit dab6d196c9
8 changed files with 75 additions and 28 deletions
+3 -3
View File
@@ -29,9 +29,9 @@ package Alire.Index.Alire is
Current ("half_life_3") and -- unconditional
If_Platform -- conditional
(System_Is (GNU_Linux),
When_True => At_Least ("elite_horizons", "2.0") and
At_Least ("star_citizen", "3.0"), -- Wish...
When_False => At_Least ("windows_100", "1.0")),
When_True => At_Least ("elite_horizons", V ("2.0")) and
At_Least ("star_citizen", V ("3.0")), -- Wish...
When_False => At_Least ("windows_100", V ("1.0"))),
Properties =>
GPR_Scenario ("Build", "Debug" or "Release") and
+33 -1
View File
@@ -1,5 +1,32 @@
package body Alire.Conditional_Values is
-----------
-- "and" --
-----------
function "and" (L, R : Conditional_Value) return Conditional_Value is
begin
return Result : Conditional_Value do
if L.Is_Empty and then R.Is_Empty then
null; -- nothing to do nor return
else
declare
Inner : Vector_Inner;
begin
if not L.Is_Empty then
Inner.Values.Append (L.Constant_Reference);
end if;
if not R.Is_Empty then
Inner.Values.Append (R.Constant_Reference);
end if;
Result.Replace_Element (Inner);
end;
end if;
end return;
end "and";
--------------
-- Evaluate --
--------------
@@ -30,8 +57,13 @@ package body Alire.Conditional_Values is
end case;
end Evaluate;
Empty_Value : Values;
begin
return Evaluate (This.Constant_Reference);
if This.Is_Empty then
return Empty_Value;
else
return Evaluate (This.Constant_Reference);
end if;
end Evaluate;
--------------
-9
View File
@@ -164,15 +164,6 @@ private
function False_Value (This : Conditional_Value) return Conditional_Value is
(This.As_Conditional.Else_Value);
-----------
-- "and" --
-----------
use all type Vectors.Vector;
function "and" (L, R : Conditional_Value) return Conditional_Value is
(To_Holder (Vector_Inner'(Values => L.Element & R.Element)));
-----------
-- Empty --
-----------
+7 -1
View File
@@ -108,7 +108,7 @@ package Alire.Index is
function Current (P : Project_Name) return Release_Dependencies is (On (P, Semver.Any));
-- These take a project name and a version string
-- These take a project name and a semantic version (see V above)
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);
@@ -117,6 +117,9 @@ package Alire.Index is
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 "and" (L, R : Release_Dependencies) return Release_Dependencies
renames Conditional.For_Dependencies."and";
------------------
-- PROPERTIES --
@@ -171,6 +174,9 @@ package Alire.Index is
function License (L : Licensing.Licenses) return Properties.Vector is (+Properties.Licenses.Values.New_Property (L));
function License (L : Licensing.Licenses) return Conditional.Properties is (U (License (L)));
function "and" (L, R : Release_Properties) return Release_Properties
renames Conditional.For_Properties."and";
-- 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";
+6 -6
View File
@@ -31,7 +31,7 @@ package body Alire.Releases is
----------------
function Executables (R : Release;
P : Properties.Vector := Properties.No_Properties)
P : Properties.Vector)
return Utils.String_Vector is
begin
return Exes : Utils.String_Vector := Values (R.Properties.Evaluate (P), Executable) do
@@ -48,7 +48,7 @@ package body Alire.Releases is
---------------
function GPR_Files (R : Release;
P : Properties.Vector := Properties.No_Properties)
P : Properties.Vector)
return Utils.String_Vector is
begin
return Files : Utils.String_Vector := Values (R.Properties.Evaluate (P), GPR_File) do
@@ -110,11 +110,11 @@ package body Alire.Releases is
end if;
-- DEPENDENCIES
if not R.Depends.Is_Empty then
if not R.Dependencies.Is_Empty then
Put_Line ("Dependencies (direct):");
for Dep of R.Depends loop
Put_Line (" " & Dep.Image);
end loop;
-- for Dep of R.Depends loop
-- Put_Line (" " & Dep.Image);
-- end loop;
end if;
end Print;
+11 -7
View File
@@ -33,9 +33,11 @@ package Alire.Releases with Preelaborate is
function Project (R : Release) return Project_Name;
function Description (R : Release) return Project_Description;
function Version (R : Release) return Semantic_Versioning.Version;
function Depends (R : Release;
P : Properties.Vector := Properties.No_Properties)
P : Properties.Vector)
return Dependencies.Vector;
function Origin (R : Release) return Origins.Origin;
function Available (R : Release) return Requisites.Tree;
@@ -43,13 +45,13 @@ package Alire.Releases with Preelaborate is
-- We encapsulate here the fixing of platform extension
function Executables (R : Release;
P : Properties.Vector := Properties.No_Properties)
P : Properties.Vector)
return Utils.String_Vector;
-- Only explicity declared ones
-- Under some conditions (usually current platform)
function GPR_Files (R : Release;
P : Properties.Vector := Properties.No_Properties)
P : Properties.Vector)
return Utils.String_Vector;
-- Explicitly declared ones, or if default one if none declared
-- Under some conditions (usually current platform)
@@ -81,7 +83,7 @@ package Alire.Releases with Preelaborate is
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 Conditional.Dependencies;
V : Semantic_Versioning.Version) return Conditional.Dependencies;
private
@@ -129,10 +131,12 @@ private
function Project (R : Release) return Project_Name is (R.Name);
function Description (R : Release) return Project_Description is (R.Description);
function Version (R : Release) return Semantic_Versioning.Version is (R.Version);
function Depends (R : Release;
P : Properties.Vector := Properties.No_Properties)
P : Properties.Vector)
return Dependencies.Vector is
(R.Dependencies.Evaluate (P));
function Origin (R : Release) return Origins.Origin is (R.Origin);
function Available (R : Release) return Requisites.Tree is (R.Available);
@@ -160,7 +164,7 @@ private
(On (R.Project, Condition (R.Version)));
function From_Names (P : Project_Name;
V : Semantic_Versioning.Version_String) return Conditional.Dependencies is
(On (P, Condition (Semantic_Versioning.New_Version (V))));
V : Semantic_Versioning.Version) return Conditional.Dependencies is
(On (P, Condition (V)));
end Alire.Releases;
+1 -1
View File
@@ -45,7 +45,7 @@ package body Alire.Root_Project is
Version,
New_Filesystem (Ada.Directories.Current_Directory),
Depends_On,
Properties => Conditions.Properties.Empty_Vector,
Properties => Index.No_Properties,
Available => Requisites.No_Requisites);
begin
if Index.Exists (Project, Version) then
+14
View File
@@ -0,0 +1,14 @@
with Alire.Conditional;
with Alire.Dependencies.Vectors;
package Alire.Types with Preelaborate is
-- Recopilation of types for convenient use in alr
subtype Platform_Dependencies is Dependencies.Vectors.Vector;
-- A plain vector
subtype Abstract_Dependencies is Conditional.Dependencies;
-- Conditional dependencies as yet unmaterialized for a precise platform
end Alire.Types;