Implementation of Provides/Renaming in Release

Closes #34
This commit is contained in:
Alejandro R Mosteo
2018-05-11 11:54:12 +02:00
parent 9620102b7a
commit 315cf596e6
9 changed files with 107 additions and 23 deletions
+12 -6
View File
@@ -20,6 +20,9 @@ package body Alire.Containers is
return Result : Release_Map := Dst do
for E of Src loop
Result.Insert (E.Project, E);
if E.Project /= E.Provides then
Result.Insert (E.Provides, E);
end if;
end loop;
end return;
end Inserting;
@@ -55,14 +58,17 @@ package body Alire.Containers is
function To_Dependencies (Map : Release_Map) return Conditional.Dependencies is
use Conditional.For_Dependencies;
use Project_Release_Maps;
begin
return Deps : Conditional.Dependencies do
for R of Map loop
Deps :=
Deps and
Conditional.New_Dependency
(R.Project,
Semantic_Versioning.Exactly (R.Version));
for I in Map.Iterate loop
if Key (I) = Map (I).Provides then -- Avoid duplicates
Deps :=
Deps and
Conditional.New_Dependency
(Map (I).Project,
Semantic_Versioning.Exactly (Map (I).Version));
end if;
end loop;
end return;
end To_Dependencies;
+3 -7
View File
@@ -30,11 +30,6 @@ package Alire.Containers with Preelaborate is
Releases."=");
subtype Release_H is Release_Holders.Holder;
package Project_Description_Maps is new Ada.Containers.Indefinite_Ordered_Maps
(Alire.Project, Description_String);
package Project_Version_Maps is new Ada.Containers.Indefinite_Ordered_Maps
(Alire.Project, Semantic_Versioning.Version, "<", Semantic_Versioning."<");
subtype Version_Map is Project_Version_Maps.Map;
@@ -51,12 +46,13 @@ package Alire.Containers with Preelaborate is
procedure Insert (Dst : in out Release_Map; Src : Release_Map);
function Inserting (Dst : Release_Map; Src : Release_Map) return Release_Map;
function Inserting (Dst : Release_Map; Src : Release_Map) return Release_Map;
function Inserting (Dst : Release_Map; Src : Releases.release) return Release_Map;
-- Those insert both under the actual project name and Provides, if different
function To_Dependencies (Map : Release_Map)
return Conditional.Dependencies;
-- Will filter out duplicates under Provides key (only actual projects will remain)
function To_Map (R : Releases.Release) return Release_Map;
-2
View File
@@ -1,7 +1,5 @@
with Ada.Containers.Indefinite_Ordered_Maps;
with Alire.Projects;
with GNAT.Source_Info;
package body Alire.Index is
+6 -2
View File
@@ -9,6 +9,7 @@ with Alire.GPR;
with Alire.Licensing;
with Alire.Origins;
with Alire.Platforms;
with Alire.Projects;
with Alire.Properties;
with Alire.Properties.Labeled;
with Alire.Properties.Licenses;
@@ -32,7 +33,7 @@ package Alire.Index is
Catalog : Containers.Release_Set;
type Catalog_Entry (<>) is new Versions.Comparable with private;
type Catalog_Entry (<>) is new Projects.Named and Versions.Comparable with private;
-- Used to force the declaration of a single variable to refer to a project in index specs
-- NOTE that the following generics internally use GNAT.Source_Info to
-- ascertain the package and project names.
@@ -58,6 +59,7 @@ package Alire.Index is
-- A "variant/flavor" project that resides in the same package.
-- It may either extend or override a base project
overriding
function Project (C : Catalog_Entry) return Alire.Project;
function Ada_Identifier (C : Catalog_Entry) return String;
@@ -354,7 +356,9 @@ package Alire.Index is
private
type Catalog_Entry (Name_Len, Descr_Len, Pack_Len, Self_Len : Natural) is new Versions.Comparable with record
type Catalog_Entry (Name_Len, Descr_Len, Pack_Len, Self_Len : Natural) is new
Projects.Named and Versions.Comparable with
record
Project : Alire.Project (1 .. Name_Len);
Description : Description_String (1 .. Descr_Len);
Package_Name : String (1 .. Pack_Len);
+9 -2
View File
@@ -1,8 +1,15 @@
with Alire.Containers;
with Ada.Containers.Indefinite_Ordered_Maps;
package Alire.Projects with Preelaborate is
Descriptions : Containers.Project_Description_Maps.Map;
package Project_Description_Maps is new Ada.Containers.Indefinite_Ordered_Maps
(Alire.Project, Description_String);
Descriptions : Project_Description_Maps.Map;
-- Master list of known projects & descriptions
type Named is limited interface;
function Project (N : Named) return Alire.Project is abstract;
end Alire.Projects;
+27 -1
View File
@@ -1,6 +1,5 @@
-- with Alire.Platform;
with Alire.Platforms;
with Alire.Projects;
with Alire.Requisites.Booleans;
with GNAT.IO; -- To keep preelaborable
@@ -42,6 +41,30 @@ package body Alire.Releases is
end return;
end Extending;
--------------
-- Renaming --
--------------
function Renaming (Base : Release;
Provides : Alire.Project) return Release is
begin
return Renamed : Release := Base do
Renamed.Alias := +(+Provides);
end return;
end Renaming;
--------------
-- Renaming --
--------------
function Renaming (Base : Release;
Provides : Projects.Named'Class) return Release is
(Base.Renaming (Provides.Project));
---------------
-- Replacing --
---------------
function Replacing (Base : Release;
Origin : Origins.Origin) return Release is
begin
@@ -72,6 +95,7 @@ package body Alire.Releases is
Project => New_Project,
Notes => New_Notes,
Alias => Base.Alias,
Version => Base.Version,
Origin => Base.Origin,
Dependencies => Base.Dependencies,
@@ -124,6 +148,7 @@ package body Alire.Releases is
(Prj_Len => Project'Length,
Notes_Len => Notes'Length,
Project => Project,
Alias => +"",
Version => Version,
Origin => Origin,
Notes => Notes,
@@ -369,6 +394,7 @@ package body Alire.Releases is
(Prj_Len => R.Prj_Len,
Notes_Len => R.Notes_Len,
Project => R.Project,
Alias => R.Alias,
Version => R.Version,
Origin => R.Origin,
Notes => R.Notes,
+23 -3
View File
@@ -5,6 +5,7 @@ with Alire.Conditional;
with Alire.Dependencies;
with Alire.Milestones;
with Alire.Origins;
with Alire.Projects;
with Alire.Properties;
with Alire.Properties.Labeled;
with Alire.Requisites;
@@ -39,7 +40,15 @@ package Alire.Releases with Preelaborate is
Available : Alire.Requisites.Tree := Requisites.Trees.Empty_Tree)
return Release;
-- Takes a release and merges given fields
function Renaming (Base : Release;
Provides : Alire.Project) return Release;
function Renaming (Base : Release;
Provides : Projects.Named'Class) return Release;
-- Fills-in the "provides" field
-- During resolution, a project that has a renaming will act as the
-- "Provides" project, so both projects cannot be selected simultaneously.
function Replacing (Base : Release;
Project : Alire.Project := "";
@@ -69,6 +78,10 @@ package Alire.Releases with Preelaborate is
function Project_Base (R : Release) return String;
-- Project up to first dot, if any; which is needed for extension projects in templates and so on
function Provides (R : Release) return Alire.Project;
-- The actual project name to be used during dependency resolution
-- (But nowhere else)
function Is_Extension (R : Release) return Boolean;
function Notes (R : Release) return Description_String; -- Specific to release
@@ -154,8 +167,10 @@ private
function Comment is new Alire.Properties.Labeled.Cond_New_Label (Alire.Properties.Labeled.Comment);
function Describe is new Alire.Properties.Labeled.Cond_New_Label (Alire.Properties.Labeled.Description);
type Release (Prj_Len, Notes_Len : Natural) is new Versions.Versioned with record
type Release (Prj_Len,
Notes_Len : Natural) is new Versions.Versioned with record
Project : Alire.Project (1 .. Prj_Len);
Alias : Ustring; -- I finally gave up on constraints
Version : Semantic_Versioning.Version;
Origin : Origins.Origin;
Notes : Description_String (1 .. Notes_Len);
@@ -183,7 +198,12 @@ private
overriding function Project (R : Release) return Alire.Project is (R.Project);
function Project_Base (R : Release) return String is
(Utils.Head (+R.Project, Extension_Separator));
(Utils.Head (+R.Project, Extension_Separator));
function Provides (R : Release) return Alire.Project is
((if Ustrings.Length (R.Alias) = 0
then R.Project
else +(+R.Alias)));
function Notes (R : Release) return Description_String is (R.Notes);
+12
View File
@@ -1,3 +1,6 @@
-- with Ada.Strings.Bounded;
with Ada.Strings.Unbounded;
with Simple_Logging;
package Alire with Preelaborate is
@@ -11,11 +14,20 @@ package Alire with Preelaborate is
Max_Name_Length : constant := 72; -- Github maximum is 100 and bitbucket 128, but since Description is 72...
Max_Description_Length : constant := 72; -- Git line recommendation (although it's 50 for subject line)
-- package BStrings is new Ada.Strings.Bounded.Generic_Bounded_Length
-- (Integer'Max (Max_Name_Length, Max_Description_Length));
Extension_Separator : constant Character := '.';
-- Refers to extension releases! Nothing to do with files
-- Strings that are used quite generally
package UStrings renames Ada.Strings.Unbounded;
subtype UString is Ada.Strings.Unbounded.Unbounded_String;
function "+" (S : String) return UString renames UStrings.To_Unbounded_String;
function "+" (S : UString) return String renames UStrings.To_String;
type Project is new String with Dynamic_Predicate =>
Project'Length >= Min_Name_Length and then
Project (Project'First) /= '_' and then