Query by name and version set, release report
This commit is contained in:
Vendored
+1
-1
Submodule deps/semver updated: 9f35b00a31...c25fb63017
@@ -9,6 +9,9 @@ package Alire.Index.RxAda is
|
||||
Register (Name,
|
||||
V ("0.1.0"),
|
||||
Desc,
|
||||
Hg (Repo, "361d4e2ab20a7dcca007e31bf7094d57b13fee6b"));
|
||||
Hg (Repo, "361d4e2ab20a7dcca007e31bf7094d57b13fee6b"),
|
||||
Properties =>
|
||||
Maintainer ("alejandro@mosteo.com") and
|
||||
Website (Repo));
|
||||
|
||||
end Alire.Index.RxAda;
|
||||
|
||||
@@ -7,8 +7,8 @@ package Alire.Index.Semantic_Versioning is
|
||||
|
||||
Latest : constant Release :=
|
||||
Register (Name,
|
||||
V ("0.1.0"),
|
||||
V ("0.1.1"),
|
||||
Desc,
|
||||
Git (Repo, "9f35b00a31861ea96085ee553fb6335d74831f5c"));
|
||||
Git (Repo, "c25fb63017b098e8c696f9530e1128fb33948fd5"));
|
||||
|
||||
end Alire.Index.Semantic_Versioning;
|
||||
|
||||
@@ -15,6 +15,7 @@ package Alire.Dependencies with Preelaborate is
|
||||
|
||||
function Versions (Dep : Dependency) return Semantic_Versioning.Version_Set;
|
||||
|
||||
function Image (Dep : Dependency) return String;
|
||||
|
||||
private
|
||||
|
||||
@@ -39,4 +40,7 @@ private
|
||||
function Versions (Dep : Dependency) return Semantic_Versioning.Version_Set is
|
||||
(Dep.Versions_H.Element);
|
||||
|
||||
function Image (Dep : Dependency) return String is
|
||||
(Dep.Project & " ver " & Semantic_Versioning.Image (Dep.Versions_H.Element));
|
||||
|
||||
end Alire.Dependencies;
|
||||
|
||||
@@ -6,6 +6,7 @@ with Alire.Dependencies.Vectors;
|
||||
with Alire.Operating_Systems;
|
||||
with Alire.Origins;
|
||||
with Alire.Properties;
|
||||
with Alire.Properties.Labeled;
|
||||
with Alire.Releases;
|
||||
with Alire.Requisites;
|
||||
with Alire.Requisites.Platform;
|
||||
@@ -82,6 +83,10 @@ package Alire.Index is
|
||||
|
||||
-- Shortcuts for properties/requisites:
|
||||
|
||||
-- "Typed" attributes (named pairs of label-value)
|
||||
function Maintainer is new Properties.Labeled.Generic_New_Label (Properties.Labeled.Maintainer);
|
||||
function Website is new Properties.Labeled.Generic_New_Label (Properties.Labeled.Website);
|
||||
|
||||
use all type Alire.Dependencies.Vectors.Vector;
|
||||
use all type Compilers.Compilers;
|
||||
use all type Operating_Systems.Operating_Systems;
|
||||
|
||||
+12
-1
@@ -40,6 +40,8 @@ package Alire.Origins with Preelaborate is
|
||||
|
||||
function New_Apt (Id_As_Package_Name : String) return Origin;
|
||||
|
||||
function Image (This : Origin) return String;
|
||||
|
||||
private
|
||||
|
||||
use Ada.Strings.Unbounded;
|
||||
@@ -70,7 +72,7 @@ private
|
||||
To_Unbounded_String (Id));
|
||||
|
||||
function New_Apt (Id_As_Package_Name : String) return Origin is
|
||||
(Filesystem,
|
||||
(Apt,
|
||||
To_Unbounded_String (Id_As_Package_Name),
|
||||
Null_Unbounded_String);
|
||||
|
||||
@@ -80,4 +82,13 @@ private
|
||||
|
||||
function Id (This : Origin) return String is (To_String (This.Id));
|
||||
|
||||
function S (Str : Unbounded_String) return String is (To_String (Str));
|
||||
|
||||
function Image (This : Origin) return String is
|
||||
(case This.Kind is
|
||||
when Git | Hg => "commit " & S (This.Id) & " from " & S (This.URL),
|
||||
when Apt => "package " & S (This.Id) & " from native package manager (apt)",
|
||||
when Filesystem => "path " & S (This.Id));
|
||||
|
||||
|
||||
end Alire.Origins;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
private with Alire.Utils;
|
||||
|
||||
package Alire.Properties.Labeled with Preelaborate is
|
||||
|
||||
-- Properties that have a single string value and a name
|
||||
|
||||
type Labels is (Maintainer,
|
||||
Website);
|
||||
|
||||
type Label (<>) is new Properties.Property with private;
|
||||
|
||||
function New_Label (Name : Labels; Value : String) return Label;
|
||||
|
||||
function Name (L : Label) return Labels;
|
||||
|
||||
function Value (L : Label) return String;
|
||||
|
||||
overriding function Image (L : Label) return String;
|
||||
|
||||
generic
|
||||
Name : Labels;
|
||||
function Generic_New_Label (Value : String) return Label;
|
||||
-- Returns a vector so its directly usable during indexing
|
||||
|
||||
|
||||
private
|
||||
|
||||
type Label (Length : Natural) is new Properties.Property with record
|
||||
Name : Labels;
|
||||
Value : String (1 .. Length);
|
||||
end record;
|
||||
|
||||
function New_Label (Name : Labels; Value : String) return Label is
|
||||
(Properties.Property with Value'Length, Name, Value);
|
||||
|
||||
function Name (L : Label) return Labels is (L.Name);
|
||||
|
||||
function Value (L : Label) return String is (L.Value);
|
||||
|
||||
function Generic_New_Label (Value : String) return Label is (New_Label (Name, Value));
|
||||
|
||||
overriding function Image (L : Label) return String is (Utils.To_Mixed_Case (L.Name'Img & ": " & L.Value));
|
||||
|
||||
end Alire.Properties.Labeled;
|
||||
@@ -3,8 +3,10 @@ with Alire.Operating_Systems;
|
||||
|
||||
package Alire.Properties.Platform with Preelaborate is
|
||||
|
||||
package Compilers is new Values (Alire.Compilers.Compilers);
|
||||
package Operating_Systems is new Values (Alire.Operating_Systems.Operating_Systems);
|
||||
package Compilers is new Values (Alire.Compilers.Compilers,
|
||||
Alire.Compilers.Compilers'IMage);
|
||||
package Operating_Systems is new Values (Alire.Operating_Systems.Operating_Systems,
|
||||
Alire.Operating_Systems.Operating_Systems'Image);
|
||||
|
||||
function Current return Properties.Vector;
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ package Alire.Properties with Preelaborate is
|
||||
|
||||
type Property is interface;
|
||||
|
||||
function Image (P : Property) return String is abstract;
|
||||
|
||||
package Vectors is new Ada.Containers.Indefinite_Vectors (Positive, Property'Class);
|
||||
|
||||
subtype Vector is Vectors.Vector;
|
||||
@@ -23,6 +25,7 @@ package Alire.Properties with Preelaborate is
|
||||
-- A generic helper to simply store/retrieve e.g. an enumerated type
|
||||
generic
|
||||
type Value is private;
|
||||
with function Image (V : Value) return String is <>;
|
||||
package Values is
|
||||
|
||||
type Property (<>) is new Properties.Property with private;
|
||||
@@ -33,6 +36,8 @@ package Alire.Properties with Preelaborate is
|
||||
|
||||
private
|
||||
|
||||
overriding function Image (P : Property) return String;
|
||||
|
||||
type Property is new Properties.Property with record
|
||||
V : Value;
|
||||
end record;
|
||||
@@ -41,6 +46,8 @@ package Alire.Properties with Preelaborate is
|
||||
|
||||
function Element (P : Property) return Value is (P.V);
|
||||
|
||||
overriding function Image (P : Property) return String is (Image (P.V));
|
||||
|
||||
end Values;
|
||||
|
||||
private
|
||||
|
||||
+48
-7
@@ -1,19 +1,36 @@
|
||||
with Alire.Dependencies;
|
||||
|
||||
with Semantic_Versioning;
|
||||
with Alire.Utils;
|
||||
|
||||
package body Alire.Query is
|
||||
|
||||
package Semver renames Semantic_Versioning;
|
||||
|
||||
use all type Semver.Version_Set;
|
||||
|
||||
----------------------
|
||||
-- Dependency_Image --
|
||||
----------------------
|
||||
|
||||
function Dependency_Image (Project : Project_Name;
|
||||
Versions : Semantic_Versioning.Version_Set;
|
||||
Policy : Policies := Newest) return String is
|
||||
(Project &
|
||||
(if Versions /= Semver.Any
|
||||
then " version " & Semver.Image (Versions)
|
||||
else " with " & Utils.To_Mixed_Case (Policy'Img) & " version"));
|
||||
|
||||
------------
|
||||
-- Exists --
|
||||
------------
|
||||
|
||||
function Exists (Project : Project_Name) return Boolean is
|
||||
function Exists (Project : Project_Name;
|
||||
Allowed : Semantic_Versioning.Version_Set := Semantic_Versioning.Any)
|
||||
return Boolean
|
||||
is
|
||||
use Semver;
|
||||
begin
|
||||
for R of Releases loop
|
||||
if R.Project = Project then
|
||||
if R.Project = Project and then Satisfies (R.Version, Allowed) then
|
||||
return True;
|
||||
end if;
|
||||
end loop;
|
||||
@@ -21,6 +38,29 @@ package body Alire.Query is
|
||||
return False;
|
||||
end Exists;
|
||||
|
||||
----------
|
||||
-- Find --
|
||||
----------
|
||||
|
||||
function Find (Project : Project_Name;
|
||||
Allowed : Semantic_Versioning.Version_Set := Semantic_Versioning.Any;
|
||||
Policy : Policies := Newest) return Release
|
||||
is
|
||||
use Semantic_Versioning;
|
||||
begin
|
||||
for R of reverse Index.Releases loop
|
||||
if R.Project = Project then
|
||||
if Satisfies (R.Version, Allowed) then
|
||||
return R;
|
||||
else
|
||||
Trace.Debug ("Skipping unsatisfactory version: " & Image (R.Version));
|
||||
end if;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
raise Query_Unsuccessful with "Release not found: " & Project;
|
||||
end Find;
|
||||
|
||||
--------------------
|
||||
-- Print_Solution --
|
||||
--------------------
|
||||
@@ -29,7 +69,7 @@ package body Alire.Query is
|
||||
use Containers.Project_Release_Maps;
|
||||
begin
|
||||
for Rel of I loop
|
||||
Log (" " & Rel.Milestone_Image, Detail);
|
||||
Log (" " & Rel.Milestone_Image, Debug);
|
||||
end loop;
|
||||
end Print_Solution;
|
||||
|
||||
@@ -61,7 +101,7 @@ package body Alire.Query is
|
||||
is
|
||||
begin
|
||||
if Unresolved.Is_Empty then
|
||||
Log ("Dependencies resolved");
|
||||
Log ("Dependencies resolved", Detail);
|
||||
Print_Solution (Frozen);
|
||||
return Frozen;
|
||||
else
|
||||
@@ -115,7 +155,8 @@ package body Alire.Query is
|
||||
-------------
|
||||
|
||||
function Resolve (Deps : Index.Dependencies;
|
||||
Success : out Boolean) return Instance is
|
||||
Success : out Boolean;
|
||||
Policy : Policies := Newest) return Instance is
|
||||
begin
|
||||
Success := False;
|
||||
|
||||
|
||||
+18
-2
@@ -1,18 +1,34 @@
|
||||
with Alire.Containers;
|
||||
with Alire.Index; use Alire.Index;
|
||||
|
||||
with Semantic_Versioning;
|
||||
|
||||
package Alire.Query is
|
||||
|
||||
type Policies is (Oldest, Newest);
|
||||
|
||||
--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 Exists (Project : Project_Name;
|
||||
Allowed : Semantic_Versioning.Version_Set := Semantic_Versioning.Any)
|
||||
return Boolean;
|
||||
|
||||
function Find (Project : Project_Name;
|
||||
Allowed : Semantic_Versioning.Version_Set := Semantic_Versioning.Any;
|
||||
Policy : Policies := Newest) return Release;
|
||||
|
||||
function Resolve (Deps : Index.Dependencies;
|
||||
Success : out Boolean) return Instance;
|
||||
Success : out Boolean;
|
||||
Policy : Policies := Newest) return Instance;
|
||||
|
||||
procedure Print_Solution (I : Instance);
|
||||
|
||||
|
||||
function Dependency_Image (Project : Project_Name;
|
||||
Versions : Semantic_Versioning.Version_Set;
|
||||
Policy : Policies := Newest) return String;
|
||||
|
||||
end Alire.Query;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
with GNAT.IO; -- To keep preelaborable
|
||||
|
||||
package body Alire.Releases is
|
||||
|
||||
-----------
|
||||
-- Print --
|
||||
-----------
|
||||
|
||||
procedure Print (R : Release) is
|
||||
use GNAT.IO;
|
||||
begin
|
||||
-- MILESTONE
|
||||
Put_Line (R.Milestone_Image & ": " & R.Description);
|
||||
|
||||
-- ORIGIN
|
||||
Put_Line ("Origin: " & R.Origin.Image);
|
||||
|
||||
-- REQUISITES
|
||||
if not R.Reqs.Is_Empty then
|
||||
Put ("Requisites: ");
|
||||
R.Reqs.Print_Skeleton;
|
||||
end if;
|
||||
|
||||
-- PROPERTIES
|
||||
if not R.Props.Is_Empty then
|
||||
Put_Line ("Properties:");
|
||||
for Prop of R.Props loop
|
||||
Put_Line (" " & Prop.Image);
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
-- DEPENDENCIES
|
||||
if not R.Depends.Is_Empty then
|
||||
Put_Line ("Dependencies (direct):");
|
||||
for Dep of R.Depends loop
|
||||
Put_Line (" " & Dep.Image);
|
||||
end loop;
|
||||
end if;
|
||||
end Print;
|
||||
|
||||
end Alire.Releases;
|
||||
@@ -39,6 +39,9 @@ package Alire.Releases with Preelaborate is
|
||||
|
||||
function Is_Native (R : Release) return Boolean;
|
||||
-- not alr packaged but from the platform
|
||||
|
||||
procedure Print (R : Release);
|
||||
-- Dump info to console
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
with GNAT.Case_Util;
|
||||
|
||||
package body Alire.Utils is
|
||||
|
||||
-------------------
|
||||
-- To_Mixed_Case --
|
||||
-------------------
|
||||
|
||||
function To_Mixed_Case (S : String) return String is
|
||||
begin
|
||||
return SMC : String := S do
|
||||
GNAT.Case_Util.To_Mixed (SMC);
|
||||
end return;
|
||||
end To_Mixed_Case;
|
||||
|
||||
end Alire.Utils;
|
||||
@@ -0,0 +1,5 @@
|
||||
package Alire.Utils with Preelaborate is
|
||||
|
||||
function To_Mixed_Case (S : String) return String;
|
||||
|
||||
end Alire.Utils;
|
||||
@@ -2,6 +2,9 @@ with Simple_Logging;
|
||||
|
||||
package Alire with Preelaborate is
|
||||
|
||||
Query_Unsuccessful : exception;
|
||||
-- Raised by subprograms that return releases/dependencies when not found/impossible
|
||||
|
||||
subtype URL is String;
|
||||
|
||||
Max_Name_Length : constant := 72; -- Github maximum is 100 and bitbucket 128, but since Description is 72...
|
||||
|
||||
Reference in New Issue
Block a user