diff --git a/deps/semver b/deps/semver index 71653bab..3480c761 160000 --- a/deps/semver +++ b/deps/semver @@ -1 +1 @@ -Subproject commit 71653babaab97d835ecd22edb562b9b529dd8948 +Subproject commit 3480c76110b1a40b3dbb189f6ac5020bf22d644a diff --git a/index/alire-index-adayaml.ads b/index/alire-index-adayaml.ads index cc95890a..0c8350a8 100644 --- a/index/alire-index-adayaml.ads +++ b/index/alire-index-adayaml.ads @@ -10,57 +10,44 @@ package Alire.Index.AdaYaml is Prj_Author : constant String := "Felix Krause"; Prj_Website : constant URL := "https://ada.yaml.io/"; - V_0_2 : constant Release := - Project.Register - (V ("0.2"), - Git (Prj_Repo, "0264b03fd92eeedfe3e2713ed1da3f0d255c1727"), + Base : constant Release := + Project.Unreleased + (Dependencies => + AUnit.Project >= AUnit.V_2017, - Dependencies => - AUnit.Project >= AUnit.V_2017, + Properties => + Project_File ("yaml.gpr") and + Project_File ("yaml-utils.gpr") and - Properties => - Project_File ("yaml.gpr") and - Project_File ("yaml-utils.gpr") and + GPR_Scenario ("Mode", "debug" or "release") and - GPR_Scenario ("Mode", "debug" or "release") and + Author (Prj_Author) and + Website (Prj_Website) and + License (MIT), - Author (Prj_Author) and - Website (Prj_Website) and - License (MIT), + Private_Properties => + Project_File ("yaml-tests.gpr")); + package V_0_3 is new Released + (Base + .Replacing (Git (Prj_Repo, "2017a7c2523499c03b8d7fe06546a5a8bae6476d")) + .Extending (Properties => + Project_File ("yaml-annotation_processor.gpr"), Private_Properties => - Project_File ("yaml-tests.gpr") and + Executable ("yaml-dumping_tests-harness") and + Executable ("yaml-loading_tests-harness") and + Executable ("yaml-transformation_tests-harness"))); + package V_0_2 is new Released + (Base + .Replacing (Git (Prj_Repo, "0264b03fd92eeedfe3e2713ed1da3f0d255c1727")) + .Extending (Private_Properties => Executable ("yaml-lexer-harness") and - Executable ("yaml-parser-harness") - ); + Executable ("yaml-parser-harness"))); - V_0_3 : constant Release := - Project.Register - (V ("0.3"), - Git (Prj_Repo, "2017a7c2523499c03b8d7fe06546a5a8bae6476d"), - - Dependencies => - AUnit.Project >= AUnit.V_2017, - - Properties => - Project_File ("yaml.gpr") and - Project_File ("yaml-annotation_processor.gpr") and - Project_File ("yaml-utils.gpr") and - - GPR_Scenario ("Mode", "debug" or "release") and - - Author (Prj_Author) and - Website (Prj_Website) and - License (MIT), - - Private_Properties => - Project_File ("yaml-tests.gpr") and - - Executable ("yaml-dumping_tests-harness") and - Executable ("yaml-loading_tests-harness") and - Executable ("yaml-transformation_tests-harness") - ); + ------------ + -- Server -- + ------------ package Server is @@ -69,7 +56,7 @@ package Alire.Index.AdaYaml is V_0_3 : constant Release := Project.Register - (AdaYaml.V_0_3 + (AdaYaml.V_0_3.Release .Extending (Properties => Project_File ("yaml-server.gpr") and diff --git a/index/alire-index-alr.ads b/index/alire-index-alr.ads index 8af9be05..e8d9d981 100644 --- a/index/alire-index-alr.ads +++ b/index/alire-index-alr.ads @@ -9,7 +9,7 @@ package Alire.Index.Alr is Repo : constant URL := "https://github.com/alire-project/alr.git"; - V_0 : constant Release := + Base : constant Release := Project.Unreleased (Dependencies => Simple_Logging.V_1_0.Within_Major, @@ -20,7 +20,7 @@ package Alire.Index.Alr is V_0_4 : constant Release := Project.Register - (V_0 + (Base .Upgrading (V ("0.4"), Git (Repo, "721d111225cf30b9c298ff23587664510f4c4ea1")) @@ -31,7 +31,7 @@ package Alire.Index.Alr is V_0_2 : constant Release := Project.Register - (V_0 + (Base .Upgrading (V ("0.2"), Git (Repo, "481a22aceb07242cabaefedbb41b2d6fe7a8bd1e")) @@ -41,7 +41,7 @@ package Alire.Index.Alr is V_0_1_2 : constant Release := Project.Register - (V_0 + (Base .Upgrading (V ("0.1.2"), Git (Repo, "4002536beea8aee12b455077df4dd144b409bde4")) diff --git a/src/alire-index.adb b/src/alire-index.adb index 99fca0f1..24358bf3 100644 --- a/src/alire-index.adb +++ b/src/alire-index.adb @@ -245,4 +245,37 @@ package body Alire.Index is Available => Available_When); end Unreleased; + ----------------- + -- New_Release -- + ----------------- + + package body Released is + + The_Release : constant Index.Release := + Project.Register -- Add to catalog + (Base.Retagging -- Overriding the version + (Versions.From_Identifier -- with the one in the + (Identify -- package name + (GNAT.Source_Info.Enclosing_Entity).Identifier))); + + ------------- + -- Release -- + ------------- + + function Release return Index.Release is + begin + return The_Release; + end Release; + + function This_Version return Conditional.Dependencies is + (The_Release.This_Version); + + function Within_Major return Conditional.Dependencies is + (The_Release.Within_Major); + + function Within_Minor return Conditional.Dependencies is + (The_Release.Within_Minor); + + end Released; + end Alire.Index; diff --git a/src/alire-index.ads b/src/alire-index.ads index 385ffeaa..4d11f03d 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -122,7 +122,20 @@ package Alire.Index is ------------------------------------------------------------------ -- NEW INDEXING FACILITIES USING Enclosing_Entity for the version - ------------------------------------------------------------------ + generic + Base : Release; + with function Project return Catalog_Entry is <>; + package Released is + + function Release return Index.Release; + + function This_Version return Conditional.Dependencies; + function Within_Major return Conditional.Dependencies; + function Within_Minor return Conditional.Dependencies; + + end Released; + + ------------------------------------------------------------------ --------------------- -- BASIC QUERIES -- diff --git a/src/alire-releases.adb b/src/alire-releases.adb index bebd2282..dea2a30b 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -83,6 +83,18 @@ package body Alire.Releases is end return; end Replacing; + --------------- + -- Retagging -- + --------------- + + function Retagging (Base : Release; + Version : Semantic_Versioning.Version) return Release is + begin + return Upgraded : Release := Base do + Upgraded.Version := Version; + end return; + end Retagging; + --------------- -- Upgrading -- --------------- diff --git a/src/alire-releases.ads b/src/alire-releases.ads index 389b8996..2f112173 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -48,7 +48,11 @@ package Alire.Releases with Preelaborate is -- Takes a release and replaces the given fields function Replacing (Base : Release; - Origin : Origins.Origin) return Release; + Origin : Origins.Origin) return Release; + + function Retagging (Base : Release; + Version : Semantic_Versioning.Version) return Release; + -- Keep all data but version function Upgrading (Base : Release; Version : Semantic_Versioning.Version; diff --git a/src/alire-versions.adb b/src/alire-versions.adb new file mode 100644 index 00000000..7b043296 --- /dev/null +++ b/src/alire-versions.adb @@ -0,0 +1,60 @@ +with Ada.Characters.Handling; + +package body Alire.Versions is + + --------------------- + -- From_Identifier -- + --------------------- + + function From_Identifier (S : String) return Semantic_Versioning.Version is + + ----------- + -- Error -- + ----------- + + procedure Error is + begin + Trace.Error ("Given identifier cannot be a version: " & S); + raise Constraint_Error; + end Error; + + use Ada.Characters.Handling; + Img : String := S; + First : Positive := Img'First; + Seen : Natural := 0; + begin + if Img'Length < 2 then + Error; + end if; + + -- Skip leading text + while First <= Img'Last and then Is_Letter (Img (First)) loop + First := First + 1; + end loop; + + if First > Img'Last then + Error; + end if; + + -- Skip optional underscore + if Img (First) = '_' then + First := First + 1; + end if; + + -- Convert remaining underscores to proper symbol: + for I in First + 1 .. Img'Last loop + if S (I) = '_' then + Seen := Seen + 1; + case Seen is + when 1 .. 2 => Img (I) := '.'; + when 3 => Img (I) := '-'; + when 4 => Img (I) := '+'; + when others => exit; + end case; + end if; + end loop; + + return Semantic_Versioning.Relaxed (Img (First .. S'Last)); + end From_Identifier; + +end Alire.Versions; diff --git a/src/alire-versions.ads b/src/alire-versions.ads index fdfe038a..341aa54f 100644 --- a/src/alire-versions.ads +++ b/src/alire-versions.ads @@ -35,6 +35,16 @@ package Alire.Versions with Preelaborate is package Expressions_With_Versioned is new Expressions.Against (Versioned'Class, Version_Classwide); + -- Utils dealing with versions + + function From_Identifier (S : String) return Semantic_Versioning.Version; + -- Convert an Ada Identifier into a version + -- This is used by the package releases in Index to autodetect the version + -- and avoid duplication + -- EXAMPLES OF VALID IDENTIFIERS: + -- V1_2_3_Prerelease_Build + -- V_1_2_3 + private use Semantic_Versioning;