Root demoting to simple release

This commit is contained in:
Alejandro R Mosteo
2018-05-20 12:51:35 +02:00
parent 9c4305a622
commit e21afc9218
3 changed files with 27 additions and 62 deletions
+18 -6
View File
@@ -29,14 +29,14 @@ package body Alire.Root is
is
begin
if Index.Exists (Project, Version) then
Root := new Roots.Root'(Roots.New_Root (Index.Find (Project, Version)));
Trace.Debug ("Storing indexed release as root: " & Root.Release.Milestone.Image);
Root := new Roots.Root'(Index.Find (Project, Version) with null record);
Trace.Debug ("Storing indexed release as root: " & Root.Milestone.Image);
return Root.all;
else
-- Session is outdated or outside
Trace.Warning ("Storing incomplete root for outdated session");
return Set (Project,
Conditional.For_Dependencies.Empty);
Trace.Error ("Requesting released root not in index: " &
(+Project) & "=" & Semantic_Versioning.Image (Version));
raise Constraint_Error;
end if;
end Set;
@@ -50,7 +50,19 @@ package body Alire.Root is
is
begin
Trace.Debug ("Storing unindexed project as root:" & (+Project));
Root := new Roots.Root'(Roots.New_Root (Project, Dependencies));
Root := new Roots.Root'
(Releases.New_Working_Release (Project, Dependencies => Dependencies) with null record);
return Root.all;
end Set;
---------
-- Set --
---------
function Set (Release : Releases.Release) return Roots.Root is
begin
Trace.Debug ("Storing unindexed release as root:" & Release.Milestone.Image);
Root := new Roots.Root'(Release with null record);
return Root.all;
end Set;
+3
View File
@@ -1,4 +1,5 @@
with Alire.Conditional;
with Alire.Releases;
with Alire.Roots;
with Semantic_Versioning;
@@ -19,6 +20,8 @@ package Alire.Root is
return Roots.Root;
-- An unindexed working copy
function Set (Release : Releases.Release) return Roots.Root;
function Current return Roots.Root;
function Is_Set return Boolean;
+6 -56
View File
@@ -1,68 +1,18 @@
with Alire.Conditional;
with Alire.Containers;
with Alire.OS_Lib;
with Alire.Releases;
with Alire.Utils;
package Alire.Roots is
-- Type used to encapsulate the information about the root release/working copy
type Root (<>) is tagged private;
type Root is new Releases.Release with null record;
function New_Root (R : Releases.Release) return Root;
function New_Root (Name : Alire.Project;
Dependencies : Conditional.Dependencies := Conditional.For_Dependencies.Empty)
return Root;
function Default_Executable (R : Root) return String;
function Dependencies (R : Root) return Conditional.Dependencies;
function Is_Released (R : Root) return Boolean;
function Project (R : Root) return Alire.Project;
function Project_Base (R : Root) return String; -- see Release.Project_Base
function Release (R : Root) return Releases.Release with Pre => R.Is_Released;
private
type Root (Name_Len : Natural; Project_Release : Boolean) is tagged record
case Project_Release is
when False =>
Project : Alire.Project (1 .. Name_Len);
Dependencies : Conditional.Dependencies;
when True =>
Release : Containers.Release_H;
end case;
end record;
function New_Root (Name : Alire.Project) return Root is
(Releases.New_Working_Release (Name) with null record);
function New_Root (R : Releases.Release) return Root is
(0, True, Containers.Release_Holders.To_Holder (R));
(R with null record);
function New_Root (Name : Alire.Project;
Dependencies : Conditional.Dependencies := Conditional.For_Dependencies.Empty)
return Root is
(Name'Length, False, Name, Dependencies);
function Default_Executable (R : Root) return String is
(if R.Project_Release
then R.Release.Constant_Reference.Default_Executable
else +R.Project & OS_Lib.Exe_Suffix);
function Dependencies (R : Root) return Conditional.Dependencies is
(if R.Project_Release
then R.Release.Constant_Reference.Depends
else R.Dependencies);
function Is_Released (R : Root) return Boolean is (R.Project_Release);
function Project (R : Root) return Alire.Project is
(if R.Project_Release
then R.Release.Constant_Reference.Project
else R.Project);
function Project_Base (R : Root) return String is
(Utils.Head (+R.Project, Extension_Separator));
function Release (R : Root) return Releases.Release is (R.Release.Element);
function Release (This : Root) return Releases.Release is
(Releases.Release (This));
end Alire.Roots;