diff --git a/index/alire-index-alire.ads b/index/alire-index-alire.ads index 2fe194df..59582566 100644 --- a/index/alire-index-alire.ads +++ b/index/alire-index-alire.ads @@ -9,13 +9,12 @@ package Alire.Index.Alire is Desc : constant Project_Description := "Alire project catalog and support files"; Latest : constant Release := - Register_Git (Name, - V ("0.1.0"), - Desc, - Repo, - "2b6d3f2a116cb7c18f392015c792038892815055", - Depends_On => - Within_Major (Semantic_Versioning.Latest) and - Within_Major (Simple_Logging.V_1)); + Register (Name, + V ("0.1.0"), + Desc, + Git (Repo, "2b6d3f2a116cb7c18f392015c792038892815055"), + Depends_On => + Within_Major (Semantic_Versioning.Latest) and + Within_Major (Simple_Logging.V_1)); end Alire.Index.Alire; diff --git a/index/alire-index-alr.ads b/index/alire-index-alr.ads index 7eef3865..3fecb7da 100644 --- a/index/alire-index-alr.ads +++ b/index/alire-index-alr.ads @@ -9,13 +9,12 @@ package Alire.Index.Alr is Desc : constant Project_Description := "Command-line tool from the Alire project"; Latest : constant Release := - Register_Git (Name, - V ("0.1.0"), - Desc, - Repo, - "10a98e9d14ea129271e5de9a3a4e46a14610fbc2", - Depends_On => - Within_Major (Alire.Latest) and - Within_Major (Simple_Logging.V_1)); + Register (Name, + V ("0.1.0"), + Desc, + Git (Repo, "10a98e9d14ea129271e5de9a3a4e46a14610fbc2"), + Depends_On => + Within_Major (Alire.Latest) and + Within_Major (Simple_Logging.V_1)); end Alire.Index.Alr; diff --git a/index/alire-index-hello.ads b/index/alire-index-hello.ads index cbc10aec..e285496f 100644 --- a/index/alire-index-hello.ads +++ b/index/alire-index-hello.ads @@ -8,19 +8,17 @@ package Alire.Index.Hello is Desc : constant Project_Description := """Hello, world!"" demonstration project"; V_1_0_0 : constant Release := - Register_Git (Name, + Register (Name, V ("1.0.0"), Desc, - Repo, - "8cac0afddc505794ae3e5634745ce0830129d241", + Git (Repo, "8cac0afddc505794ae3e5634745ce0830129d241"), Depends_On => Within_Major (Libhello.V_1_0_0)); V_1_0_1 : constant Release := - Register_Git (Name, + Register (Name, V ("1.0.1"), Desc, - Repo, - "65725c20778875eef12b61a01b437120932965f3", + Git (Repo, "65725c20778875eef12b61a01b437120932965f3"), Depends_On => 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 d32be91b..b537490c 100644 --- a/index/alire-index-libhello.ads +++ b/index/alire-index-libhello.ads @@ -6,10 +6,9 @@ package Alire.Index.Libhello is 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"); + Register (Name, + V ("1.0.0"), + Desc, + Git (Repo, "ce78e7706c9d3f97605df48d8befca5407f8d328")); end Alire.Index.Libhello; diff --git a/index/alire-index-rxada.ads b/index/alire-index-rxada.ads index 3617a023..83946360 100644 --- a/index/alire-index-rxada.ads +++ b/index/alire-index-rxada.ads @@ -1,15 +1,14 @@ package Alire.Index.RxAda is Name : constant Project_Name := "rxada"; - Repo : constant URL := "https://bitbucket.org/amosteo/rxada.git"; + Repo : constant URL := "https://bitbucket.org/amosteo/rxada"; Desc : constant Project_Description := "RxAda port of the Rx framework"; V_0_1_0 : constant Release := - Register_Git (Name, - V ("0.1.0"), - Desc, - Repo, - "361d4e2ab20a7dcca007e31bf7094d57b13fee6b"); + Register (Name, + V ("0.1.0"), + Desc, + Hg (Repo, "361d4e2ab20a7dcca007e31bf7094d57b13fee6b")); end Alire.Index.RxAda; diff --git a/index/alire-index-semantic_versioning.ads b/index/alire-index-semantic_versioning.ads index 82fd598e..edef4469 100644 --- a/index/alire-index-semantic_versioning.ads +++ b/index/alire-index-semantic_versioning.ads @@ -6,10 +6,9 @@ package Alire.Index.Semantic_Versioning is Desc : constant Project_Description := "Semantic Versioning for Ada"; Latest : constant Release := - Register_Git (Name, - V ("0.1.0"), - Desc, - Repo, - "9f35b00a31861ea96085ee553fb6335d74831f5c"); + Register (Name, + V ("0.1.0"), + Desc, + Git (Repo, "9f35b00a31861ea96085ee553fb6335d74831f5c")); end Alire.Index.Semantic_Versioning; diff --git a/index/alire-index-simple_logging.ads b/index/alire-index-simple_logging.ads index 293e7fa6..bc7da6df 100644 --- a/index/alire-index-simple_logging.ads +++ b/index/alire-index-simple_logging.ads @@ -6,10 +6,9 @@ package Alire.Index.Simple_Logging is Desc : constant Project_Description := "Simple logging to console"; V_1 : constant Release := - Register_Git (Name, - V ("1.0.1"), - Desc, - Repo, - "0d5ab8764f667107892a0c832a7a70a2c6b7efe2"); + Register (Name, + V ("1.0.1"), + Desc, + Git (Repo, "0d5ab8764f667107892a0c832a7a70a2c6b7efe2")); end Alire.Index.Simple_Logging; diff --git a/src/alire-index.ads b/src/alire-index.ads index 90ab559d..53d144e1 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -40,22 +40,22 @@ package Alire.Index is -- 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. - function Register_Git (Project : Project_Name; - Version : Semantic_Versioning.Version; - Description : Project_Description; - Hosting : URL; - Commit : Origins.Git_Commit; - -- Optional - Properties : Alire.Properties.Vector := No_Properties; - Requisites : Alire.Requisites.Tree := No_Requisites; - Depends_On : Dependencies := No_Dependencies) return Release; + -- Shortcuts for common origins: + function Git (URL : Alire.URL; Commit : Origins.Git_Commit) return Origins.Origin renames Origins.New_Git; + function Hg (URL : Alire.URL; Commit : Origins.Hg_Commit) return Origins.Origin renames Origins.New_Hg; -- Shortcuts to give dependencies: function V (Semantic_Version : String) return Semantic_Versioning.Version renames Semantic_Versioning.New_Version; + function Current (R : Release) return Dependencies; + -- Within the major of R, + -- it will accept the newest/oldest version according to the resolution policy (by default, newest) + -- Note: it might be older than R itself + function Within_Major (R : Release) return Dependencies; + function Within_Minor (R : Release) return Dependencies; function At_Least (R : Release) return Dependencies; function At_Most (R : Release) return Dependencies; @@ -67,7 +67,11 @@ package Alire.Index is subtype Version is Semantic_Versioning.Version; subtype Version_Set is Semantic_Versioning.Version_Set; + function Current (P : Project_Name) return Dependencies; + -- Will accept the newest/oldest version according to the resolution policy (by default, newest) + function Within_Major (P : Project_Name; V : Version) return Dependencies; + function Within_Minor (P : Project_Name; V : Version) return Dependencies; function At_Least (P : Project_Name; V : Version) return Dependencies; function At_Most (P : Project_Name; V : Version) return Dependencies; @@ -77,16 +81,18 @@ package Alire.Index is function Except (P : Project_Name; V : Version) return Dependencies; -- Shortcuts for properties/requisites: - + + use all type Alire.Dependencies.Vectors.Vector; use all type Compilers.Compilers; use all type Operating_Systems.Operating_Systems; - - use all type Dependencies; - use all type Properties.Property'Class; -- for "and" operator + use all type Properties.Property'Class; use all type Requisites.Requisite'Class; - use all type Requisites.Tree; -- for logical operators + use all type Requisites.Tree; + -- These "use all" are useful for alire-index-* packages, but not for project_alr metadata files Default_Properties : constant Properties.Vector := No_Properties; + + function "and" (Dep1, Dep2 : Dependencies) return Dependencies renames Alire.Dependencies.Vectors."and"; function Verifies (P : Properties.Property'Class) return Properties.Vector; function "+" (P : Properties.Property'Class) return Properties.Vector renames Verifies; @@ -114,29 +120,18 @@ package Alire.Index is -- Otherwise alr does not know what's the current project, and its version and dependencies -- The returned Release is the same; this is just a trick to be able to use it in an spec file. -private - - function Register_Git (Project : Project_Name; - Version : Semantic_Versioning.Version; - Description : Project_Description; - Hosting : URL; - Commit : Origins.Git_Commit; - Properties : Alire.Properties.Vector := No_Properties; - Requisites : Alire.Requisites.Tree := No_Requisites; - Depends_On : Dependencies := No_Dependencies) return Release - is (Register (Project, - Version, - Description, - Origins.New_Git (Hosting, Commit), - Depends_On, - Properties => Properties, - Requisites => Requisites, - Native => False)); - +private + use Semantic_Versioning; + function Current (R : Release) return Dependencies is + (New_Dependency (R.Project, Within_Major (New_Version (Major (R.Version))))); + function Within_Major (R : Release) return Dependencies is (New_Dependency (R.Project, Within_Major (R.Version))); + + function Within_Minor (R : Release) return Dependencies is + (New_Dependency (R.Project, Within_Minor (R.Version))); function At_Least (R : Release) return Dependencies is (New_Dependency (R.Project, At_Least (R.Version))); @@ -157,8 +152,14 @@ private (New_Dependency (R.Project, Except (R.Version))); + function Current (P : Project_Name) return Dependencies is + (New_Dependency (P, At_Least (V ("0.0.0")))); + function Within_Major (P : Project_Name; V : Version) return Dependencies is - (New_Dependency (P, Within_Major (V))); + (New_Dependency (P, Within_Major (V))); + + function Within_Minor (P : Project_Name; V : Version) return Dependencies is + (New_Dependency (P, Within_Minor (V))); function At_Least (P : Project_Name; V : Version) return Dependencies is (New_Dependency (P, At_Least (V))); diff --git a/src/alire-origins.ads b/src/alire-origins.ads index f8244cc1..c7fba9ed 100644 --- a/src/alire-origins.ads +++ b/src/alire-origins.ads @@ -7,10 +7,11 @@ package Alire.Origins with Preelaborate is -- The actual capabilities for check-outs or fetches are in alr proper - type Kinds is (Filesystem, -- Not really an origin, but a working copy of a project + type Kinds is (Apt, -- Native platform package + Filesystem, -- Not really an origin, but a working copy of a project Git, -- Remote git repo - Local_Apt -- Native platform package - ); + Hg -- Remote hg repo + ); type Origin is tagged private; @@ -23,6 +24,7 @@ package Alire.Origins with Preelaborate is -- Helper types subtype Git_Commit is String (1 .. 40); + subtype Hg_Commit is String (1 .. 40); -- Constructors @@ -32,7 +34,11 @@ package Alire.Origins with Preelaborate is Id : Git_Commit) return Origin; - function New_Local_Apt (Id_As_Package_Name : String) return Origin; + function New_Hg (URL : Alire.URL; + Id : Hg_Commit) + return Origin; + + function New_Apt (Id_As_Package_Name : String) return Origin; private @@ -56,7 +62,14 @@ private To_Unbounded_String (URL), To_Unbounded_String (Id)); - function New_Local_Apt (Id_As_Package_Name : String) return Origin is + function New_Hg (URL : Alire.URL; + Id : Hg_Commit) + return Origin is + (Hg, + To_Unbounded_String (URL), + To_Unbounded_String (Id)); + + function New_Apt (Id_As_Package_Name : String) return Origin is (Filesystem, To_Unbounded_String (Id_As_Package_Name), Null_Unbounded_String); diff --git a/src/alire-query.adb b/src/alire-query.adb index a33fe96b..80a5b900 100644 --- a/src/alire-query.adb +++ b/src/alire-query.adb @@ -119,6 +119,11 @@ package body Alire.Query is begin Success := False; + if Deps.Is_Empty then + Success := True; + return Empty_Instance; + end if; + return I : constant Instance := Resolve (Deps, Containers.Project_Release_Maps.Empty_Map, Success) do if not Success then Log ("Dependency resolution failed");