diff --git a/src/alire-properties-labeled.ads b/src/alire-properties-labeled.ads index 7a8735f8..534d39cc 100644 --- a/src/alire-properties-labeled.ads +++ b/src/alire-properties-labeled.ads @@ -23,7 +23,6 @@ package Alire.Properties.Labeled with Preelaborate is 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 diff --git a/src/alire-query.adb b/src/alire-query.adb index f8ddc0c2..38081546 100644 --- a/src/alire-query.adb +++ b/src/alire-query.adb @@ -61,6 +61,23 @@ package body Alire.Query is raise Query_Unsuccessful with "Release not found: " & Project; end Find; + ------------ + -- Exists -- + ------------ + + function Exists (Project : Project_Name; + Version : Semantic_Versioning.Version) + return Boolean is + (Exists (Project, Semver.Exactly (Version))); + + ---------- + -- Find -- + ---------- + + function Find (Project : Project_Name; + Version : Semantic_Versioning.Version) return Release is + (Find (Project, Semver.Exactly (Version))); + -------------------- -- Print_Solution -- -------------------- diff --git a/src/alire-query.ads b/src/alire-query.ads index 9ad68eb8..ad568ca4 100644 --- a/src/alire-query.ads +++ b/src/alire-query.ads @@ -20,6 +20,13 @@ package Alire.Query is Allowed : Semantic_Versioning.Version_Set := Semantic_Versioning.Any; Policy : Policies := Newest) return Release; + function Exists (Project : Project_Name; + Version : Semantic_Versioning.Version) + return Boolean; + + function Find (Project : Project_Name; + Version : Semantic_Versioning.Version) return Release; + function Resolve (Deps : Index.Dependencies; Success : out Boolean; Policy : Policies := Newest) return Instance; diff --git a/src/alire-releases.adb b/src/alire-releases.adb index 9636d3e7..7d12dd76 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -4,9 +4,9 @@ with GNAT.IO; -- To keep preelaborable package body Alire.Releases is ------------------ --- Executables -- ------------------ + ----------------- + -- Executables -- + ---------------- function Executables (R : Release) return Utils.String_Vector is begin diff --git a/src/alire-releases.ads b/src/alire-releases.ads index 35da9fcf..a5a648bc 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -22,7 +22,7 @@ package Alire.Releases with Preelaborate is Requisites : Alire.Requisites.Tree; Native : Boolean) return Release; - function "<" (L, R : Release) return Boolean; + function "<" (L, R : Release) return Boolean; function Project (R : Release) return Project_Name; function Description (R : Release) return Project_Description; @@ -83,10 +83,10 @@ private use Semantic_Versioning; function "<" (L, R : Release) return Boolean is - (L.Project < R.Project or else - (L.Project = R.Project and then + (L.Name < R.Name or else + (L.Name = R.Name and then L.Version < R.Version) or else - (L.Project = R.Project and then + (L.Name = R.Name and then L.Version = R.Version and then Build (L.Version) < Build (R.Version))); @@ -103,7 +103,7 @@ private -- FIXME: this should be OS-sanitized to be a valid path function Image (R : Release) return String is - (R.Project & "_" & + (R.Name & "_" & Image (R.Version) & "_" & (if R.Origin.Id'Length <= 8 then R.Origin.Id else R.Origin.Id (R.Origin.Id'First .. R.Origin.Id'First + 7))); diff --git a/src/alire-root_project.adb b/src/alire-root_project.adb index f03f2e07..68f0c64e 100644 --- a/src/alire-root_project.adb +++ b/src/alire-root_project.adb @@ -1,11 +1,31 @@ + with Ada.Directories; +with Alire.Containers; with Alire.Origins; with Alire.Properties; with Alire.Requisites; package body Alire.Root_Project is + Root : Alire.Containers.Release_H; + -- Root dependency (the working project). If Is_Empty we know we must recompile, + -- unless the hash already matches. In this case, we know the project file is + -- missing the Set_Root_Project call + + ------------- + -- Current -- + ------------- + + function Current return Releases.Release is (Root.Element); + + ------------ + -- Is_Set -- + ------------ + + function Is_Set return Boolean is + (not Root.Is_Empty); + ---------------------- -- Set_Root_Project -- ---------------------- @@ -27,7 +47,7 @@ package body Alire.Root_Project is Requisites => Requisites.No_Requisites, Native => False); begin - Root_Project.Current.Replace_Element (Rel); + Root.Replace_Element (Rel); return Rel; end Set; diff --git a/src/alire-root_project.ads b/src/alire-root_project.ads index f78142d7..5ae9501a 100644 --- a/src/alire-root_project.ads +++ b/src/alire-root_project.ads @@ -1,4 +1,3 @@ -with Alire.Containers; with Alire.Dependencies.Vectors; with Alire.Releases; @@ -10,11 +9,6 @@ package Alire.Root_Project is -- Besides the important Set_Root_Project, unfortunately it renames most of Alire.Index to -- make it directly visible in project_alr.ads - Current : Alire.Containers.Release_H; - -- Root dependency (the working project). If Is_Empty we know we must recompile, - -- unless the hash already matches. In this case, we know the project file is - -- missing the Set_Root_Project call - function Set (Project : Project_Name; Version : Semantic_Versioning.Version; Depends_On : Dependencies.Vectors.Vector := Dependencies.Vectors.No_Dependencies) @@ -24,4 +18,8 @@ package Alire.Root_Project is -- It could be manually parsed from the file, but that's precisely what we want to avoid -- The returned Release is the same; this is just a trick to be able to use it in an spec file. + function Current return Releases.Release; + + function Is_Set return Boolean; + end Alire.Root_Project;