Version + Arch properties
This commit is contained in:
+13
-3
@@ -133,6 +133,8 @@ package Alire.Index is
|
||||
use all type Platforms.Compilers;
|
||||
use all type Platforms.Distributions;
|
||||
use all type Platforms.Operating_Systems;
|
||||
use all type Platforms.Versions;
|
||||
use all type Platforms.Word_Sizes;
|
||||
use all type Properties.Property'Class;
|
||||
use all type Release_Dependencies;
|
||||
use all type Release_Properties;
|
||||
@@ -190,14 +192,22 @@ package Alire.Index is
|
||||
-- REQUISITES --
|
||||
------------------
|
||||
|
||||
function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree
|
||||
renames Requisites.Platform.Compiler_Is_At_Least;
|
||||
function Compiler_Is (V : Platforms.Compilers) return Requisites.Tree
|
||||
renames Requisites.Platform.Compiler_Is;
|
||||
|
||||
function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree
|
||||
renames Requisites.Platform.Distribution_Is;
|
||||
|
||||
function System_is (V : Platforms.Operating_Systems) return Requisites.Tree
|
||||
function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree
|
||||
renames Requisites.Platform.System_Is;
|
||||
|
||||
function Version_is (V : Platforms.Versions) return Requisites.Tree
|
||||
renames Requisites.Platform.Version_Is;
|
||||
|
||||
function Word_Size_Is (V : Platforms.Word_Sizes) return Requisites.Tree
|
||||
renames Requisites.Platform.Word_Size_Is;
|
||||
|
||||
-- function Version_Is (V : Platforms.Versions) return
|
||||
|
||||
-- Other useful functions
|
||||
|
||||
|
||||
+14
-6
@@ -10,22 +10,30 @@ package Alire.Platforms with Preelaborate is
|
||||
Windows,
|
||||
Unsupported);
|
||||
|
||||
type Distributions is (Debian_Buster,
|
||||
Ubuntu_Xenial,
|
||||
Ubuntu_Yakkety,
|
||||
Ubunty_Zesty,
|
||||
Ubuntu_Artful,
|
||||
type Distributions is (Debian,
|
||||
Ubuntu,
|
||||
Unsupported);
|
||||
|
||||
type Versions is (Debian_Buster,
|
||||
Ubuntu_Xenial,
|
||||
Ubuntu_Yakkety,
|
||||
Ubunty_Zesty,
|
||||
Ubuntu_Artful,
|
||||
Unsupported);
|
||||
-- Known flavors of OSs
|
||||
-- It turns out that Debian uses no numbers for its non-stable releases, so we'll prefer the codename
|
||||
-- Not really used very much for now
|
||||
|
||||
type Word_Sizes is (Bits_32,
|
||||
Bits_64,
|
||||
Unsupported);
|
||||
|
||||
type Package_Managers is (Apt,
|
||||
Unsupported);
|
||||
|
||||
function Package_Manager (D : Distributions) return Package_Managers is
|
||||
(case D is
|
||||
when Debian_Buster .. Ubuntu_Artful => Apt,
|
||||
when Debian | Ubuntu => Apt,
|
||||
when others => Unsupported);
|
||||
|
||||
end Alire.Platforms;
|
||||
|
||||
@@ -2,13 +2,7 @@ with Alire.Platforms;
|
||||
|
||||
package Alire.Properties.Platform with Preelaborate is
|
||||
|
||||
function Compiler_Is (C : Platforms.Compilers) return Vector;
|
||||
|
||||
function Distribution_Is (D : Platforms.Distributions) return Vector;
|
||||
|
||||
function System_Is (V : Platforms.Operating_Systems) return Vector;
|
||||
|
||||
-- The following packages declare types used elsewhere so they have to be public --
|
||||
-- The following packages declare types used by requisites so they have to be public --
|
||||
|
||||
package Compilers is new Values (Platforms.Compilers,
|
||||
Platforms.Compilers'IMage);
|
||||
@@ -19,15 +13,21 @@ package Alire.Properties.Platform with Preelaborate is
|
||||
package Operating_Systems is new Values (Platforms.Operating_Systems,
|
||||
Platforms.Operating_Systems'Image);
|
||||
|
||||
private
|
||||
package Versions is new Values (Platforms.Versions,
|
||||
Platforms.Versions'Image);
|
||||
|
||||
function Compiler_Is (C : Platforms.Compilers) return Vector is
|
||||
(+Compilers.New_Property (C));
|
||||
package Word_Sizes is new Values (Platforms.Word_Sizes,
|
||||
Platforms.Word_Sizes'Image);
|
||||
|
||||
function Distribution_Is (D : Platforms.Distributions) return Vector is
|
||||
(+Distributions.New_Property (D));
|
||||
|
||||
function System_Is (V : Platforms.Operating_Systems) return Vector is
|
||||
(+Operating_Systems.New_Property (V));
|
||||
function Compiler_Is (C : Platforms.Compilers) return Vector renames Compilers.New_Vector;
|
||||
|
||||
function Distribution_Is (D : Platforms.Distributions) return Vector renames Distributions.New_Vector;
|
||||
|
||||
function System_Is (OS : Platforms.Operating_Systems) return Vector renames Operating_Systems.New_Vector;
|
||||
|
||||
function Version_Is (V : Platforms.Versions) return Vector renames Versions.New_Vector;
|
||||
|
||||
function Word_Size_Is (V : Platforms.Word_Sizes) return Vector renames Word_Sizes.New_Vector;
|
||||
|
||||
end Alire.Properties.Platform;
|
||||
|
||||
@@ -41,6 +41,8 @@ package Alire.Properties with Preelaborate is
|
||||
|
||||
function New_Property (V : Value) return Property;
|
||||
|
||||
function New_Vector (V : Value) return Vector;
|
||||
|
||||
function Element (P : Property) return Value;
|
||||
|
||||
private
|
||||
@@ -53,6 +55,8 @@ package Alire.Properties with Preelaborate is
|
||||
|
||||
function New_Property (V : Value) return Property is (V => V);
|
||||
|
||||
function New_Vector (V : Value) return Vector is (+New_Property (V));
|
||||
|
||||
function Element (P : Property) return Value is (P.V);
|
||||
|
||||
overriding function Image (P : Property) return String is (Image (P.V));
|
||||
|
||||
@@ -117,7 +117,7 @@ package body Alire.Releases is
|
||||
end loop;
|
||||
end Print_Depvec;
|
||||
|
||||
procedure Print_Properties is new Print_Conditional (Conditional.For_Properties, Print_Propvec);
|
||||
procedure Print_Properties is new Print_Conditional (Conditional.For_Properties, Print_Propvec);
|
||||
procedure Print_Dependencies is new Print_Conditional (Conditional.For_Dependencies, Print_Depvec);
|
||||
begin
|
||||
-- MILESTONE
|
||||
|
||||
@@ -1,89 +1,23 @@
|
||||
with Alire.Platforms;
|
||||
with Alire.Properties.Platform;
|
||||
with Alire.Utils;
|
||||
|
||||
package Alire.Requisites.Platform with Preelaborate is
|
||||
|
||||
function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree;
|
||||
package Plat renames Properties.Platform;
|
||||
|
||||
function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree;
|
||||
package Compilers is new Typed_Value_Requisites (Plat.Compilers, "Compiler");
|
||||
function Compiler_Is (V : Platforms.Compilers) return Tree renames Compilers.New_Equality;
|
||||
|
||||
function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree;
|
||||
package Distributions is new Typed_Value_Requisites (Plat.Distributions, "Distribution");
|
||||
function Distribution_Is (V : Platforms.Distributions) return Tree renames Distributions.New_Equality;
|
||||
|
||||
private
|
||||
package Systems is new Typed_Value_Requisites (Plat.Operating_Systems, "OS");
|
||||
function System_Is (V : Platforms.Operating_Systems) return Tree renames Systems.New_Equality;
|
||||
|
||||
-- Preparation for OS requisites mimicking OS properties
|
||||
package Versions is new Typed_Value_Requisites (Plat.Versions, "Version");
|
||||
function Version_Is (V : Platforms.Versions) return Tree renames Versions.New_Equality;
|
||||
|
||||
use all type Platforms.Compilers;
|
||||
use all type Platforms.Distributions;
|
||||
use all type Platforms.Operating_Systems;
|
||||
|
||||
package Props renames Alire.Properties.Platform;
|
||||
|
||||
package System_Requisites is new Typed_Requisites (Props.Operating_Systems.Property'Class);
|
||||
|
||||
function Mix (S : String) return String renames Utils.To_Mixed_Case;
|
||||
|
||||
type OS_Requisite is new System_Requisites.Requisite with record
|
||||
Value : Platforms.Operating_Systems;
|
||||
end record;
|
||||
|
||||
overriding function Image (R : OS_Requisite) return String is
|
||||
("OS is " & Mix (R.Value'Image));
|
||||
|
||||
overriding function Is_Satisfied (R : OS_Requisite;
|
||||
P : Props.Operating_Systems.Property'Class) return Boolean is
|
||||
(R.Value = P.Element);
|
||||
|
||||
|
||||
package Compiler_Requisites is new Typed_Requisites (Props.Compilers.Property'Class);
|
||||
|
||||
type Compiler_Requisite is new Compiler_Requisites.Requisite with record
|
||||
Value : Platforms.Compilers;
|
||||
end record;
|
||||
|
||||
overriding function Image (R : Compiler_Requisite) return String is
|
||||
("Compiler >= " & Mix (R.Value'Image));
|
||||
|
||||
overriding function Is_Satisfied (R : Compiler_Requisite;
|
||||
P : Props.Compilers.Property'Class) return Boolean is
|
||||
(R.Value <= P.Element);
|
||||
|
||||
|
||||
package Distro_Requisites is new Typed_Requisites (Props.Distributions.Property'Class);
|
||||
|
||||
type Distro_Requisite is new Distro_Requisites.Requisite with record
|
||||
Value : Platforms.Distributions;
|
||||
end record;
|
||||
|
||||
overriding function Image (R : Distro_Requisite) return String is
|
||||
("Distribution is " & Mix (R.Value'Image));
|
||||
|
||||
overriding function Is_Satisfied (R : Distro_Requisite;
|
||||
P : Props.Distributions.Property'Class) return Boolean is
|
||||
(R.Value = P.Element);
|
||||
|
||||
use all type Tree;
|
||||
|
||||
--------------------------
|
||||
-- Compiler_Is_At_Least --
|
||||
--------------------------
|
||||
|
||||
function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree is
|
||||
(+Compiler_Requisite'(Value => V));
|
||||
|
||||
---------------------
|
||||
-- Distribution_Is --
|
||||
---------------------
|
||||
|
||||
function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree is
|
||||
(+Distro_Requisite'(Value => V));
|
||||
|
||||
---------------
|
||||
-- System_Is --
|
||||
---------------
|
||||
|
||||
function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree is
|
||||
(+OS_Requisite'(Value => V));
|
||||
package Word_Sizes is new Typed_Value_Requisites (Plat.Word_Sizes, "Arquitecture width");
|
||||
function Word_Size_Is (V : Platforms.Word_Sizes) return Tree renames Word_Sizes.New_Equality;
|
||||
|
||||
end Alire.Requisites.Platform;
|
||||
|
||||
+67
-11
@@ -1,5 +1,6 @@
|
||||
with Alire.Boolean_Trees;
|
||||
with Alire.Properties;
|
||||
with Alire.Utils;
|
||||
|
||||
package Alire.Requisites with Preelaborate is
|
||||
|
||||
@@ -24,6 +25,29 @@ package Alire.Requisites with Preelaborate is
|
||||
function Image (R : Requisite) return String is abstract;
|
||||
-- A necessary pain to be able to report
|
||||
|
||||
-- Trees of requisites to be matched against a list of properties in a release
|
||||
|
||||
function Satisfies (R : Requisite'Class; P : Properties.Vector) return Boolean;
|
||||
-- True if any of the properties in the vector satisfies the requisite
|
||||
|
||||
function Image_Class (R : Requisite'Class) return String is (R.Image);
|
||||
|
||||
package Trees is new Boolean_Trees (Properties.Vector,
|
||||
Requisite'Class,
|
||||
Satisfies,
|
||||
Image_Class);
|
||||
|
||||
subtype Tree is Trees.Tree;
|
||||
|
||||
function No_Requisites return Trees.Tree is (Trees.Empty_Tree);
|
||||
-- Function instead of constant to keep Preelaborate
|
||||
|
||||
----------------------
|
||||
-- Typed_Requisites --
|
||||
----------------------
|
||||
-- Using these we get free matching of properties to requisites
|
||||
-- It is in essence a work around MI
|
||||
|
||||
generic
|
||||
type Compatible_Property (<>) is new Property with private;
|
||||
package Typed_Requisites is
|
||||
@@ -46,23 +70,55 @@ package Alire.Requisites with Preelaborate is
|
||||
then Requisite'Class (R).Is_Satisfied (Compatible_Property (P))
|
||||
else False);
|
||||
|
||||
-- For free we get a requisite that is equality for value properties
|
||||
|
||||
end Typed_Requisites;
|
||||
|
||||
-- Trees of requisites to be matched against a list of properties in a release
|
||||
--------------
|
||||
-- EXTRAS --
|
||||
--------------
|
||||
|
||||
function Satisfies (R : Requisite'Class; P : Properties.Vector) return Boolean;
|
||||
-- True if any of the properties in the vector satisfies the requisite
|
||||
-- This following requisite is a typed_requisite for equality with the property
|
||||
-- Concevably, this could be expanded to offer >=, <, <=...
|
||||
|
||||
function Image_Class (R : Requisite'Class) return String is (R.Image);
|
||||
generic
|
||||
with package Values is new Properties.Values (<>);
|
||||
-- The property that encapsulates the requiiste value
|
||||
|
||||
package Trees is new Boolean_Trees (Properties.Vector,
|
||||
Requisite'Class,
|
||||
Satisfies,
|
||||
Image_Class);
|
||||
Name : String; -- used for image "Name is Mixed_Case (Image (Value))"
|
||||
package Typed_Value_Requisites is
|
||||
|
||||
subtype Tree is Trees.Tree;
|
||||
package Value_Requisites is new Typed_Requisites (Values.Property);
|
||||
|
||||
function No_Requisites return Trees.Tree is (Trees.Empty_Tree);
|
||||
-- Function instead of constant to keep Preelaborate
|
||||
type Equality is new Value_Requisites.Requisite with private;
|
||||
|
||||
function New_Equality (V : Values.Value) return Tree;
|
||||
|
||||
overriding function Is_Satisfied (R : Equality;
|
||||
P : Values.Property)
|
||||
return Boolean;
|
||||
|
||||
overriding function Image (R : Equality)
|
||||
return String;
|
||||
|
||||
private
|
||||
|
||||
function Mix (S : String) return String renames Utils.To_Mixed_Case;
|
||||
use all type Values.Value;
|
||||
|
||||
type Equality is new Value_Requisites.Requisite with record
|
||||
Value : Values.Value;
|
||||
end record;
|
||||
|
||||
function New_Equality (V : Values.Value) return Tree is
|
||||
(Trees.Leaf (Equality'(Value => V)));
|
||||
|
||||
overriding function Is_Satisfied (R : Equality; P : Values.Property) return Boolean is
|
||||
(R.Value = P.Element);
|
||||
|
||||
overriding function Image (R : Equality) return String is
|
||||
(Name & " is " & Mix (Values.Image (R.Value)));
|
||||
|
||||
end Typed_Value_Requisites;
|
||||
|
||||
end Alire.Requisites;
|
||||
|
||||
Reference in New Issue
Block a user