Support for multi-GPR, non-standard named, projects

This commit is contained in:
A
2018-02-26 18:13:36 +01:00
parent c0283e2566
commit 1d40fb3895
8 changed files with 147 additions and 30 deletions
+59
View File
@@ -0,0 +1,59 @@
package Alire.Index.DAK is
-- Simple Components by Dmitry A. Kazakov
-- This library is a good challenge since it has many subprojects
-- It prompted the introduction of the GPR_File property
-- Unsure if something should be done about -X arguments...
-- Since most project names are common words, I've taken the liberty to prefix them with dak_
-- But the original sources are unchanged.
Base : constant Project_Name := "dak_";
Repo : constant URL := "https://github.com/alire-project/dak_simple_components.git";
DAK_Author : constant String := "Dmitry A. Kazakov";
DAK_Website : constant String := "http://www.dmitry-kazakov.de/ada/components.htm";
Desc_Pre : constant String := "Simple Components ";
Desc_Post : constant String := " by Dmitry A. Kazakov";
Strings_Edit_V_4_27 : constant Release :=
Register (Base & "strings_edit",
V ("4.27"),
Desc_Pre & "(strings)" & Desc_Post,
Git (Repo, "b8b638e6694e92141f4c1b33ccad066678260c18"),
Properties =>
GPR_File ("strings_edit.gpr") and
GPR_File ("test_strings_edit" / "strings_edit-test.gpr") and
Executable ("test_base64") and
Executable ("test_strings_edit") and
Executable ("test_string_streams") and
License (GMGPL_2_0) and
Author (DAK_Author) and
Website (DAK_Website)
);
Tables_V_4_27 : constant Release :=
Register (Base & "tables",
V ("4.27"),
Desc_Pre & "(tables)" & Desc_Post,
Git (Repo, "93dfba26bf6251aefd76af0b5567fd43ec3c8fe2"),
Properties =>
GPR_File ("tables.gpr") and
GPR_File ("test_tables" / "tables-test.gpr") and
Executable ("test_tables") and
License (GMGPL_2_0) and
Author (DAK_Author) and
Website (DAK_Website)
);
end Alire.Index.DAK;
+7 -5
View File
@@ -9,16 +9,18 @@ package Alire.Index.Hello is
V_1_0_0 : constant Release :=
Register (Name,
V ("1.0.0"),
Desc,
Git (Repo, "8cac0afddc505794ae3e5634745ce0830129d241"),
Depends_On => Within_Major (Libhello.V_1_0_0));
V ("1.0.0"),
Desc,
Git (Repo, "8cac0afddc505794ae3e5634745ce0830129d241"),
Depends_On => Within_Major (Libhello.V_1_0_0));
V_1_0_1 : constant Release :=
Register (Name,
V ("1.0.1"),
Desc,
Git (Repo, "65725c20778875eef12b61a01b437120932965f3"),
Depends_On => Within_Major (Libhello.V_1_0_0));
Depends_On => Within_Major (Libhello.V_1_0_0));
V_1_0 : Release renames V_1_0_1;
end Alire.Index.Hello;
+12 -3
View File
@@ -1,5 +1,7 @@
private with Alire_Early_Elaboration; pragma Unreferenced (Alire_Early_Elaboration);
with Ada.Directories;
with Alire.Containers;
with Alire.Compilers;
with Alire.Dependencies.Vectors;
@@ -39,9 +41,9 @@ package Alire.Index is
Requisites : Alire.Requisites.Tree := No_Requisites;
Available_When : Alire.Requisites.Tree := No_Requisites;
Native : Boolean := False) return Release;
-- Properties are of the Release; currently not used but could support License or other attributes.
-- Requisites are properties that dependencies have to fulfill, again not used yet.
-- Available_On are properties the platform has to fulfill; these are checked on registration.
-- Properties are of the Release
-- Requisites are properties that dependencies have to fulfill, not used yet.
-- Available_On are properties the platform has to fulfill.
-- Shortcuts for common origins:
function Git (URL : Alire.URL; Commit : Origins.Git_Commit) return Origins.Origin renames Origins.New_Git;
@@ -88,6 +90,7 @@ package Alire.Index is
-- "Typed" attributes (named pairs of label-value)
function Author is new Properties.Labeled.Generic_New_Label (Properties.Labeled.Author);
function Executable is new Properties.Labeled.Generic_New_Label (Properties.Labeled.Executable);
function GPR_File is new Properties.Labeled.Generic_New_Label (Properties.Labeled.GPR_File);
function Maintainer is new Properties.Labeled.Generic_New_Label (Properties.Labeled.Maintainer);
function Website is new Properties.Labeled.Generic_New_Label (Properties.Labeled.Website);
@@ -120,6 +123,12 @@ package Alire.Index is
function System_is (V : Operating_Systems.Operating_Systems) return Requisites.Requisite'Class
renames Requisites.Platform.System_Is;
-- Other useful functions
function "/" (L, R : String) return String is (Ada.Directories.Compose (L, R));
-- Path composition.
-- FIXME: hardcoded path separators shouldn't reach the index, not sure how to force-prevent this...
----------------------
-- Set_Root_Project --
+7 -5
View File
@@ -4,10 +4,12 @@ package Alire.Properties.Labeled with Preelaborate is
-- Properties that have a single string value and a name
type Labels is (Author, -- VIP
Executable, -- A resulting executable built by the project
Maintainer, -- Info about the maintainer of the alr-packaged project
Website); -- A website other than the repository
type Labels is (Author, -- VIP
Description, -- One-liner description, so it is searched too
Executable, -- A resulting executable built by the project
GPR_File, -- Alternative naming of the project file (or more than one)
Maintainer, -- Info about the maintainer of the alr-packaged project
Website); -- A website other than the repository
type Label (<>) is new Properties.Property with private;
@@ -40,6 +42,6 @@ private
function Generic_New_Label (Value : String) return Label is (New_Label (Name, Value));
overriding function Image (L : Label) return String is (Utils.To_Mixed_Case (L.Name'Img & ": " & L.Value));
overriding function Image (L : Label) return String is (Utils.To_Mixed_Case (L.Name'Img) & ": " & L.Value);
end Alire.Properties.Labeled;
+43 -15
View File
@@ -1,31 +1,59 @@
with Alire.Properties.Labeled;
with GNAT.IO; -- To keep preelaborable
package body Alire.Releases is
use all type Properties.Labeled.Labels;
------------
-- Values --
------------
function Values (Props : Properties.Vector; Label : Properties.Labeled.Labels) return Utils.String_Vector is
-- Extract values of a particular label
begin
return Strs : Utils.String_Vector do
for P of Props loop
if P in Properties.Labeled.Label'Class then
declare
LP : Properties.Labeled.Label renames Properties.Labeled.Label (P);
begin
if LP.Name = Label then
Strs.Append (LP.Value);
end if;
end;
end if;
end loop;
end return;
end Values;
-----------------
-- Executables --
----------------
function Executables (R : Release) return Utils.String_Vector is
begin
return Exes : Utils.String_Vector do
for P of R.Props loop
if P in Properties.Labeled.Label'Class then
declare
use all type Properties.Labeled.Labels;
Label : Properties.Labeled.Label renames Properties.Labeled.Label (P);
begin
if Label.Name = Executable then
Exes.Append (Label.Value & OS_Lib.Exe_Suffix);
end if;
end;
end if;
end loop;
return Exes : Utils.String_Vector := Values (R.Props, Executable) do
if OS_Lib.Exe_Suffix /= "" then
for I in Exes.Iterate loop
Exes (I) := Exes (I) & OS_Lib.Exe_Suffix;
end loop;
end if;
end return;
end Executables;
---------------
-- GPR_Files --
---------------
function GPR_Files (R : Release) return Utils.String_Vector is
begin
return Files : Utils.String_Vector := Values (R.Props, GPR_File) do
if Files.Is_Empty then
Files.Append (R.Project & ".gpr");
end if;
end return;
end GPR_Files;
-----------
-- Print --
-----------
+8 -1
View File
@@ -8,6 +8,7 @@ with Alire.Utils;
with Semantic_Versioning;
private with Alire.OS_Lib;
private with Alire.Properties.Labeled;
package Alire.Releases with Preelaborate is
@@ -39,6 +40,9 @@ package Alire.Releases with Preelaborate is
function Executables (R : Release) return Utils.String_Vector;
-- Only explicity declared ones
function GPR_Files (R : Release) return Utils.String_Vector;
-- Explicitly declared ones, or if default one if none declared
function Image (R : Release) return Path_String;
-- Unique string built as name_version_id
function Unique_Folder (R : Release) return Path_String renames Image;
@@ -60,6 +64,9 @@ package Alire.Releases with Preelaborate is
-- True if some property contains the given string
private
use all type Properties.Property'Class;
function Describe is new Properties.Labeled.Generic_New_Label (Properties.Labeled.Description);
type Release (Name_Len, Descr_Len : Natural) is tagged record
Name : Project_Name (1 .. Name_Len);
@@ -86,7 +93,7 @@ private
Version,
Origin,
Depends_On,
Properties,
Properties and Describe (Description),
Requisites,
Native);
+9 -1
View File
@@ -4,6 +4,7 @@ with Ada.Directories;
with Alire.Containers;
with Alire.Origins;
with Alire.Properties;
with Alire.Query;
with Alire.Requisites;
package body Alire.Root_Project is
@@ -49,7 +50,14 @@ package body Alire.Root_Project is
Requisites => Requisites.No_Requisites,
Native => False);
begin
Root.Replace_Element (Rel);
if Query.Exists (Project, Version) then
-- This is done to ensure that properties are all available
Trace.Debug ("Storing pre-indexed release of root project");
Root.Replace_Element (Query.Find (Project, Version));
else
Trace.Debug ("Storing unindexed release of root project");
Root.Replace_Element (Rel);
end if;
return Rel;
end Set;
+2
View File
@@ -18,6 +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.
-- FIXME: specific GPR project files should be given here too, for developing of alr-packaged new versions
function Current return Releases.Release;
function Is_Set return Boolean;