From 01db1970af29b2e2bb7bae22d85f7e46fe7c3ece Mon Sep 17 00:00:00 2001 From: Jano at Zelda Date: Wed, 14 Feb 2018 21:37:24 +0100 Subject: [PATCH] Descriptions and assorted fixes --- index/alire-index-example_dependencies.ads | 1 + index/alire-index-hello.ads | 14 ++++--- index/alire-index-libhello.ads | 11 +++-- index/alire-index-simple_logging.ads | 3 ++ src/alire-index.adb | 14 ++++--- src/alire-index.ads | 17 +++++--- src/alire-releases.ads | 48 ++++++++++++---------- src/alire.ads | 15 ++++++- src/alire_early_elaboration.adb | 34 +++++++-------- 9 files changed, 97 insertions(+), 60 deletions(-) diff --git a/index/alire-index-example_dependencies.ads b/index/alire-index-example_dependencies.ads index d0388ea5..18990bfe 100644 --- a/index/alire-index-example_dependencies.ads +++ b/index/alire-index-example_dependencies.ads @@ -5,6 +5,7 @@ package Alire.Index.Example_Dependencies is V_1_0_0 : constant Release := Register ("example_dependencies", V ("1.0.0"), + "Release with assorted advanced dependency conditions", Repositories.Local.Repo, Repositories.Local.Local_Id, Available_When => -- Note that it's impossible diff --git a/index/alire-index-hello.ads b/index/alire-index-hello.ads index bb086520..bc8adaaa 100644 --- a/index/alire-index-hello.ads +++ b/index/alire-index-hello.ads @@ -4,19 +4,23 @@ package Alire.Index.Hello is Name : constant Project_Name := "hello"; Repo : constant URL := "https://bitbucket.org/aleteolabs/hello.git"; - - V_1_0_0 : constant Release := + + Desc : constant Project_Description := """Hello, world!"" demonstration project"; + + V_1_0_0 : constant Release := Register_Git (Name, V ("1.0.0"), + Desc, Repo, "8cac0afddc505794ae3e5634745ce0830129d241", Depends_On => At_Least_Within_Major (Libhello.V_1_0_0)); - - V_1_0_1 : constant Release := + + V_1_0_1 : constant Release := Register_Git (Name, V ("1.0.1"), + Desc, Repo, "65725c20778875eef12b61a01b437120932965f3", Depends_On => At_Least_Within_Major (Libhello.V_1_0_0)); - + end Alire.Index.Hello; diff --git a/index/alire-index-libhello.ads b/index/alire-index-libhello.ads index 5fb2104e..d32be91b 100644 --- a/index/alire-index-libhello.ads +++ b/index/alire-index-libhello.ads @@ -1,11 +1,14 @@ package Alire.Index.Libhello is - - Name : constant Project_Name := "libhello"; + + Name : constant Project_Name := "libhello"; Repo : constant URL := "https://bitbucket.org/aleteolabs/libhello.git"; - - V_1_0_0 : constant Release := + + Desc : constant Project_Description := "A sample dependency for the hello project"; + + V_1_0_0 : constant Release := Register_Git (Name, V ("1.0.0"), + Desc, Repo, "ce78e7706c9d3f97605df48d8befca5407f8d328"); diff --git a/index/alire-index-simple_logging.ads b/index/alire-index-simple_logging.ads index cf343b41..6e5a67f7 100644 --- a/index/alire-index-simple_logging.ads +++ b/index/alire-index-simple_logging.ads @@ -3,9 +3,12 @@ package Alire.Index.Simple_Logging is Name : constant Project_Name := "simple_logging"; Repo : constant URL := "https://github.com/mosteo/simple_logging.git"; + Desc : constant Project_Description := "Simple logging to console"; + V_1_0_0 : constant Release := Register_Git (Name, V ("1.0.0"), + Desc, Repo, "77896e4a9d0539a63e6bfb657ab955656c2e3c0f"); diff --git a/src/alire-index.adb b/src/alire-index.adb index 919e8799..1c7c40b3 100644 --- a/src/alire-index.adb +++ b/src/alire-index.adb @@ -9,19 +9,21 @@ package body Alire.Index is -- Register -- -------------- - function Register (Project : Project_Name; - Version : Semantic_Versioning.Version; - Hosting : Repositories.Repository'Class; - Id : Repositories.Release_Id; - Depends_On : Dependencies := Depends.Nothing; + function Register (Project : Project_Name; + Version : Semantic_Versioning.Version; + Description : Project_Description; + Hosting : Repositories.Repository'Class; + Id : Repositories.Release_Id; + Depends_On : Dependencies := Depends.Nothing; Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector; Requisites : Alire.Requisites.Tree := Alire.Requisites.No_Requisites; Available_When : Alire.Requisites.Tree := Alire.Requisites.No_Requisites; - Native : Boolean := False) return Release + Native : Boolean := False) return Release is begin return Rel : constant Alire.Releases.Release := Alire.Releases.New_Release (Project, + Description, Version, Hosting, Id, diff --git a/src/alire-index.ads b/src/alire-index.ads index b85cb939..e8d6e264 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -21,11 +21,14 @@ package Alire.Index is subtype Release is Alire.Releases.Release; - function Register (Project : Project_Name; - Version : Semantic_Versioning.Version; + function Register (-- Mandatory + Project : Project_Name; + Version : Semantic_Versioning.Version; + Description : Project_Description; Hosting : Repositories.Repository'Class; - Id : Repositories.Release_Id; - Depends_On : Dependencies := Depends.Nothing; + Id : Repositories.Release_Id; + -- Optional + Depends_On : Dependencies := Depends.Nothing; Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector; Requisites : Alire.Requisites.Tree := Alire.Requisites.No_Requisites; Available_When : Alire.Requisites.Tree := Alire.Requisites.No_Requisites; @@ -36,11 +39,13 @@ package Alire.Index is function Register_Git (Project : Project_Name; Version : Semantic_Versioning.Version; + Description : Project_Description; Hosting : URL; Commit : Repositories.Git.Commit_ID; + -- Optional Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector; Requisites : Alire.Requisites.Tree := Alire.Requisites.No_Requisites; - Depends_On : Dependencies := Depends.Nothing) return Release; + Depends_On : Dependencies := Depends.Nothing) return Release; -- Shortcuts to give dependencies: @@ -97,6 +102,7 @@ private function Register_Git (Project : Project_Name; Version : Semantic_Versioning.Version; + Description : Project_Description; Hosting : URL; Commit : Repositories.Git.Commit_ID; Properties : Alire.Properties.Vector := Alire.Properties.Vectors.Empty_Vector; @@ -104,6 +110,7 @@ private Depends_On : Dependencies := Depends.Nothing) return Release is (Register (Project, Version, + Description, Repositories.Git.New_Repository (String (Hosting)), Repositories.Release_Id (Commit), Depends_On, diff --git a/src/alire-releases.ads b/src/alire-releases.ads index 17485795..967796cc 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -11,18 +11,20 @@ is type Release (<>) is tagged private; - function New_Release (Project : Project_Name; - Version : Semantic_Versioning.Version; - Repository : Repositories.Repository'Class; - Id : Repositories.Release_Id; - Depends_On : Dependencies; - Properties : Alire.Properties.Vector; - Requisites : Alire.Requisites.Tree; - Native : Boolean) return Release; + function New_Release (Name : Project_Name; + Description : Project_Description; + Version : Semantic_Versioning.Version; + Repository : Repositories.Repository'Class; + Id : Repositories.Release_Id; + Depends_On : Dependencies; + Properties : Alire.Properties.Vector; + Requisites : Alire.Requisites.Tree; + Native : Boolean) return Release; function "<" (L, R : Release) return Boolean; function Project (R : Release) return Project_Name; + function Description (R : Release) return Project_Description; function Version (R : Release) return Semantic_Versioning.Version; function Depends (R : Release) return Dependencies; function Repo_Image (R : Release) return String; @@ -43,8 +45,9 @@ is private - type Release (Name_Len, Id_Len : Positive) is tagged record - Project : Project_Name (1 .. Name_Len); + type Release (Name_Len, Descr_Len, Id_Len : Natural) is tagged record + Name : Project_Name (1 .. Name_Len); + Description: Project_Description (1 .. Descr_Len); Version : Semantic_Versioning.Version; Repository : Repositories.Repository_H; Id : Repositories.Release_Id (1 .. Id_Len); @@ -54,16 +57,18 @@ private Native : Boolean; end record; - function New_Release (Project : Project_Name; - Version : Semantic_Versioning.Version; - Repository : Repositories.Repository'Class; - Id : Repositories.Release_Id; - Depends_On : Dependencies; - Properties : Alire.Properties.Vector; - Requisites : Alire.Requisites.Tree; - Native : Boolean) return Release is - (Project'Length, Id'Length, - Project, + function New_Release (Name : Project_Name; + Description : Project_Description; + Version : Semantic_Versioning.Version; + Repository : Repositories.Repository'Class; + Id : Repositories.Release_Id; + Depends_On : Dependencies; + Properties : Alire.Properties.Vector; + Requisites : Alire.Requisites.Tree; + Native : Boolean) return Release is + (Name'Length, Description'Length, Id'Length, + Name, + Description, Version, Repositories.To_Holder (Repository), Id, @@ -79,7 +84,8 @@ private L.Version = R.Version and then L.Repository.Element.Image < R.Repository.Element.Image)); - function Project (R : Release) return Project_Name is (R.Project); + function Project (R : Release) return Project_Name is (R.Name); + function Description (R : Release) return Project_Description is (R.Description); function Version (R : Release) return Semantic_Versioning.Version is (R.Version); function Depends (R : Release) return Dependencies is (R.Depends_On); diff --git a/src/alire.ads b/src/alire.ads index ddec39b1..6e63b3b9 100644 --- a/src/alire.ads +++ b/src/alire.ads @@ -12,8 +12,19 @@ package Alire with Preelaborate is type URL is new String; - subtype Project_Name is String; - -- FIXME: add predicate on valid characters (must be a valid gnat filename part) + Max_Name_Length : constant := 72; -- Github maximum is 100 and bitbucket 128, but since Description is 72... + Max_Description_Length : constant := 72; -- Git line recommendation (although it's 50 for subject line) + + + subtype Project_Name is String with Dynamic_Predicate => + Project_Name'Length >= 3 and then + Project_Name'Length <= Max_Name_Length and then + Project_Name (Project_Name'First) /= '_' and then + (for all C of Project_Name => C in 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_'); + + + subtype Project_Description is String with Dynamic_Predicate => + Project_Description'Length <= Max_Description_Length; type Dependency (<>) is tagged private; diff --git a/src/alire_early_elaboration.adb b/src/alire_early_elaboration.adb index 0ea17554..470d2487 100644 --- a/src/alire_early_elaboration.adb +++ b/src/alire_early_elaboration.adb @@ -13,25 +13,25 @@ package body Alire_Early_Elaboration is procedure Early_Switch_Detection is use GNAT.Command_Line; - - Config : Command_Line_Configuration; - begin - Define_Switch (Config, - Switch_Q'Access, - "-q", - Help => "Limit output to errors"); - Define_Switch (Config, - Switch_V'Access, - "-v", - Help => "Be more verbose"); - Define_Switch (Config, - Switch_D'Access, - "-d", - Help => "Be even more verbose (including debug messages)"); - - Getopt (Config); + -- We use the simpler Getopt form to avoid built-in help and other shenanigans + begin + loop + case Getopt ("* d q v") is + when ASCII.NUL => exit; + when 'd' => Switch_D := True; + when 'q' => Switch_Q := True; + when 'v' => Switch_V := True; + when others => null; + end case; + end loop; + exception + when Exit_From_Command_Line => + -- Something unexpected happened but it will be properly dealt with later on, + -- in the regular command-line parser + null; + end; -- Exclusivity check if (Switch_D and Switch_V) or (Switch_D and Switch_Q) or (Switch_V and Switch_Q) then