diff --git a/src/alire-os_lib.adb b/src/alire-os_lib.adb new file mode 100644 index 00000000..71db0f2d --- /dev/null +++ b/src/alire-os_lib.adb @@ -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; diff --git a/src/alire-os_lib.ads b/src/alire-os_lib.ads new file mode 100644 index 00000000..7f5a8887 --- /dev/null +++ b/src/alire-os_lib.ads @@ -0,0 +1,5 @@ +package Alire.OS_Lib with Preelaborate is + + function Exe_Suffix return String; + +end Alire.OS_Lib; diff --git a/src/alire-releases.adb b/src/alire-releases.adb index 7d12dd76..c11e823f 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -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; diff --git a/src/alire-releases.ads b/src/alire-releases.ads index a5a648bc..cfb911b2 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -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 diff --git a/src/alire-root_project.adb b/src/alire-root_project.adb index 68f0c64e..624c0b50 100644 --- a/src/alire-root_project.adb +++ b/src/alire-root_project.adb @@ -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, diff --git a/src/alire.ads b/src/alire.ads index 0f7ca09f..40a40f30 100644 --- a/src/alire.ads +++ b/src/alire.ads @@ -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 -- ---------------