GPR_External vs GPR_Scenario
This commit is contained in:
@@ -42,7 +42,7 @@ package Alire.Index.Alire is
|
||||
Otherwise => Within_Major ("alire", V ("0.5")))),
|
||||
|
||||
Alr_Properties => -- These are only interesting to alr, not users
|
||||
GPR_Config ("-XProfile=False"),
|
||||
GPR_External ("Profile", "False"),
|
||||
-- Sample extra params for build
|
||||
|
||||
Properties =>
|
||||
|
||||
@@ -252,16 +252,16 @@ package Alire.Index.DAK is
|
||||
Alr_Properties =>
|
||||
On_Condition
|
||||
(System_Is (GNU_Linux),
|
||||
GPR_Config ("-Xodbc=unixODBC")) and
|
||||
GPR_External ("odbc", "unixODBC")) and
|
||||
On_Condition
|
||||
(System_Is (Windows),
|
||||
GPR_Config ("-Xodbc=ODBC32")) and
|
||||
GPR_External ("odbc", "ODBC32")) and
|
||||
On_Condition
|
||||
(Word_Size_Is (Bits_32),
|
||||
GPR_Config ("-Xarch=i686")) and
|
||||
GPR_External ("arch", "i686")) and
|
||||
On_Condition
|
||||
(Word_Size_Is (Bits_64),
|
||||
GPR_Config ("-Xarch=x86_64"))
|
||||
GPR_External ("arch", "x86_64"))
|
||||
);
|
||||
|
||||
end Alire.Index.DAK;
|
||||
|
||||
@@ -37,10 +37,10 @@ package Alire.Index.Libadacrypt is
|
||||
Alr_Properties =>
|
||||
On_Condition
|
||||
(System_Is (GNU_Linux),
|
||||
GPR_Config ("-Xsystem=unix")) and
|
||||
GPR_External ("system", "unix")) and
|
||||
On_Condition
|
||||
(System_Is (Windows),
|
||||
GPR_Config ("-Xsystem=windows"))
|
||||
GPR_External ("system", "windows"))
|
||||
);
|
||||
|
||||
end Alire.Index.Libadacrypt;
|
||||
|
||||
@@ -44,7 +44,7 @@ package Alire.Index.OpenGLAda is
|
||||
|
||||
Alr_Properties =>
|
||||
On_Condition
|
||||
(System_Is (GNU_Linux), GPR_Config ("-XWindowing_System=x11")),
|
||||
(System_Is (GNU_Linux), GPR_External ("Windowing_System", "x11")),
|
||||
|
||||
Available_When =>
|
||||
System_Is (GNU_Linux)
|
||||
|
||||
@@ -51,10 +51,11 @@ package Alire.Index.SDLAda is
|
||||
Executable ("test") and
|
||||
Executable ("version") and
|
||||
|
||||
GPR_Config ("-XSDL_MODE=release") and
|
||||
GPR_External ("SDL_MODE", "release") and
|
||||
|
||||
On_Condition
|
||||
(System_Is (GNU_Linux),
|
||||
GPR_Config ("-XSDL_PLATFORM=linux")),
|
||||
GPR_External ("SDL_PLATFORM", "linux")),
|
||||
|
||||
Available_When =>
|
||||
System_Is (GNU_Linux)
|
||||
|
||||
+8
-5
@@ -19,11 +19,14 @@ package body Alire.GPR is
|
||||
end Listify;
|
||||
|
||||
begin
|
||||
if V.Kind = Free_String then
|
||||
return V.Name & " = <string>";
|
||||
else
|
||||
return V.Name & " = " & Listify (V.Values);
|
||||
end if;
|
||||
case V.Kind is
|
||||
when Free_String =>
|
||||
return V.Name & " = <string>";
|
||||
when Enumeration =>
|
||||
return V.Name & " = " & Listify (V.Values);
|
||||
when External =>
|
||||
return V.Name & " = " & V.Value.First_Element;
|
||||
end case;
|
||||
end Image;
|
||||
|
||||
------------------
|
||||
|
||||
+26
-2
@@ -2,12 +2,17 @@ with Alire.Utils;
|
||||
|
||||
package Alire.GPR with Preelaborate is
|
||||
|
||||
type Variable_Kinds is (Enumeration, Free_String);
|
||||
type Variable_Kinds is (Enumeration, Free_String, External);
|
||||
-- Enumeration: Name + all possible values
|
||||
-- Free_String: Name without value
|
||||
-- External : Name=Value
|
||||
|
||||
type Variable (<>) is tagged private;
|
||||
|
||||
function Kind (V : Variable) return Variable_Kinds;
|
||||
|
||||
function Name (V : Variable) return String;
|
||||
|
||||
function Image (V : Variable) return String;
|
||||
|
||||
function Free_Variable (Name : String) return Variable;
|
||||
@@ -18,14 +23,23 @@ package Alire.GPR with Preelaborate is
|
||||
|
||||
function Enum_Variable (Name : String;
|
||||
Values : Value_Vector'Class) return Variable;
|
||||
-- Used to represent a Typed enum with its possible values: Name = Value1 | Value2 ...
|
||||
|
||||
function External_Value (Name : String;
|
||||
Value : String) return Variable;
|
||||
-- Used to represent a pair Name=Value
|
||||
|
||||
function Values (V : Variable) return Value_Vector'Class
|
||||
with Pre => V.Kind = Enumeration;
|
||||
|
||||
function External_value (V : Variable) return String
|
||||
with Pre => V.Kind = External;
|
||||
|
||||
function "or" (L, R : Value) return Value_Vector;
|
||||
function "or" (L : Value_Vector; R : Value) return Value_Vector;
|
||||
|
||||
-- A collection of Var=Arg conform a scenario:
|
||||
-- These are used to store -X command-line arguments
|
||||
|
||||
type Scenario is tagged private;
|
||||
|
||||
@@ -45,6 +59,8 @@ private
|
||||
case Kind is
|
||||
when Enumeration =>
|
||||
Values : Value_Vector;
|
||||
when External =>
|
||||
Value : Value_Vector; -- Only one element
|
||||
when Free_String =>
|
||||
null;
|
||||
end case;
|
||||
@@ -52,14 +68,22 @@ private
|
||||
|
||||
function Kind (V : Variable) return Variable_Kinds is (V.Kind);
|
||||
|
||||
function Name (V : Variable) return String is (V.Name);
|
||||
|
||||
function Free_Variable (Name : String) return Variable is (Free_String, Name'Length, Name);
|
||||
|
||||
function Enum_Variable (Name : String;
|
||||
Values : Value_Vector'Class) return Variable is
|
||||
(Enumeration, Name'Length, Name, Value_Vector (Values));
|
||||
(Enumeration, Name'Length, Name, Value_Vector (Values));
|
||||
|
||||
function External_Value (Name : String;
|
||||
Value : String) return Variable is
|
||||
(External, Name'Length, Name, To_Vector (Value, 1));
|
||||
|
||||
function Values (V : Variable) return Value_Vector'Class is (V.Values);
|
||||
|
||||
function External_Value (V : Variable) return String is (V.Value.First_Element);
|
||||
|
||||
function "or" (L, R : Value) return Value_Vector is (L & R);
|
||||
function "or" (L : Value_Vector; R : Value) return Value_Vector is (L & R);
|
||||
|
||||
|
||||
+5
-3
@@ -211,10 +211,10 @@ package Alire.Index is
|
||||
renames Conditional.For_Properties.New_Value;
|
||||
|
||||
-- Non-label attributes require a custom builder function
|
||||
function GPR_Free_Scenario (Name : String) return Properties.Vector is (+Properties.Scenarios.New_Variable (GPR.Free_Variable (Name)));
|
||||
function GPR_Free_Scenario (Name : String) return Properties.Vector is (+Properties.Scenarios.New_Property (GPR.Free_Variable (Name)));
|
||||
function GPR_Free_Scenario (Name : String) return Conditional.Properties is (U (GPR_Free_Scenario (Name)));
|
||||
|
||||
function GPR_Scenario (Name : String; Values : GPR.Value_Vector) return Properties.Vector is (+Properties.Scenarios.New_Variable (GPR.Enum_Variable (Name, Values)));
|
||||
function GPR_Scenario (Name : String; Values : GPR.Value_Vector) return Properties.Vector is (+Properties.Scenarios.New_Property (GPR.Enum_Variable (Name, Values)));
|
||||
function GPR_Scenario (Name : String; Values : GPR.Value_Vector) return Conditional.Properties is (U (GPR_Scenario (Name, Values)));
|
||||
|
||||
function License (L : Licensing.Licenses) return Properties.Vector is (+Properties.Licenses.Values.New_Property (L));
|
||||
@@ -228,7 +228,9 @@ package Alire.Index is
|
||||
------------------------
|
||||
-- Those instruct alr on how to build, but are not the main concern of the project user
|
||||
|
||||
function GPR_Config is new PL.Cond_New_Label (Properties.Labeled.GPR_Config);
|
||||
function GPR_External (Name : String; Value : String) return Conditional.Properties is
|
||||
(U (+Properties.Scenarios.New_Property (GPR.External_Value (Name, Value))));
|
||||
|
||||
function GPR_File (File : Platform_Independent_Path) return Release_Properties;
|
||||
function GPR_Path (Path : Platform_Independent_Path) return Release_Properties;
|
||||
|
||||
|
||||
@@ -12,15 +12,14 @@ package Alire.Properties.Labeled with Preelaborate is
|
||||
Description, -- One-liner description, so it is searched too
|
||||
Executable, -- A resulting executable built by the project
|
||||
Maintainer, -- Info about the maintainer of the alr-packaged project
|
||||
Project_File,-- GPR files that the user can use. No path. This is purely informative
|
||||
Website,
|
||||
Project_File,-- GPR files that the user can use. No path. Search paths given with GPR_Path
|
||||
Website, -- A website other than the repository
|
||||
|
||||
-- internal labels
|
||||
GPR_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)
|
||||
-- Those are used when testing the build, and must include full relative path
|
||||
GPR_Path -- Extra path to add to the environment to look for projects
|
||||
); -- A website other than the repository
|
||||
GPR_File, -- Alternative naming of the project file (or aditional ones)
|
||||
-- Those are used when testing the build, and must include full relative path
|
||||
GPR_Path -- Extra path to add to the environment to look for projects
|
||||
);
|
||||
|
||||
type Label (<>) is new Properties.Property with private;
|
||||
|
||||
|
||||
@@ -4,24 +4,34 @@ private with Ada.Containers.Indefinite_Holders;
|
||||
|
||||
package Alire.Properties.Scenarios with Preelaborate is
|
||||
|
||||
type Variable is new Property with private;
|
||||
type Property is new Properties.Property with private;
|
||||
|
||||
function New_Variable (V : GPR.Variable) return Variable;
|
||||
function New_Property (V : GPR.Variable) return Property;
|
||||
|
||||
overriding function Image (V : Variable) return String;
|
||||
overriding function Image (V : Property) return String;
|
||||
|
||||
function Value (V : Property) return Gpr.Variable;
|
||||
|
||||
private
|
||||
|
||||
package Holders is new Ada.Containers.Indefinite_Holders (Gpr.Variable, GPR."=");
|
||||
|
||||
type Variable is new Property with record
|
||||
type Property is new Properties.Property with record
|
||||
Var : Holders.Holder;
|
||||
end record;
|
||||
|
||||
function New_Variable (V : GPR.Variable) return Variable is
|
||||
function New_Property (V : GPR.Variable) return Property is
|
||||
(Var => Holders.To_Holder (V));
|
||||
|
||||
overriding function Image (V : Variable) return String is
|
||||
("GPR Scenario: " & V.Var.Constant_Reference.Image);
|
||||
overriding function Image (V : Property) return String is
|
||||
((case V.Var.Element.Kind is
|
||||
when GPR.External => "GPR External: ",
|
||||
when others => "GPR Scenario: ") & V.Var.Element.Image);
|
||||
|
||||
-- overriding function Image (V : Property) return String is
|
||||
-- ("GPR Scenario: " & V.Var.Constant_Reference.Image);
|
||||
|
||||
function Value (V : Property) return Gpr.Variable is
|
||||
(V.Var.Element);
|
||||
|
||||
end Alire.Properties.Scenarios;
|
||||
|
||||
@@ -9,6 +9,13 @@ package body Alire.Releases is
|
||||
|
||||
use all type Properties.Labeled.Labels;
|
||||
|
||||
----------------------------
|
||||
-- On_Platform_Properties --
|
||||
----------------------------
|
||||
|
||||
function On_Platform_Properties (R : Release; P : Properties.Vector) return Properties.Vector is
|
||||
(R.Properties.Evaluate (P));
|
||||
|
||||
------------
|
||||
-- Values --
|
||||
------------
|
||||
|
||||
@@ -60,6 +60,9 @@ package Alire.Releases with Preelaborate is
|
||||
-- Unique string built as name_version_id
|
||||
function Unique_Folder (R : Release) return Folder_String renames Image;
|
||||
|
||||
function On_Platform_Properties (R : Release; P : Properties.Vector) return Properties.Vector;
|
||||
-- Return properties that apply to R under platform properties P
|
||||
|
||||
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
|
||||
@@ -98,8 +101,8 @@ private
|
||||
function Unavailable return Conditional.Dependencies is
|
||||
(On ("alire_unavailable", Semantic_Versioning.Any));
|
||||
|
||||
use Properties;
|
||||
function Describe is new Properties.Labeled.Cond_New_Label (Properties.Labeled.Description);
|
||||
use Alire.Properties;
|
||||
function Describe is new Alire.Properties.Labeled.Cond_New_Label (Alire.Properties.Labeled.Description);
|
||||
|
||||
type Release (Name_Len, Descr_Len : Natural) is tagged record
|
||||
Name : Project_Name (1 .. Name_Len);
|
||||
|
||||
Reference in New Issue
Block a user