diff --git a/index/alire-index-alire.ads b/index/alire-index-alire.ads index 251daf5c..3f1032bc 100644 --- a/index/alire-index-alire.ads +++ b/index/alire-index-alire.ads @@ -36,18 +36,21 @@ package Alire.Index.Alire is Properties => GPR_Scenario ("Build", "Debug" or "Release") and GPR_Free_Scenario ("Path_To_Something") and - If_Platform (System_Is (Windows), - GPR_File ("project_win.gpr")) and - If_Platform (System_Is (GNU_Linux), - GPR_File ("project_linux.gpr")) and + If_Platform + (System_Is (Windows), + GPR_File ("project_win.gpr")) and + If_Platform + (System_Is (GNU_Linux), + If_Platform (Distribution_Is (Ubuntu), -- Nested conditions + GPR_File ("project_ubuntu.gpr"))) and If_Platform (System_Is (GNU_Linux), Comment ("Long life the penguin")) and If_Platform - (not Compiler_Is_At_Least (GNAT_Unknown), + (not Compiler_Is (GNAT_Unknown), Comment ("Never saw that compiler") and Comment ("But I would like to")) and If_Platform - (Distribution_Is (Ubuntu_Artful), + (Version_Is (Ubuntu_Artful), When_True => Comment ("Living on the edge"), When_False => Comment ("I am a rock")) and Comment ("Tell me about your mother") and @@ -55,6 +58,6 @@ package Alire.Index.Alire is Available_When => -- Impossible mix (System_Is (Windows) and System_Is (GNU_Linux)) or - (Compiler_Is_At_Least (GNAT_Unknown) and not Compiler_Is_At_Least (GNAT_Unknown))); + (Compiler_Is (GNAT_Unknown) and not Compiler_Is (GNAT_Unknown))); end Alire.Index.Alire; diff --git a/index/alire-index-libgnutls.ads b/index/alire-index-libgnutls.ads index 54ea1dc2..d901e8a1 100644 --- a/index/alire-index-libgnutls.ads +++ b/index/alire-index-libgnutls.ads @@ -9,8 +9,8 @@ package Alire.Index.LibGNUTLS is Desc, Native ("libgnutls28-dev"), Available_When => - Distribution_Is (Debian_Buster) or - Distribution_Is (Ubuntu_Xenial) or - Distribution_Is (Ubuntu_Artful)); + Version_Is (Debian_Buster) or + Version_Is (Ubuntu_Xenial) or + Version_Is (Ubuntu_Artful)); end Alire.Index.LibGNUTLS; diff --git a/src/alire-index.ads b/src/alire-index.ads index c5cca776..bc43204b 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -133,6 +133,8 @@ package Alire.Index is use all type Platforms.Compilers; use all type Platforms.Distributions; use all type Platforms.Operating_Systems; + use all type Platforms.Versions; + use all type Platforms.Word_Sizes; use all type Properties.Property'Class; use all type Release_Dependencies; use all type Release_Properties; @@ -190,14 +192,22 @@ package Alire.Index is -- REQUISITES -- ------------------ - function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree - renames Requisites.Platform.Compiler_Is_At_Least; + function Compiler_Is (V : Platforms.Compilers) return Requisites.Tree + renames Requisites.Platform.Compiler_Is; function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree renames Requisites.Platform.Distribution_Is; - function System_is (V : Platforms.Operating_Systems) return Requisites.Tree + function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree renames Requisites.Platform.System_Is; + + function Version_is (V : Platforms.Versions) return Requisites.Tree + renames Requisites.Platform.Version_Is; + + function Word_Size_Is (V : Platforms.Word_Sizes) return Requisites.Tree + renames Requisites.Platform.Word_Size_Is; + +-- function Version_Is (V : Platforms.Versions) return -- Other useful functions diff --git a/src/alire-platforms.ads b/src/alire-platforms.ads index 45533729..3cc621bb 100644 --- a/src/alire-platforms.ads +++ b/src/alire-platforms.ads @@ -10,22 +10,30 @@ package Alire.Platforms with Preelaborate is Windows, Unsupported); - type Distributions is (Debian_Buster, - Ubuntu_Xenial, - Ubuntu_Yakkety, - Ubunty_Zesty, - Ubuntu_Artful, + type Distributions is (Debian, + Ubuntu, Unsupported); + + type Versions is (Debian_Buster, + Ubuntu_Xenial, + Ubuntu_Yakkety, + Ubunty_Zesty, + Ubuntu_Artful, + Unsupported); -- Known flavors of OSs -- It turns out that Debian uses no numbers for its non-stable releases, so we'll prefer the codename -- Not really used very much for now + type Word_Sizes is (Bits_32, + Bits_64, + Unsupported); + type Package_Managers is (Apt, Unsupported); function Package_Manager (D : Distributions) return Package_Managers is (case D is - when Debian_Buster .. Ubuntu_Artful => Apt, + when Debian | Ubuntu => Apt, when others => Unsupported); end Alire.Platforms; diff --git a/src/alire-properties-platform.ads b/src/alire-properties-platform.ads index 771ed70c..c19970bf 100644 --- a/src/alire-properties-platform.ads +++ b/src/alire-properties-platform.ads @@ -2,13 +2,7 @@ with Alire.Platforms; package Alire.Properties.Platform with Preelaborate is - function Compiler_Is (C : Platforms.Compilers) return Vector; - - function Distribution_Is (D : Platforms.Distributions) return Vector; - - function System_Is (V : Platforms.Operating_Systems) return Vector; - - -- The following packages declare types used elsewhere so they have to be public -- + -- The following packages declare types used by requisites so they have to be public -- package Compilers is new Values (Platforms.Compilers, Platforms.Compilers'IMage); @@ -19,15 +13,21 @@ package Alire.Properties.Platform with Preelaborate is package Operating_Systems is new Values (Platforms.Operating_Systems, Platforms.Operating_Systems'Image); -private + package Versions is new Values (Platforms.Versions, + Platforms.Versions'Image); - function Compiler_Is (C : Platforms.Compilers) return Vector is - (+Compilers.New_Property (C)); + package Word_Sizes is new Values (Platforms.Word_Sizes, + Platforms.Word_Sizes'Image); - function Distribution_Is (D : Platforms.Distributions) return Vector is - (+Distributions.New_Property (D)); - function System_Is (V : Platforms.Operating_Systems) return Vector is - (+Operating_Systems.New_Property (V)); + function Compiler_Is (C : Platforms.Compilers) return Vector renames Compilers.New_Vector; + + function Distribution_Is (D : Platforms.Distributions) return Vector renames Distributions.New_Vector; + + function System_Is (OS : Platforms.Operating_Systems) return Vector renames Operating_Systems.New_Vector; + + function Version_Is (V : Platforms.Versions) return Vector renames Versions.New_Vector; + + function Word_Size_Is (V : Platforms.Word_Sizes) return Vector renames Word_Sizes.New_Vector; end Alire.Properties.Platform; diff --git a/src/alire-properties.ads b/src/alire-properties.ads index 9eaff4d4..dc792e38 100644 --- a/src/alire-properties.ads +++ b/src/alire-properties.ads @@ -41,6 +41,8 @@ package Alire.Properties with Preelaborate is function New_Property (V : Value) return Property; + function New_Vector (V : Value) return Vector; + function Element (P : Property) return Value; private @@ -53,6 +55,8 @@ package Alire.Properties with Preelaborate is function New_Property (V : Value) return Property is (V => V); + function New_Vector (V : Value) return Vector is (+New_Property (V)); + function Element (P : Property) return Value is (P.V); overriding function Image (P : Property) return String is (Image (P.V)); diff --git a/src/alire-releases.adb b/src/alire-releases.adb index 2e425503..df06d18e 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -117,7 +117,7 @@ package body Alire.Releases is end loop; end Print_Depvec; - procedure Print_Properties is new Print_Conditional (Conditional.For_Properties, Print_Propvec); + procedure Print_Properties is new Print_Conditional (Conditional.For_Properties, Print_Propvec); procedure Print_Dependencies is new Print_Conditional (Conditional.For_Dependencies, Print_Depvec); begin -- MILESTONE diff --git a/src/alire-requisites-platform.ads b/src/alire-requisites-platform.ads index afe570c4..5221fa58 100644 --- a/src/alire-requisites-platform.ads +++ b/src/alire-requisites-platform.ads @@ -1,89 +1,23 @@ with Alire.Platforms; with Alire.Properties.Platform; -with Alire.Utils; package Alire.Requisites.Platform with Preelaborate is - function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree; + package Plat renames Properties.Platform; - function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree; + package Compilers is new Typed_Value_Requisites (Plat.Compilers, "Compiler"); + function Compiler_Is (V : Platforms.Compilers) return Tree renames Compilers.New_Equality; - function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree; + package Distributions is new Typed_Value_Requisites (Plat.Distributions, "Distribution"); + function Distribution_Is (V : Platforms.Distributions) return Tree renames Distributions.New_Equality; -private + package Systems is new Typed_Value_Requisites (Plat.Operating_Systems, "OS"); + function System_Is (V : Platforms.Operating_Systems) return Tree renames Systems.New_Equality; - -- Preparation for OS requisites mimicking OS properties + package Versions is new Typed_Value_Requisites (Plat.Versions, "Version"); + function Version_Is (V : Platforms.Versions) return Tree renames Versions.New_Equality; - use all type Platforms.Compilers; - use all type Platforms.Distributions; - use all type Platforms.Operating_Systems; - - package Props renames Alire.Properties.Platform; - - package System_Requisites is new Typed_Requisites (Props.Operating_Systems.Property'Class); - - function Mix (S : String) return String renames Utils.To_Mixed_Case; - - type OS_Requisite is new System_Requisites.Requisite with record - Value : Platforms.Operating_Systems; - end record; - - overriding function Image (R : OS_Requisite) return String is - ("OS is " & Mix (R.Value'Image)); - - overriding function Is_Satisfied (R : OS_Requisite; - P : Props.Operating_Systems.Property'Class) return Boolean is - (R.Value = P.Element); - - - package Compiler_Requisites is new Typed_Requisites (Props.Compilers.Property'Class); - - type Compiler_Requisite is new Compiler_Requisites.Requisite with record - Value : Platforms.Compilers; - end record; - - overriding function Image (R : Compiler_Requisite) return String is - ("Compiler >= " & Mix (R.Value'Image)); - - overriding function Is_Satisfied (R : Compiler_Requisite; - P : Props.Compilers.Property'Class) return Boolean is - (R.Value <= P.Element); - - - package Distro_Requisites is new Typed_Requisites (Props.Distributions.Property'Class); - - type Distro_Requisite is new Distro_Requisites.Requisite with record - Value : Platforms.Distributions; - end record; - - overriding function Image (R : Distro_Requisite) return String is - ("Distribution is " & Mix (R.Value'Image)); - - overriding function Is_Satisfied (R : Distro_Requisite; - P : Props.Distributions.Property'Class) return Boolean is - (R.Value = P.Element); - - use all type Tree; - - -------------------------- - -- Compiler_Is_At_Least -- - -------------------------- - - function Compiler_Is_At_Least (V : Platforms.Compilers) return Requisites.Tree is - (+Compiler_Requisite'(Value => V)); - - --------------------- - -- Distribution_Is -- - --------------------- - - function Distribution_Is (V : Platforms.Distributions) return Requisites.Tree is - (+Distro_Requisite'(Value => V)); - - --------------- - -- System_Is -- - --------------- - - function System_Is (V : Platforms.Operating_Systems) return Requisites.Tree is - (+OS_Requisite'(Value => V)); + package Word_Sizes is new Typed_Value_Requisites (Plat.Word_Sizes, "Arquitecture width"); + function Word_Size_Is (V : Platforms.Word_Sizes) return Tree renames Word_Sizes.New_Equality; end Alire.Requisites.Platform; diff --git a/src/alire-requisites.ads b/src/alire-requisites.ads index d583dcc2..05294ebf 100644 --- a/src/alire-requisites.ads +++ b/src/alire-requisites.ads @@ -1,5 +1,6 @@ with Alire.Boolean_Trees; with Alire.Properties; +with Alire.Utils; package Alire.Requisites with Preelaborate is @@ -24,6 +25,29 @@ package Alire.Requisites with Preelaborate is function Image (R : Requisite) return String is abstract; -- A necessary pain to be able to report + -- Trees of requisites to be matched against a list of properties in a release + + function Satisfies (R : Requisite'Class; P : Properties.Vector) return Boolean; + -- True if any of the properties in the vector satisfies the requisite + + function Image_Class (R : Requisite'Class) return String is (R.Image); + + package Trees is new Boolean_Trees (Properties.Vector, + Requisite'Class, + Satisfies, + Image_Class); + + subtype Tree is Trees.Tree; + + function No_Requisites return Trees.Tree is (Trees.Empty_Tree); + -- Function instead of constant to keep Preelaborate + + ---------------------- + -- Typed_Requisites -- + ---------------------- + -- Using these we get free matching of properties to requisites + -- It is in essence a work around MI + generic type Compatible_Property (<>) is new Property with private; package Typed_Requisites is @@ -46,23 +70,55 @@ package Alire.Requisites with Preelaborate is then Requisite'Class (R).Is_Satisfied (Compatible_Property (P)) else False); + -- For free we get a requisite that is equality for value properties + end Typed_Requisites; - -- Trees of requisites to be matched against a list of properties in a release + -------------- + -- EXTRAS -- + -------------- - function Satisfies (R : Requisite'Class; P : Properties.Vector) return Boolean; - -- True if any of the properties in the vector satisfies the requisite + -- This following requisite is a typed_requisite for equality with the property + -- Concevably, this could be expanded to offer >=, <, <=... - function Image_Class (R : Requisite'Class) return String is (R.Image); + generic + with package Values is new Properties.Values (<>); + -- The property that encapsulates the requiiste value - package Trees is new Boolean_Trees (Properties.Vector, - Requisite'Class, - Satisfies, - Image_Class); + Name : String; -- used for image "Name is Mixed_Case (Image (Value))" + package Typed_Value_Requisites is - subtype Tree is Trees.Tree; + package Value_Requisites is new Typed_Requisites (Values.Property); - function No_Requisites return Trees.Tree is (Trees.Empty_Tree); - -- Function instead of constant to keep Preelaborate + type Equality is new Value_Requisites.Requisite with private; + + function New_Equality (V : Values.Value) return Tree; + + overriding function Is_Satisfied (R : Equality; + P : Values.Property) + return Boolean; + + overriding function Image (R : Equality) + return String; + + private + + function Mix (S : String) return String renames Utils.To_Mixed_Case; + use all type Values.Value; + + type Equality is new Value_Requisites.Requisite with record + Value : Values.Value; + end record; + + function New_Equality (V : Values.Value) return Tree is + (Trees.Leaf (Equality'(Value => V))); + + overriding function Is_Satisfied (R : Equality; P : Values.Property) return Boolean is + (R.Value = P.Element); + + overriding function Image (R : Equality) return String is + (Name & " is " & Mix (Values.Image (R.Value))); + + end Typed_Value_Requisites; end Alire.Requisites;