Streamlined dependencies working, solver is greedy
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
with Ada.Containers.Indefinite_Vectors;
|
||||
|
||||
with Alire.Utils;
|
||||
|
||||
package Alire.Dependencies.Vectors with Preelaborate is
|
||||
|
||||
-- Dependencies are a plain list (vector) of individual dependencies
|
||||
-- There's nothing preventing giving version sets on the same project as distinct dependencies
|
||||
|
||||
package Dependency_Vectors is new Ada.Containers.Indefinite_Vectors (Positive, Dependency);
|
||||
|
||||
type Vector is new Dependency_Vectors.Vector with private;
|
||||
|
||||
function Image_One_Line (V : Vector) return String;
|
||||
|
||||
function No_Dependencies return Vector;
|
||||
|
||||
-- Creation of dependency vectors
|
||||
|
||||
function New_Dependency (Name : Names;
|
||||
Versions : Semantic_Versioning.Version_Set) return Vector;
|
||||
|
||||
function "and" (Dep1, Dep2 : Vector) return Vector is (Dep1 & Dep2);
|
||||
|
||||
private
|
||||
|
||||
type Vector is new Dependency_Vectors.Vector with null record;
|
||||
-- New type so the "and" function is primitive
|
||||
|
||||
function No_Dependencies return Vector is (Dependency_Vectors.Empty_Vector with null record);
|
||||
|
||||
--------------------
|
||||
-- New_Dependency --
|
||||
--------------------
|
||||
|
||||
function New_Dependency (Name : Names;
|
||||
Versions : Semantic_Versioning.Version_Set) return Vector is
|
||||
(To_Vector ((Name'Length, Name, Versions), 1));
|
||||
|
||||
--------------------
|
||||
-- Image_One_Line --
|
||||
--------------------
|
||||
|
||||
package Non_Primitives is
|
||||
function Image_One_Line_Instance is
|
||||
new Utils.Image_One_Line (Dependency_Vectors,
|
||||
Vector,
|
||||
Image,
|
||||
" and ",
|
||||
"(no dependencies");
|
||||
end Non_Primitives;
|
||||
|
||||
function Image_One_Line (V : Vector) return String
|
||||
renames Non_Primitives.Image_One_Line_Instance;
|
||||
|
||||
end Alire.Dependencies.Vectors;
|
||||
@@ -0,0 +1,32 @@
|
||||
with Ada.Containers.Indefinite_Holders;
|
||||
|
||||
package body Alire.Platform is
|
||||
|
||||
package Holders is new Ada.Containers.Indefinite_Holders (Supported_Platform'Class);
|
||||
|
||||
This : Holders.Holder;
|
||||
|
||||
|
||||
type Unsupported_Platform is new Supported_Platform with null record;
|
||||
|
||||
overriding function Package_Version (P : Unsupported_Platform; Origin : Origins.Origin) return String is ("");
|
||||
|
||||
-------------
|
||||
-- Current --
|
||||
-------------
|
||||
|
||||
function Current return Supported_Platform'Class is
|
||||
(if This.Is_Empty
|
||||
then Unsupported_Platform'(Supported_Platform with null record)
|
||||
else This.Element);
|
||||
|
||||
------------------
|
||||
-- Set_Platform --
|
||||
------------------
|
||||
|
||||
procedure Set (P : Supported_Platform'Class) is
|
||||
begin
|
||||
This.Replace_Element (P);
|
||||
end Set;
|
||||
|
||||
end Alire.Platform;
|
||||
@@ -0,0 +1,20 @@
|
||||
with Alire.Origins;
|
||||
|
||||
package Alire.Platform with Preelaborate is
|
||||
|
||||
-- This interface encapsulates what a supported platform must provide for use in Alire, and a way
|
||||
-- to hook it after elaboration
|
||||
|
||||
type Supported_Platform is interface;
|
||||
|
||||
function Package_Version (P : Supported_Platform;
|
||||
Origin : Origins.Origin)
|
||||
return String is abstract;
|
||||
|
||||
procedure Set (P : Supported_Platform'Class);
|
||||
|
||||
function Current return Supported_Platform'Class
|
||||
with Pre => Platform'Elaborated;
|
||||
-- Always valid, because at worst a dummy do-nothign one is returned
|
||||
|
||||
end Alire.Platform;
|
||||
@@ -0,0 +1,44 @@
|
||||
with Alire.Dependencies.Vectors;
|
||||
with Alire.Properties;
|
||||
|
||||
package Alire.Properties.Dependencies with Preelaborate is
|
||||
|
||||
type Availability_Checker is new Property with private;
|
||||
|
||||
type Checker_Function is access function (Dependencies : Alire.Dependencies.Vectors.Vector)
|
||||
return Boolean;
|
||||
-- The platform-bound function that says if a dependency is available
|
||||
-- Currently, Alr.Query.Is_Resolvable
|
||||
|
||||
function New_Property (Checker : Checker_Function;
|
||||
Props : Properties.Vector) return Vector;
|
||||
|
||||
function Checker (This : Availability_Checker) return Checker_Function;
|
||||
|
||||
function Properties (This : Availability_Checker) return Properties.Vector;
|
||||
-- Contained platform properties
|
||||
|
||||
private
|
||||
|
||||
type Availability_Checker is new Property with record
|
||||
Checker : Checker_Function; -- Needed to check resolution
|
||||
Properties : Alire.Properties.Vector; -- Needed to materialize the conditional dependencies
|
||||
end record;
|
||||
|
||||
overriding function Image (This : Availability_Checker) return String is
|
||||
("Availability_Resolver");
|
||||
|
||||
function New_Property (Checker : Checker_Function;
|
||||
Props : Alire.Properties.Vector) return Vector is
|
||||
(+Availability_Checker'(Checker => Checker,
|
||||
Properties => Props));
|
||||
|
||||
function Checker (This : Availability_Checker) return Checker_Function is
|
||||
(This.Checker);
|
||||
|
||||
function Properties (This : Availability_Checker) return Alire.Properties.Vector is
|
||||
(This.Properties);
|
||||
|
||||
-- FIXME currently there is no recursivity detection so mutually dependent packages will enter infinite loop
|
||||
|
||||
end Alire.Properties.Dependencies;
|
||||
Reference in New Issue
Block a user