Preparation for availability checks
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package Alire.Index.LibGNUTLS is
|
||||
|
||||
Name : constant String := "libgnutls";
|
||||
Desc : constant String := "GNU TLS library";
|
||||
|
||||
V_3_5_8 : constant Release :=
|
||||
Register (Name,
|
||||
V ("3.5.8"),
|
||||
Desc,
|
||||
Apt ("libgnutls28-dev"),
|
||||
Available_When =>
|
||||
Distribution_Is (Debian_Buster) or
|
||||
Distribution_Is (Ubuntu_Artful));
|
||||
|
||||
end Alire.Index.LibGNUTLS;
|
||||
+64
-23
@@ -98,35 +98,76 @@ package body Alire.Boolean_Trees is
|
||||
return Check (Trees.First_Child (T.Root));
|
||||
end Check;
|
||||
|
||||
---------------------
|
||||
-- Image_Recursive --
|
||||
---------------------
|
||||
|
||||
function Image_Recursive (C : Trees.Cursor; Skeleton : Boolean) return String is
|
||||
N : constant Node := Trees.Element (C);
|
||||
begin
|
||||
case N.Kind is
|
||||
when Leaf =>
|
||||
if Skeleton then
|
||||
return "Leaf";
|
||||
else
|
||||
return Image (N.Condition.Constant_Reference);
|
||||
end if;
|
||||
when And_Node =>
|
||||
return "(" & Image_Recursive (Trees.First_Child (C), Skeleton) & " and " &
|
||||
Image_Recursive (Trees.Last_Child (C), Skeleton) & ")";
|
||||
when Or_Node =>
|
||||
return "(" & Image_Recursive (Trees.First_Child (C), Skeleton) & " or " &
|
||||
Image_Recursive (Trees.Last_Child (C), Skeleton) & ")";
|
||||
when Not_Node =>
|
||||
return "(not " & Image_Recursive (Trees.First_Child (C), Skeleton) & ")";
|
||||
end case;
|
||||
end Image_Recursive;
|
||||
|
||||
-----------
|
||||
-- Image --
|
||||
-----------
|
||||
|
||||
function Image (T : Tree) return String is
|
||||
use Trees;
|
||||
begin
|
||||
if T.Is_Empty then
|
||||
return "(empty tree)";
|
||||
else
|
||||
return Image_Recursive (Trees.First_Child (T.Root), Skeleton => False);
|
||||
end if;
|
||||
end Image;
|
||||
|
||||
-----------
|
||||
-- Print --
|
||||
-----------
|
||||
|
||||
procedure Print (T : Tree) is
|
||||
begin
|
||||
GNAT.IO.Put_Line (T.Image);
|
||||
end Print;
|
||||
|
||||
--------------------
|
||||
-- Image_Skeleton --
|
||||
--------------------
|
||||
|
||||
function Image_Skeleton (T : Tree) return String is
|
||||
use Trees;
|
||||
|
||||
begin
|
||||
if T.Is_Empty then
|
||||
return "(empty tree)";
|
||||
else
|
||||
return Image_Recursive (Trees.First_Child (T.Root), Skeleton => True);
|
||||
end if;
|
||||
end Image_Skeleton;
|
||||
|
||||
--------------------
|
||||
-- Print_Skeleton --
|
||||
--------------------
|
||||
|
||||
procedure Print_Skeleton (T : Tree) is
|
||||
use GNAT.IO;
|
||||
use Trees;
|
||||
|
||||
function Image (C : Trees.Cursor) return String is
|
||||
N : constant Node := Trees.Element (C);
|
||||
begin
|
||||
case N.Kind is
|
||||
when Leaf =>
|
||||
return "Leaf";
|
||||
when And_Node =>
|
||||
return "(" & Image (Trees.First_Child (C)) & " and " & Image (Trees.Last_Child (C)) & ")";
|
||||
when Or_Node =>
|
||||
return "(" & Image (Trees.First_Child (C)) & " or " & Image (Trees.Last_Child (C)) & ")";
|
||||
when Not_Node =>
|
||||
return "(not " & Image (Trees.First_Child (C)) & ")";
|
||||
end case;
|
||||
end Image;
|
||||
|
||||
begin
|
||||
if T.Is_Empty then
|
||||
Put_Line ("(null tree)");
|
||||
else
|
||||
Put_Line (Image (Trees.First_Child (T.Root)));
|
||||
end if;
|
||||
GNAT.IO.Put_Line (T.Image_Skeleton);
|
||||
end Print_Skeleton;
|
||||
|
||||
end Alire.Boolean_Trees;
|
||||
|
||||
@@ -5,6 +5,7 @@ generic
|
||||
type Value (<>) is private;
|
||||
type Condition (<>) is private;
|
||||
with function Check (C : Condition; V : Value) return Boolean;
|
||||
with function Image (C : Condition) return String;
|
||||
package Alire.Boolean_Trees with Preelaborate is
|
||||
|
||||
-- A package to represent trees of logical expressions
|
||||
@@ -44,8 +45,12 @@ package Alire.Boolean_Trees with Preelaborate is
|
||||
|
||||
-- Debugging
|
||||
|
||||
function Image_Skeleton (T : Tree) return String;
|
||||
procedure Print_Skeleton (T : Tree);
|
||||
|
||||
function Image (T : Tree) return String;
|
||||
procedure Print (T : Tree);
|
||||
|
||||
private
|
||||
|
||||
type Node_Kinds is (Leaf, And_Node, Or_Node, Not_Node);
|
||||
|
||||
+7
-2
@@ -46,6 +46,7 @@ package Alire.Index is
|
||||
-- Available_On are properties the platform has to fulfill.
|
||||
|
||||
-- Shortcuts for common origins:
|
||||
function Apt (Pack : String ) return Origins.Origin renames Origins.New_Apt;
|
||||
function Git (URL : Alire.URL; Commit : Origins.Git_Commit) return Origins.Origin renames Origins.New_Git;
|
||||
function Hg (URL : Alire.URL; Commit : Origins.Hg_Commit) return Origins.Origin renames Origins.New_Hg;
|
||||
|
||||
@@ -92,6 +93,7 @@ package Alire.Index is
|
||||
use all type GPR.Value_Vector;
|
||||
use all type Licensing.Licenses;
|
||||
use all type Platforms.Compilers;
|
||||
use all type Platforms.Distributions;
|
||||
use all type Platforms.Operating_Systems;
|
||||
use all type Properties.Property'Class;
|
||||
use all type Requisites.Requisite'Class;
|
||||
@@ -123,10 +125,13 @@ package Alire.Index is
|
||||
|
||||
-- Specific shortcuts:
|
||||
|
||||
function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Requisite'Class
|
||||
function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree
|
||||
renames Requisites.Platform.Compiler_Is_At_Least;
|
||||
|
||||
function System_is (V : Platforms.Operating_Systems) return Requisites.Requisite'Class
|
||||
function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree
|
||||
renames Requisites.Platform.Distribution_Is;
|
||||
|
||||
function System_is (V : Platforms.Operating_Systems) return Requisites.Tree
|
||||
renames Requisites.Platform.System_Is;
|
||||
|
||||
-- Other useful functions
|
||||
|
||||
+13
-8
@@ -21,6 +21,8 @@ package Alire.Origins with Preelaborate is
|
||||
|
||||
function Id (This : Origin) return String;
|
||||
|
||||
function Is_Native (This : Origin) return Boolean;
|
||||
|
||||
-- Helper types
|
||||
|
||||
subtype Git_Commit is String (1 .. 40);
|
||||
@@ -54,27 +56,27 @@ private
|
||||
|
||||
function New_Filesystem (URL_As_Path : String) return Origin is
|
||||
(Filesystem,
|
||||
Null_Unbounded_String,
|
||||
To_Unbounded_String (URL_As_Path));
|
||||
Id => Null_Unbounded_String,
|
||||
URL => To_Unbounded_String (URL_As_Path));
|
||||
|
||||
function New_Git (URL : Alire.URL;
|
||||
Id : Git_Commit)
|
||||
return Origin is
|
||||
(Git,
|
||||
To_Unbounded_String (URL),
|
||||
To_Unbounded_String (Id));
|
||||
URL => To_Unbounded_String (URL),
|
||||
Id => To_Unbounded_String (Id));
|
||||
|
||||
function New_Hg (URL : Alire.URL;
|
||||
Id : Hg_Commit)
|
||||
return Origin is
|
||||
(Hg,
|
||||
To_Unbounded_String (URL),
|
||||
To_Unbounded_String (Id));
|
||||
URL => To_Unbounded_String (URL),
|
||||
Id => To_Unbounded_String (Id));
|
||||
|
||||
function New_Apt (Id_As_Package_Name : String) return Origin is
|
||||
(Apt,
|
||||
To_Unbounded_String (Id_As_Package_Name),
|
||||
Null_Unbounded_String);
|
||||
Id => To_Unbounded_String (Id_As_Package_Name),
|
||||
URL => Null_Unbounded_String);
|
||||
|
||||
function Kind (This : Origin) return Kinds is (This.Kind);
|
||||
|
||||
@@ -82,6 +84,9 @@ private
|
||||
|
||||
function Id (This : Origin) return String is (To_String (This.Id));
|
||||
|
||||
function Is_Native (This : Origin) return Boolean is
|
||||
(This.Kind in Apt);
|
||||
|
||||
function S (Str : Unbounded_String) return String is (To_String (Str));
|
||||
|
||||
function Image (This : Origin) return String is
|
||||
|
||||
@@ -9,4 +9,10 @@ package Alire.Platforms with Preelaborate is
|
||||
type Operating_Systems is (GNU_Linux,
|
||||
Windows);
|
||||
|
||||
type Distributions is (Debian_Buster,
|
||||
Ubuntu_Artful);
|
||||
-- Known flavors of OSs
|
||||
-- It turns out that Debian uses no numbers for its non-stable releases, so we'll prefer the codename
|
||||
-- These are important mostly to tie platform package names to releases
|
||||
|
||||
end Alire.Platforms;
|
||||
|
||||
@@ -4,6 +4,10 @@ package Alire.Properties.Platform with Preelaborate is
|
||||
|
||||
package Compilers is new Values (Platforms.Compilers,
|
||||
Platforms.Compilers'IMage);
|
||||
|
||||
package Distributions is new Values (Platforms.Distributions,
|
||||
Platforms.Distributions'Image);
|
||||
|
||||
package Operating_Systems is new Values (Platforms.Operating_Systems,
|
||||
Platforms.Operating_Systems'Image);
|
||||
|
||||
|
||||
@@ -67,6 +67,11 @@ package body Alire.Releases is
|
||||
-- ORIGIN
|
||||
Put_Line ("Origin: " & R.Origin.Image);
|
||||
|
||||
-- AVAILABILITY
|
||||
if not R.Available.Is_Empty then
|
||||
Put_Line ("Available when: " & R.Available.Image);
|
||||
end if;
|
||||
|
||||
-- REQUISITES
|
||||
if not R.Reqs.Is_Empty then
|
||||
Put ("Requisites: ");
|
||||
|
||||
@@ -1,27 +1,36 @@
|
||||
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.Requisite'Class;
|
||||
function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree;
|
||||
|
||||
function System_Is (V : Platforms.Operating_Systems) return Requisites.Requisite'Class;
|
||||
function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree;
|
||||
|
||||
function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree;
|
||||
|
||||
private
|
||||
|
||||
-- Preparation for OS requisites mimicking OS properties
|
||||
|
||||
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);
|
||||
@@ -33,22 +42,48 @@ private
|
||||
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.Requisite'Class is
|
||||
(Compiler_Requisite'(Value => V));
|
||||
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.Requisite'Class is
|
||||
(OS_Requisite'(Value => V));
|
||||
function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree is
|
||||
(+OS_Requisite'(Value => V));
|
||||
|
||||
end Alire.Requisites.Platform;
|
||||
|
||||
@@ -21,6 +21,9 @@ package Alire.Requisites with Preelaborate is
|
||||
-- This function is used later in the generic implementation to automatically downcast,
|
||||
-- so requisite implementations do not need to deal with this MI-mess
|
||||
|
||||
function Image (R : Requisite) return String is abstract;
|
||||
-- A necessary pain to be able to report
|
||||
|
||||
generic
|
||||
type Compatible_Property (<>) is new Property with private;
|
||||
package Typed_Requisites is
|
||||
@@ -50,9 +53,12 @@ package Alire.Requisites with Preelaborate is
|
||||
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);
|
||||
Satisfies,
|
||||
Image_Class);
|
||||
|
||||
subtype Tree is Trees.Tree;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
with Ada.Calendar;
|
||||
|
||||
package Alire_Early_Elaboration with Elaborate_Body is
|
||||
|
||||
-- This body should be elaborated among the first ones.
|
||||
@@ -10,4 +12,7 @@ package Alire_Early_Elaboration with Elaborate_Body is
|
||||
Switch_V : aliased Boolean := False;
|
||||
-- Verbosity switches detected during early elaboration
|
||||
|
||||
Start : constant Ada.Calendar.Time := Ada.Calendar.Clock;
|
||||
-- Out of curiosity
|
||||
|
||||
end Alire_Early_Elaboration;
|
||||
|
||||
Reference in New Issue
Block a user