Refactorings

This commit is contained in:
Alejandro R. Mosteo
2018-02-24 20:31:05 +01:00
parent 7800a5e27b
commit a70cba98f7
7 changed files with 57 additions and 16 deletions
-1
View File
@@ -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
+17
View File
@@ -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 --
--------------------
+7
View File
@@ -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;
+3 -3
View File
@@ -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
+5 -5
View File
@@ -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)));
+21 -1
View File
@@ -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;
+4 -6
View File
@@ -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;