Support for platform extensions

This commit is contained in:
Alejandro R. Mosteo
2018-02-25 19:43:51 +01:00
parent a70cba98f7
commit 19c0607407
6 changed files with 46 additions and 8 deletions
+20
View File
@@ -0,0 +1,20 @@
with GNAT.OS_Lib;
package body Alire.OS_Lib is
----------------
-- Exe_Suffix --
----------------
function Exe_Suffix return String is
-- Shenanigans needed to stay preelaborable
use GNAT.OS_Lib;
Suffix : String_Access := Get_Executable_Suffix;
begin
return S : constant String := Suffix.all do
Free (Suffix);
end return;
end Exe_Suffix;
end Alire.OS_Lib;
+5
View File
@@ -0,0 +1,5 @@
package Alire.OS_Lib with Preelaborate is
function Exe_Suffix return String;
end Alire.OS_Lib;
+1 -1
View File
@@ -18,7 +18,7 @@ package body Alire.Releases is
Label : Properties.Labeled.Label renames Properties.Labeled.Label (P);
begin
if Label.Name = Executable then
Exes.Append (Label.Value);
Exes.Append (Label.Value & OS_Lib.Exe_Suffix);
end if;
end;
end if;
+13 -6
View File
@@ -7,6 +7,8 @@ with Alire.Utils;
with Semantic_Versioning;
private with Alire.OS_Lib;
package Alire.Releases with Preelaborate is
subtype Dependencies is Alire.Dependencies.Vectors.Vector;
@@ -31,12 +33,15 @@ package Alire.Releases with Preelaborate is
function Origin (R : Release) return Origins.Origin;
-- function Origin_Image (R : Release) return String;
function Default_Executable (R : Release) return String;
-- We encapsulate here the fixing of platform extension
function Executables (R : Release) return Utils.String_Vector;
-- Only explicity declared ones
function Image (R : Release) return String;
-- Unique string built as name-version-id
function Unique_Folder (R : Release) return String renames Image;
function Image (R : Release) return Path_String;
-- Unique string built as name_version_id
function Unique_Folder (R : Release) return Path_String renames Image;
function Milestone (R : Release) return Milestones.Milestone;
@@ -98,11 +103,13 @@ private
function Milestone (R : Release) return Milestones.Milestone is
(Milestones.New_Milestone (R.Name, R.Version));
function Default_Executable (R : Release) return String is
(R.Name & OS_Lib.Exe_Suffix);
function Is_Native (R : Release) return Boolean is (R.Native);
-- FIXME: this should be OS-sanitized to be a valid path
function Image (R : Release) return String is
function Image (R : Release) return Path_String is
(R.Name & "_" &
Image (R.Version) & "_" &
(if R.Origin.Id'Length <= 8 then R.Origin.Id
+3 -1
View File
@@ -37,9 +37,11 @@ package body Alire.Root_Project is
is
use Origins;
Descr : constant String := "working copy of " & Project;
Rel : constant Releases.Release :=
Alire.Releases.New_Release (Project,
"working copy of " & Project, -- FIXME might be too long
Descr (Descr'First .. Descr'First - 1 +
Natural'Min (Descr'Length, Max_Description_Length)),
Version,
New_Filesystem (Ada.Directories.Current_Directory),
Depends_On,
+4
View File
@@ -22,6 +22,10 @@ package Alire with Preelaborate is
subtype Project_Description is String with Dynamic_Predicate =>
Project_Description'Length <= Max_Description_Length;
subtype Path_String is String with Dynamic_Predicate =>
Path_String'Length > 0 and then
(for all C of Path_String => C in 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' | '.');
---------------
-- LOGGING --
---------------