From fe928371558faf9f2f39591335cd2374f3b0a4f5 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sun, 11 Mar 2018 23:14:17 +0100 Subject: [PATCH] Fixed master index building --- deps/semver | 2 +- index/alire-index-alire.ads | 109 ++++++++++++++++++------------------ index/alire-index-hello.ads | 2 +- src/alire-index.adb | 24 ++++---- src/alire-index.ads | 15 ++++- 5 files changed, 82 insertions(+), 70 deletions(-) diff --git a/deps/semver b/deps/semver index cae9a676..2937c650 160000 --- a/deps/semver +++ b/deps/semver @@ -1 +1 @@ -Subproject commit cae9a67626c6546e358eb46e97b04b905d63923b +Subproject commit 2937c650511ad3c87af64be963eca7eba7aebb68 diff --git a/index/alire-index-alire.ads b/index/alire-index-alire.ads index f897e2c0..a4099f9f 100644 --- a/index/alire-index-alire.ads +++ b/index/alire-index-alire.ads @@ -23,68 +23,69 @@ package Alire.Index.Alire is Windows_100 : Catalog_Entry; -- A few fake release to spice descriptions a bit up. - Syntax_Example : constant Release := Example_Project.Register - (V ("1.0.0"), - Origins.New_Filesystem ("/alire"), - Dependencies => - Half_Life_3.Current and -- unconditional - On_Condition -- conditional - (Operating_System = GNU_Linux, - When_True => Elite_Dangerous >= "2.0" and Star_Citizen >= V ("3.0"), -- Wish... - When_False => Windows_100 > V ("1.0")) and - When_Available -- Chained preferences - (Preferred => Within_Major (Alire.Project, V ("1.0")), -- as function - Otherwise => Alire.Project.Within_Major (V ("0.0"))) and -- or dot notation - When_Available -- Chained preferences - (Preferred => Alire.Project.Within_Major ("2.0"), - Otherwise => When_Available -- Chained preferences multi-level - (Preferred => Within_Major (Alire.Project, V ("1.0")), - Otherwise => Alire.Project.Within_Major ("0.5"))), -- V () is optional + Syntax_Example : constant Release := + Example_Project.Register + (V ("1.0.0"), + Origins.New_Filesystem ("/alire"), + Dependencies => + Half_Life_3.Current and -- unconditional + On_Condition -- conditional + (Operating_System = GNU_Linux, + When_True => Elite_Dangerous >= "2.0" and Star_Citizen >= V ("3.0"), -- Wish... + When_False => Windows_100 > V ("1.0")) and + When_Available -- Chained preferences + (Preferred => Within_Major (Alire.Project, V ("1.0")), -- as function + Otherwise => Alire.Project.Within_Major (V ("0.0"))) and -- or dot notation + When_Available -- Chained preferences + (Preferred => Alire.Project.Within_Major ("2.0"), + Otherwise => When_Available -- Chained preferences multi-level + (Preferred => Within_Major (Alire.Project, V ("1.0")), + Otherwise => Alire.Project.Within_Major ("0.5"))), -- V () is optional - Private_Properties => -- These are only interesting to alr, not users - GPR_External ("Profile", "False"), - -- Sample extra params for build + Private_Properties => -- These are only interesting to alr, not users + GPR_External ("Profile", "False"), + -- Sample extra params for build - Properties => - GPR_Scenario ("Build", "Debug" or "Release") and - GPR_Free_Scenario ("Path_To_Something") and - -- Known scenario variables + Properties => + GPR_Scenario ("Build", "Debug" or "Release") and + GPR_Free_Scenario ("Path_To_Something") and + -- Known scenario variables - GPR_File ("scenarios/catastrophical.gpr") and - -- Way to specify a project file not named like the project - -- Path separators are always "/" and internally converted to native ones + GPR_File ("scenarios/catastrophical.gpr") and + -- Way to specify a project file not named like the project + -- Path separators are always "/" and internally converted to native ones - On_Condition - (Operating_System = Windows, - GPR_File ("project_win.gpr")) and - On_Condition - (Operating_System = GNU_Linux, - On_Condition (Distribution = Ubuntu, -- Nested conditions - GPR_File ("project_ubuntu.gpr"))) and - -- Conditional project file + On_Condition + (Operating_System = Windows, + GPR_File ("project_win.gpr")) and + On_Condition + (Operating_System = GNU_Linux, + On_Condition (Distribution = Ubuntu, -- Nested conditions + GPR_File ("project_ubuntu.gpr"))) and + -- Conditional project file - On_Condition - (Operating_System = GNU_Linux, - Comment ("Long life the penguin")) and - -- Conditions on operating system + On_Condition + (Operating_System = GNU_Linux, + Comment ("Long life the penguin")) and + -- Conditions on operating system - On_Condition - (Compiler = GNAT_Unknown, -- /= also works - Comment ("Never saw that compiler") and Comment ("But I would like to")) and - -- Conditions on compiler version + On_Condition + (Compiler = GNAT_Unknown, -- /= also works + Comment ("Never saw that compiler") and Comment ("But I would like to")) and + -- Conditions on compiler version - On_Condition - (Distro_Release = Ubuntu_Artful, - When_True => Comment ("Living on the edge"), - When_False => Comment ("I am a rock")) and - -- Conditions on distribution release + On_Condition + (Distro_Release = Ubuntu_Artful, + When_True => Comment ("Living on the edge"), + When_False => Comment ("I am a rock")) and + -- Conditions on distribution release - Comment ("Tell me about your mother") and - Website ("http://www.www.www"), - -- Unconditional properties + Comment ("Tell me about your mother") and + Website ("http://www.www.www"), + -- Unconditional properties - Available_When => -- Impossible mix - (Operating_System = Windows and Operating_System /= GNU_Linux) or - (Compiler = GNAT_Unknown and Compiler /= GNAT_Unknown)); + Available_When => -- Impossible mix + (Operating_System = Windows and Operating_System /= GNU_Linux) or + (Compiler = GNAT_Unknown and Compiler /= GNAT_Unknown)); end Alire.Index.Alire; diff --git a/index/alire-index-hello.ads b/index/alire-index-hello.ads index 7da47bfb..9318bd78 100644 --- a/index/alire-index-hello.ads +++ b/index/alire-index-hello.ads @@ -2,7 +2,7 @@ with Alire.Index.Libhello; package Alire.Index.Hello is - function Project is new Catalogued_Project (Projects.LibHello); + function Project is new Catalogued_Project (Projects.Hello); Repo : constant URL := "https://bitbucket.org/aleteolabs/hello.git"; diff --git a/src/alire-index.adb b/src/alire-index.adb index a55948a4..2eb8a23c 100644 --- a/src/alire-index.adb +++ b/src/alire-index.adb @@ -15,17 +15,7 @@ package body Alire.Index is -- Catalogued_Project -- ------------------------ - function Catalogued_Project return Catalog_Entry is - begin - return C : constant Catalog_Entry := (Name, Parent) do - if Master_Entries.Contains (Name) then - Trace.Error ("Duplicate master project registration"); - raise Constraint_Error with "Duplicate project master entry"; - else - Master_Entries.Insert (Name, C); - end if; - end return; - end Catalogued_Project; + function Catalogued_Project return Catalog_Entry is (Name, Parent); ------------- -- Current -- @@ -47,7 +37,14 @@ package body Alire.Index is --------- function Get (Name : Projects.Names) return Catalog_Entry is - (Master_Entries.Element (Name)); + (Master_Entries.Element (Name)); + + -------------------------- + -- Is_Currently_Indexed -- + -------------------------- + + function Is_Currently_Indexed (Name : Projects.Names) return Boolean is + (Master_Entries.Contains (Name)); ------------ -- Exists -- @@ -115,6 +112,9 @@ package body Alire.Index is pragma Unreferenced (XXXXXXXXXXXXXX); use all type Alire.Properties.Labeled.Labels; begin + Master_Entries.Include (Project.Name, Project); + -- Only once would be optimal, but we cannot do that any other way I can think of + return Rel : constant Alire.Releases.Release := Alire.Releases.New_Release (Project.Name, Version, diff --git a/src/alire-index.ads b/src/alire-index.ads index 52903128..995b0773 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -47,6 +47,9 @@ package Alire.Index is function Callable_String (C : Catalog_Entry) return String; -- Returns Name.Project, for master projects -- Returns Parent.Subproject_Name, for subprojects + + function Package_Name (C : Catalog_Entry) return String; + -- Returns the unique part only, e.g. Alr for Alire.Index.Alr ----------------- -- Index types -- @@ -90,6 +93,9 @@ package Alire.Index is -- BASIC QUERIES -- --------------------- + function Is_Currently_Indexed (Name : Projects.Names) return Boolean; + -- It will depend on the compilation scope + function Current (C : Catalog_Entry) return Release; -- Get newest release of C project @@ -289,8 +295,13 @@ private function Callable_String (C : Catalog_Entry) return String is (if C.Parent = C.Name - then Utils.To_Mixed_Case (Projects.Image (C.Name) & ".Project") - else Utils.To_Mixed_Case (Projects.Image (C.Parent) & ".Subproject_" & Image (C.Name))); + then Utils.To_Mixed_Case (C.Package_Name & ".Project") + else Utils.To_Mixed_Case (C.Package_Name & ".Subproject_" & Image (C.Name))); + + function Package_Name (C : Catalog_Entry) return String is + (if C.Parent = C.Name + then Utils.To_Mixed_Case (Projects.Image (C.Name)) + else Utils.To_Mixed_Case (Projects.Image (C.Parent))); function Current (C : Catalog_Entry) return Conditional.Dependencies is (Conditional.New_Dependency (C.Name, Semver.Any));