Platform filters on
This commit is contained in:
@@ -7,9 +7,8 @@ package Alire.Index.Example_Dependencies is
|
||||
V ("1.0.0"),
|
||||
Repositories.Local.Repo,
|
||||
Repositories.Local.Local_Id,
|
||||
Requisites => Available_On (GNU_Linux) and
|
||||
(Available_On (GNU_Linux) or not Available_On (GNU_Linux))
|
||||
-- Compiles_With (GNAT_GPL_2017)));
|
||||
);
|
||||
Available_When => -- Note that it's impossible
|
||||
(System_Is (Windows) and System_Is (GNU_Linux)) and
|
||||
Compiler_Is_At_Least (GNAT_Any));
|
||||
|
||||
end Alire.Index.Example_Dependencies;
|
||||
|
||||
+16
-2
@@ -1,5 +1,10 @@
|
||||
with Alire.Properties.Platform;
|
||||
|
||||
package body Alire.Index is
|
||||
|
||||
Platform_Properties : constant Properties.Vector :=
|
||||
Properties.Platform.Current;
|
||||
|
||||
--------------
|
||||
-- Register --
|
||||
--------------
|
||||
@@ -9,8 +14,9 @@ package body Alire.Index is
|
||||
Hosting : Repositories.Repository'Class;
|
||||
Id : Repositories.Release_Id;
|
||||
Depends_On : Dependencies := Depends.Nothing;
|
||||
Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector;
|
||||
Requisites : Alire.Requisites.Tree := Alire.Requisites.No_Requisites;
|
||||
Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector;
|
||||
Requisites : Alire.Requisites.Tree := Alire.Requisites.No_Requisites;
|
||||
Available_When : Alire.Requisites.Tree := Alire.Requisites.No_Requisites;
|
||||
Native : Boolean := False) return Release
|
||||
is
|
||||
begin
|
||||
@@ -24,6 +30,14 @@ package body Alire.Index is
|
||||
Requisites => Requisites,
|
||||
Native => Native)
|
||||
do
|
||||
if not Available_When.Is_Empty and then
|
||||
not Available_When.Check (Platform_Properties)
|
||||
then
|
||||
Trace.Debug ("Release " & Rel.Milestone_Image &
|
||||
" requisites not met by platform");
|
||||
return;
|
||||
end if;
|
||||
|
||||
if Releases.Contains (Rel) then
|
||||
Log ("Attempt to register duplicate versions: " & Rel.Milestone_Image, Warning);
|
||||
else
|
||||
|
||||
+21
-26
@@ -19,20 +19,15 @@ package Alire.Index is
|
||||
|
||||
subtype Release is Alire.Releases.Release;
|
||||
|
||||
-- subtype Solution is Containers.Version_Map; -- A dependence-valid mapping of project -> version
|
||||
-- subtype Instance is Containers.Release_Map; -- A list of releases complying with a Solution
|
||||
|
||||
-- Empty_Instance : constant Instance := Containers.Project_Release_Maps.Empty_Map;
|
||||
|
||||
function Register (Project : Project_Name;
|
||||
Version : Semantic_Versioning.Version;
|
||||
Hosting : Repositories.Repository'Class;
|
||||
Id : Repositories.Release_Id;
|
||||
Depends_On : Dependencies := Depends.Nothing;
|
||||
Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector;
|
||||
Requisites : Alire.Requisites.Tree := Alire.Requisites.No_Requisites;
|
||||
Available_On : Alire.Requisites.Tree := Alire.Requisites.No_Requisites;
|
||||
Native : Boolean := False) return Release;
|
||||
Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector;
|
||||
Requisites : Alire.Requisites.Tree := Alire.Requisites.No_Requisites;
|
||||
Available_When : Alire.Requisites.Tree := Alire.Requisites.No_Requisites;
|
||||
Native : Boolean := False) return Release;
|
||||
-- Properties are of the Release; currently not used but could support License or other attributes.
|
||||
-- Requisites are properties that dependencies have to fulfill, again not used yet.
|
||||
-- Available_On are properties the platform has to fulfill; these are checked on registration.
|
||||
@@ -46,7 +41,7 @@ package Alire.Index is
|
||||
Depends_On : Dependencies := Depends.Nothing) return Release;
|
||||
|
||||
-- Shortcuts to give dependencies:
|
||||
|
||||
|
||||
function V (Semantic_Version : String) return Semantic_Versioning.Version
|
||||
renames Semantic_Versioning.New_Version;
|
||||
|
||||
@@ -70,29 +65,29 @@ package Alire.Index is
|
||||
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:
|
||||
use all type Compilers.Compilers;
|
||||
use all type Operating_Systems.Operating_Systems;
|
||||
|
||||
|
||||
use all type Properties.Property'Class; -- for "and" operator
|
||||
use all type Requisites.Requisite'Class;
|
||||
use all type Requisites.Requisite'Class;
|
||||
use all type Requisites.Tree; -- for logical operators
|
||||
|
||||
Default_Properties : constant Properties.Vector := Properties.Vectors.Empty_Vector;
|
||||
No_Requisites : constant Requisites.Tree := Requisites.No_Requisites;
|
||||
|
||||
|
||||
Default_Properties : constant Properties.Vector := Properties.Vectors.Empty_Vector;
|
||||
No_Requisites : constant Requisites.Tree := Requisites.No_Requisites;
|
||||
|
||||
function Verifies (P : Properties.Property'Class) return Properties.Vector;
|
||||
function "+" (P : Properties.Property'Class) return Properties.Vector renames Verifies;
|
||||
|
||||
|
||||
function Requires (R : Requisites.Requisite'Class) return Requisites.Tree;
|
||||
function "+" (R : Requisites.Requisite'Class) return Requisites.Tree renames Requires;
|
||||
|
||||
-- Specific shortcuts:
|
||||
|
||||
function Compiler_Is (V : Compilers.Compilers) return Requisites.Requisite'Class
|
||||
renames Requisites.Platform.Compiler_Is;
|
||||
|
||||
-- Specific shortcuts:
|
||||
|
||||
function Compiler_Is_At_Least (V : Compilers.Compilers) return Requisites.Requisite'Class
|
||||
renames Requisites.Platform.Compiler_Is_At_Least;
|
||||
|
||||
function System_is (V : Operating_Systems.Operating_Systems) return Requisites.Requisite'Class
|
||||
renames Requisites.Platform.System_Is;
|
||||
|
||||
@@ -159,11 +154,11 @@ private
|
||||
|
||||
function Except (P : Project_Name; V : Version) return Dependencies is
|
||||
(Depends_On (P, Except (V)));
|
||||
|
||||
|
||||
|
||||
|
||||
function Verifies (P : Properties.Property'Class) return Properties.Vector is
|
||||
(Properties.Vectors.To_Vector (P, 1));
|
||||
|
||||
|
||||
function Requires (R : Requisites.Requisite'Class) return Requisites.Tree is
|
||||
(Requisites.Trees.Leaf (R));
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package Alire.Platform with Preelaborate is
|
||||
|
||||
end Alire.Platform;
|
||||
@@ -1,5 +1,3 @@
|
||||
with Alire.Containers;
|
||||
|
||||
package body Alire.Query is
|
||||
|
||||
------------
|
||||
|
||||
+9
-3
@@ -1,12 +1,18 @@
|
||||
with Alire.Containers;
|
||||
with Alire.Index; use Alire.Index;
|
||||
|
||||
package Alire.Query is
|
||||
|
||||
|
||||
--subtype Solution is Containers.Version_Map; -- A dependence-valid mapping of project -> version
|
||||
subtype Instance is Containers.Release_Map; -- A list of releases complying with a Solution
|
||||
|
||||
Empty_Instance : constant Instance := Containers.Project_Release_Maps.Empty_Map;
|
||||
|
||||
function Exists (Project : Project_Name) return Boolean;
|
||||
|
||||
function Resolve (Deps : Dependencies;
|
||||
Success : out Boolean) return Instance;
|
||||
|
||||
Success : out Boolean) return Instance;
|
||||
|
||||
procedure Print_Solution (I : Instance);
|
||||
|
||||
end Alire.Query;
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
with Alire.Platform;
|
||||
with Alire.Compilers;
|
||||
with Alire.Properties.Platform;
|
||||
with Alire.Operating_Systems;
|
||||
|
||||
package Alire.Requisites.Platform with Preelaborate is
|
||||
|
||||
function Available_On (V : Alire.Platform.Operating_Systems) return Requisites.Requisite'Class;
|
||||
function Compiler_Is_At_Least (V : Compilers.Compilers) return Requisites.Requisite'Class;
|
||||
|
||||
function System_Is (V : Operating_Systems.Operating_Systems) return Requisites.Requisite'Class;
|
||||
|
||||
private
|
||||
|
||||
-- Preparation for OS requisites mimicking OS properties
|
||||
|
||||
use all type Alire.Platform.Operating_Systems;
|
||||
use all type Compilers.Compilers;
|
||||
use all type Operating_Systems.Operating_Systems;
|
||||
|
||||
package Props renames Alire.Properties.Platform;
|
||||
|
||||
package Operating_Systems is new Typed_Requisites (Props.Operating_Systems.Property'Class);
|
||||
package System_Requisites is new Typed_Requisites (Props.Operating_Systems.Property'Class);
|
||||
|
||||
type OS_Requisite is new Operating_Systems.Requisite with record
|
||||
Value : Alire.Platform.Operating_Systems;
|
||||
type OS_Requisite is new System_Requisites.Requisite with record
|
||||
Value : Operating_Systems.Operating_Systems;
|
||||
end record;
|
||||
|
||||
overriding function Is_Satisfied (R : OS_Requisite;
|
||||
@@ -24,11 +28,28 @@ private
|
||||
(R.Value = P.Element);
|
||||
|
||||
|
||||
------------------
|
||||
-- Available_On --
|
||||
------------------
|
||||
package Compiler_Requisites is new Typed_Requisites (Props.Compilers.Property'Class);
|
||||
|
||||
function Available_On (V : Alire.Platform.Operating_Systems) return Requisites.Requisite'Class is
|
||||
type Compiler_Requisite is new Compiler_Requisites.Requisite with record
|
||||
Value : Compilers.Compilers;
|
||||
end record;
|
||||
|
||||
overriding function Is_Satisfied (R : Compiler_Requisite;
|
||||
P : Props.Compilers.Property'Class) return Boolean is
|
||||
(R.Value <= P.Element);
|
||||
|
||||
--------------------------
|
||||
-- Compiler_Is_At_Least --
|
||||
--------------------------
|
||||
|
||||
function Compiler_Is_At_Least (V : Compilers.Compilers) return Requisites.Requisite'Class is
|
||||
(Compiler_Requisite'(Value => V));
|
||||
|
||||
---------------
|
||||
-- System_Is --
|
||||
---------------
|
||||
|
||||
function System_Is (V : Operating_Systems.Operating_Systems) return Requisites.Requisite'Class is
|
||||
(OS_Requisite'(Value => V));
|
||||
|
||||
end Alire.Requisites.Platform;
|
||||
|
||||
@@ -7,7 +7,7 @@ package body Alire.Requisites is
|
||||
function Satisfies (R : Requisite'Class; P : Properties.Vector) return Boolean is
|
||||
begin
|
||||
for Prop of P loop
|
||||
if R.Satisfies (P) then
|
||||
if R.Satisfies (Prop) then
|
||||
return True;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
@@ -40,8 +40,9 @@ package Alire.Requisites with Preelaborate is
|
||||
|
||||
overriding
|
||||
function Satisfies (R : Requisite; P : Property'Class) return Boolean is
|
||||
(Requisite'Class (R).Is_Satisfied (Compatible_Property (P)))
|
||||
with Pre => R.Is_Applicable (P);
|
||||
(if R.Is_Applicable (P)
|
||||
then Requisite'Class (R).Is_Satisfied (Compatible_Property (P))
|
||||
else False);
|
||||
|
||||
end Typed_Requisites;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user