From 68892cbaf2d70c59623aedfdb056c44ef230631a Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sat, 3 Mar 2018 13:52:26 +0100 Subject: [PATCH] Build config to apply by alr --- index/alire-index-alire.ads | 16 +++++++++++++++- index/alire-index-rxada.ads | 5 ++--- src/alire-index.ads | 13 +++++++------ src/alire-properties-labeled.ads | 1 + src/alire-releases.adb | 13 +++++++++++++ src/alire-releases.ads | 10 +++++++--- src/alire-types.ads | 2 +- src/alire-utils.adb | 15 +++++++++++++++ src/alire-utils.ads | 26 +++++++++++++++++++++++--- 9 files changed, 84 insertions(+), 17 deletions(-) diff --git a/index/alire-index-alire.ads b/index/alire-index-alire.ads index 3f1032bc..fd44fd6b 100644 --- a/index/alire-index-alire.ads +++ b/index/alire-index-alire.ads @@ -33,9 +33,14 @@ package Alire.Index.Alire is At_Least ("star_citizen", V ("3.0")), -- Wish... When_False => At_Least ("windows_100", V ("1.0"))), - Properties => + Properties => + GPR_Extra_Config ("-XProfile=False") and + -- Sample extra params for build + GPR_Scenario ("Build", "Debug" or "Release") and GPR_Free_Scenario ("Path_To_Something") and + -- Known scenario variables + If_Platform (System_Is (Windows), GPR_File ("project_win.gpr")) and @@ -43,18 +48,27 @@ package Alire.Index.Alire is (System_Is (GNU_Linux), If_Platform (Distribution_Is (Ubuntu), -- Nested conditions GPR_File ("project_ubuntu.gpr"))) and + -- Conditional project file + If_Platform (System_Is (GNU_Linux), Comment ("Long life the penguin")) and + -- Conditions on operating system + If_Platform (not Compiler_Is (GNAT_Unknown), Comment ("Never saw that compiler") and Comment ("But I would like to")) and + -- Conditions on compiler version + If_Platform (Version_Is (Ubuntu_Artful), When_True => Comment ("Living on the edge"), When_False => Comment ("I am a rock")) and + -- Conditions on distribution release + Comment ("Tell me about your mother") and Website ("http://www.www.www"), + -- Unconditional properties Available_When => -- Impossible mix (System_Is (Windows) and System_Is (GNU_Linux)) or diff --git a/index/alire-index-rxada.ads b/index/alire-index-rxada.ads index 817d0977..e0d0f1ec 100644 --- a/index/alire-index-rxada.ads +++ b/index/alire-index-rxada.ads @@ -11,13 +11,12 @@ package Alire.Index.RxAda is Desc, Hg (Repo, "361d4e2ab20a7dcca007e31bf7094d57b13fee6b"), Properties => - Executable ("rx-examples-basic") and Executable ("rx-examples-minimal") and Executable ("rx-examples-tests") and Executable ("rx-examples-threading") and - License (LGPL_3_0) and - Maintainer ("alejandro@mosteo.com")); + Author ("alejandro@mosteo.com") and + License (LGPL_3_0)); end Alire.Index.RxAda; diff --git a/src/alire-index.ads b/src/alire-index.ads index bc43204b..f702bfb1 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -156,12 +156,13 @@ package Alire.Index is -- Conditional vectors (although with unconditional value inside) package PL renames Properties.Labeled; - function Author is new PL.Cond_New_Label (Properties.Labeled.Author); - function Comment is new PL.Cond_New_Label (Properties.Labeled.Comment); - function Executable is new PL.Cond_New_Label (Properties.Labeled.Executable); - function GPR_File is new PL.Cond_New_Label (Properties.Labeled.GPR_File); - function Maintainer is new PL.Cond_New_Label (Properties.Labeled.Maintainer); - function Website is new PL.Cond_New_Label (Properties.Labeled.Website); + function Author is new PL.Cond_New_Label (Properties.Labeled.Author); + function Comment is new PL.Cond_New_Label (Properties.Labeled.Comment); + function Executable is new PL.Cond_New_Label (Properties.Labeled.Executable); + function GPR_Extra_Config is new PL.Cond_New_Label (Properties.Labeled.GPR_Extra_Config); + function GPR_File is new PL.Cond_New_Label (Properties.Labeled.GPR_File); + function Maintainer is new PL.Cond_New_Label (Properties.Labeled.Maintainer); + function Website is new PL.Cond_New_Label (Properties.Labeled.Website); function U (Prop : Properties.Vector) return Conditional.Properties renames Conditional.For_Properties.New_Value; diff --git a/src/alire-properties-labeled.ads b/src/alire-properties-labeled.ads index 7576590b..04766787 100644 --- a/src/alire-properties-labeled.ads +++ b/src/alire-properties-labeled.ads @@ -10,6 +10,7 @@ package Alire.Properties.Labeled with Preelaborate is Comment, -- Extra text Description, -- One-liner description, so it is searched too Executable, -- A resulting executable built by the project + GPR_Extra_Config, -- Extra config to pass to gprbuild for building the project with alr 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 diff --git a/src/alire-releases.adb b/src/alire-releases.adb index df06d18e..d5de6b28 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -60,6 +60,19 @@ package body Alire.Releases is end return; end GPR_Files; + ------------------------ + -- Labeled_Properties -- + ------------------------ + + function Labeled_Properties (R : Release; + P : Properties.Vector; + Label : Properties.Labeled.Labels) + return Utils.String_Vector + is + begin + return Values (R.Properties.Evaluate (P), Label); + end Labeled_Properties; + ----------------------- -- Print_Conditional -- ----------------------- diff --git a/src/alire-releases.ads b/src/alire-releases.ads index ca984364..479619af 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -4,13 +4,13 @@ with Alire.Dependencies.Vectors; with Alire.Milestones; with Alire.Origins; with Alire.Properties; +with Alire.Properties.Labeled; with Alire.Requisites; with Alire.Utils; with Semantic_Versioning; private with Alire.OS_Lib; -private with Alire.Properties.Labeled; package Alire.Releases with Preelaborate is @@ -60,17 +60,21 @@ package Alire.Releases with Preelaborate is -- Unique string built as name_version_id function Unique_Folder (R : Release) return Path_String renames Image; + function Labeled_Properties (R : Release; P : Properties.Vector; Label : Properties.Labeled.Labels) + return Utils.String_Vector; + -- Get all values for a given property for a given platform properties + function Milestone (R : Release) return Milestones.Milestone; procedure Print (R : Release); - -- Dump info to console + -- Dump info to console -- Search helpers function Property_Contains (R : Release; Str : String) return Boolean; -- True if some property contains the given string - -- Dependency generation helpers + -- Dependency generation helpers for all semantic versioning functions: function On (Name : Project_Name; Versions : Semantic_Versioning.Version_Set) diff --git a/src/alire-types.ads b/src/alire-types.ads index d3fb492d..7f647330 100644 --- a/src/alire-types.ads +++ b/src/alire-types.ads @@ -3,7 +3,7 @@ with Alire.Dependencies.Vectors; package Alire.Types with Preelaborate is - -- Recopilation of types for convenient use in alr + -- Recopilation of types for convenient use and documentation subtype Platform_Dependencies is Dependencies.Vectors.Vector; -- A plain vector diff --git a/src/alire-utils.adb b/src/alire-utils.adb index c83e7ab4..7bc4ca10 100644 --- a/src/alire-utils.adb +++ b/src/alire-utils.adb @@ -26,6 +26,21 @@ package body Alire.Utils is return Str; end Head; + ------------- + -- Flatten -- + ------------- + + function Flatten (V : String_Vector; Separator : String := " ") return String is + + function Flatten (Pos : Positive; V : String_Vector) return String is + (if Pos > V.Count + then "" + else V (Pos) & Separator & Flatten (Pos + 1, V)); + + begin + return Flatten (1, V); + end Flatten; + ---------- -- Tail -- ---------- diff --git a/src/alire-utils.ads b/src/alire-utils.ads index 66b7388c..98063792 100644 --- a/src/alire-utils.ads +++ b/src/alire-utils.ads @@ -7,9 +7,6 @@ package Alire.Utils with Preelaborate is function Contains (Text : String; Sub : String) return Boolean; - package String_Vectors is new Ada.Containers.Indefinite_Vectors (Positive, String); - subtype String_Vector is String_Vectors.Vector; - function Head (Str : String; Separator : Character) return String; -- if Str contains Separator, the lhs is returned -- Otherwise Str is returned @@ -18,4 +15,27 @@ package Alire.Utils with Preelaborate is -- If Str contains Separator, the rhs is returned -- Otherwise "" + -------------------- + -- String_Vectors -- + -------------------- + + -- To simplify somewhat managing lists of strigns + + package String_Vectors is new Ada.Containers.Indefinite_Vectors (Positive, String); + type String_Vector is new String_Vectors.Vector with null record; + + Empty_Vector : constant String_Vector; + + function Count (V : String_Vector) return Natural; + -- FSM do I hate the Containers.Count_Type... + + function Flatten (V : String_Vector; Separator : String := " ") return String; + -- Concatenate all elements + +private + + Empty_Vector : constant String_Vector := (String_Vectors.Empty_Vector with null record); + + function Count (V : String_Vector) return Natural is (Natural (String_Vectors.Vector (V).Length)); + end Alire.Utils;