diff --git a/index/alire-index-gnatcoll.ads b/index/alire-index-gnatcoll.ads index 66d626da..31e65826 100644 --- a/index/alire-index-gnatcoll.ads +++ b/index/alire-index-gnatcoll.ads @@ -43,6 +43,7 @@ package Alire.Index.GNATCOLL is package V_20180425 is new Project_Release (Base + .Renaming (GNATCOLL.Project) .Replacing (Git (Repo_Alire, "81bc37d7548fe40024eb0f647df65ec42f65443b"))); @@ -55,9 +56,23 @@ package Alire.Index.GNATCOLL is package V_20180425 is new Project_Release (Base + .Renaming (GNATCOLL.Project) .Replacing (Git (Repo_Alire, "7823e31add7133b9fbc6e037d9986a823e840dc0"))); end Strings; +-- package Test is +-- +-- function Project is new Catalogued_Project +-- ("GNAT Components Collection - Testing renames"); +-- +-- package V_99999999 is new Project_Release +-- (Base +-- .Extending +-- (Dependencies => +-- Slim.Project.Current)); +-- +-- end Test; + end Alire.Index.GNATCOLL; diff --git a/src/alire-containers.adb b/src/alire-containers.adb index ae826904..b116e31a 100644 --- a/src/alire-containers.adb +++ b/src/alire-containers.adb @@ -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; diff --git a/src/alire-containers.ads b/src/alire-containers.ads index 31135b9b..707729c9 100644 --- a/src/alire-containers.ads +++ b/src/alire-containers.ads @@ -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; diff --git a/src/alire-index.adb b/src/alire-index.adb index 8ce3863d..f128394f 100644 --- a/src/alire-index.adb +++ b/src/alire-index.adb @@ -1,7 +1,5 @@ with Ada.Containers.Indefinite_Ordered_Maps; -with Alire.Projects; - with GNAT.Source_Info; package body Alire.Index is diff --git a/src/alire-index.ads b/src/alire-index.ads index 6ba21da6..0439c1a8 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -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); diff --git a/src/alire-projects.ads b/src/alire-projects.ads index 2125e82c..83adae51 100644 --- a/src/alire-projects.ads +++ b/src/alire-projects.ads @@ -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; diff --git a/src/alire-releases.adb b/src/alire-releases.adb index 1d6dce0a..d33ed26f 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -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, diff --git a/src/alire-releases.ads b/src/alire-releases.ads index 6a7632e1..e4c4325f 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -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); diff --git a/src/alire.ads b/src/alire.ads index deae4074..0dc2042f 100644 --- a/src/alire.ads +++ b/src/alire.ads @@ -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