From e7f039156c1cd62eef386517a80cf27f7864ad82 Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Sat, 3 Mar 2018 01:08:27 +0100 Subject: [PATCH] Recovered search by property --- index/alire-index-alire.ads | 4 ++-- index/alire-index-alr.ads | 2 +- index/alire-index-dak.ads | 10 +++++----- index/alire-index-hello.ads | 4 ++-- src/alire-conditional_values.adb | 26 ++++++++++++++++++++++++++ src/alire-conditional_values.ads | 3 +++ src/alire-index.adb | 6 +++--- src/alire-index.ads | 4 ++-- src/alire-releases.adb | 26 +++++++++++++------------- src/alire-releases.ads | 6 +++--- src/alire-root_project.adb | 4 ++-- src/alire-root_project.ads | 2 +- 12 files changed, 63 insertions(+), 34 deletions(-) diff --git a/index/alire-index-alire.ads b/index/alire-index-alire.ads index 3dd148e6..251daf5c 100644 --- a/index/alire-index-alire.ads +++ b/index/alire-index-alire.ads @@ -13,7 +13,7 @@ package Alire.Index.Alire is V ("0.1.2"), Desc, Git (Repo, "e2dee2e147ae9e4d666567b53b108cbe61bc06e8"), - Depends_On => + Dependencies => Within_Minor (Semantic_Versioning.V_0_1) and Within_Major (Simple_Logging.V_1) ); @@ -25,7 +25,7 @@ package Alire.Index.Alire is "Release with all index syntax features", Origins.New_Filesystem ("/fake"), - Depends_On => + Dependencies => Current ("half_life_3") and -- unconditional If_Platform -- conditional (System_Is (GNU_Linux), diff --git a/index/alire-index-alr.ads b/index/alire-index-alr.ads index 71a652ad..1ff26564 100644 --- a/index/alire-index-alr.ads +++ b/index/alire-index-alr.ads @@ -13,7 +13,7 @@ package Alire.Index.Alr is V ("0.1.2"), Desc, Git (Repo, "4002536beea8aee12b455077df4dd144b409bde4"), - Depends_On => + Dependencies => Within_Major (Alire.V_0_1) and Within_Major (Simple_Logging.V_1)); diff --git a/index/alire-index-dak.ads b/index/alire-index-dak.ads index 17b4cbb2..ccc82ad1 100644 --- a/index/alire-index-dak.ads +++ b/index/alire-index-dak.ads @@ -65,7 +65,7 @@ package Alire.Index.DAK is V ("4.27"), Desc_Pre & "(base components)" & Desc_Post, Git (Repo, "542f02c9be86693f759fcb784a8462bc4b25f1f2"), - Depends_On => + Dependencies => Within_Major (Strings_Edit_V_4_27) and Within_Major (Tables_V_4_27), @@ -118,7 +118,7 @@ package Alire.Index.DAK is V ("4.27"), Desc_Pre & "(ntp)" & Desc_Post, Git (Repo, "34fb305d6ef360cde5e272b51409097a5de72017"), - Depends_On => + Dependencies => Within_Major (Components_V_4_27), Properties => @@ -137,7 +137,7 @@ package Alire.Index.DAK is V ("4.27"), Desc_Pre & "(sqlite)" & Desc_Post, Git (Repo, "6fda0f3f7494815c87b329f7411b9a49ff97b9ba"), - Depends_On => + Dependencies => Within_Major (Components_V_4_27), Properties => @@ -158,7 +158,7 @@ package Alire.Index.DAK is V ("4.27"), Desc_Pre & "(clients/servers)" & Desc_Post, Git (Repo, "008935d5a89396cc0c39afb39f04bf6a89a92058"), - Depends_On => + Dependencies => Within_Major (Components_V_4_27) and Within_Major (Components_Sqlite_V_4_27), @@ -210,7 +210,7 @@ package Alire.Index.DAK is V ("4.27"), Desc_Pre & "(client/servers over TLS)" & Desc_Post, Git (Repo, "ca72cf4150ae14ba6d40c3d2dd92c7846cb4cb5d"), - Depends_On => + Dependencies => Within_Major (Components_Connections_V_4_27) and Within_Major (LibGNUTLS.V_3_5_8), diff --git a/index/alire-index-hello.ads b/index/alire-index-hello.ads index 1cd3605e..9d22cfd1 100644 --- a/index/alire-index-hello.ads +++ b/index/alire-index-hello.ads @@ -12,14 +12,14 @@ package Alire.Index.Hello is V ("1.0.0"), Desc, Git (Repo, "8cac0afddc505794ae3e5634745ce0830129d241"), - Depends_On => Within_Major (Libhello.V_1_0_0)); + Dependencies => Within_Major (Libhello.V_1_0_0)); V_1_0_1 : constant Release := Register (Name, V ("1.0.1"), Desc, Git (Repo, "65725c20778875eef12b61a01b437120932965f3"), - Depends_On => Within_Major (Libhello.V_1_0_0)); + Dependencies => Within_Major (Libhello.V_1_0_0)); V_1_0 : Release renames V_1_0_1; diff --git a/src/alire-conditional_values.adb b/src/alire-conditional_values.adb index 29c27f5f..7cc60a91 100644 --- a/src/alire-conditional_values.adb +++ b/src/alire-conditional_values.adb @@ -39,6 +39,32 @@ package body Alire.Conditional_Values is end if; end "and"; + ---------------- + -- All_Values -- + ---------------- + + function All_Values (This : Conditional_Value) return Values is + + Result : Values; + + procedure Visit (V : Conditional_Value) is + begin + case V.Kind is + when Value => + Result := Result & V.Value; + when Condition => + V.True_Value.Iterate_Children (Visit'Access); + V.False_Value.Iterate_Children (Visit'Access); + when Vector => + raise Program_Error with "shouldn't happen"; + end case; + end Visit; + + begin + This.Iterate_Children (Visit'Access); + return Result; + end All_Values; + -------------- -- Evaluate -- -------------- diff --git a/src/alire-conditional_values.ads b/src/alire-conditional_values.ads index 75c94394..35446d45 100644 --- a/src/alire-conditional_values.ads +++ b/src/alire-conditional_values.ads @@ -31,6 +31,9 @@ package Alire.Conditional_Values with Preelaborate is -- Visitor will be called for any immediate non-vector value -- Vector children will be iterated too, so a flat hierarchy will be mimicked for those + function All_Values (This : Conditional_Value) return Values; + -- Returns all values herein, both true and false, at any depth + --------------- -- SINGLES -- --------------- diff --git a/src/alire-index.adb b/src/alire-index.adb index 1528716f..7ba8a21f 100644 --- a/src/alire-index.adb +++ b/src/alire-index.adb @@ -45,7 +45,7 @@ package body Alire.Index is Description : Project_Description; Origin : Origins.Origin; -- Optional - Depends_On : Release_Dependencies := No_Dependencies; + Dependencies : Release_Dependencies := No_Dependencies; Properties : Release_Properties := No_Properties; Available_When : Alire.Requisites.Tree := No_Requisites) return Release @@ -56,12 +56,12 @@ package body Alire.Index is Description, Version, Origin, - Depends_On, + Dependencies, Properties => Properties, Available => Available_When) do if Catalog.Contains (Rel) then - Log ("Attempt to register duplicate versions: " & Rel.Milestone.Image, Warning); + Trace.Error ("Attempt to register duplicate versions: " & Rel.Milestone.Image); else Catalog.Insert (Rel); end if; diff --git a/src/alire-index.ads b/src/alire-index.ads index a44593a2..c5cca776 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -39,7 +39,7 @@ package Alire.Index is Description : Project_Description; Origin : Origins.Origin; -- Optional - Depends_On : Release_Dependencies := No_Dependencies; + Dependencies : Release_Dependencies := No_Dependencies; Properties : Release_Properties := No_Properties; Available_When : Alire.Requisites.Tree := No_Requisites) return Release; @@ -211,7 +211,7 @@ package Alire.Index is function Set_Root_Project (Project : Alire.Project_Name; Version : Semantic_Versioning.Version; - Depends_On : Conditional.Dependencies := No_Dependencies) + Dependencies : Conditional.Dependencies := No_Dependencies) return Release renames Root_Project.Set; -- This function must be called in the working project alire file. -- Otherwise alr does not know what's the current project, and its version and dependencies diff --git a/src/alire-releases.adb b/src/alire-releases.adb index f3ed075f..2e425503 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -153,19 +153,19 @@ package body Alire.Releases is Search : constant String := To_Lower_Case (Str); begin --- for P of R.Properties.All_Values loop --- declare --- Text : constant String := --- To_Lower_Case --- ((if Utils.Contains (P.Image, ":") --- then Utils.Tail (P.Image, ':') --- else P.Image)); --- begin --- if Utils.Contains (Text, Search) then --- return True; --- end if; --- end; --- end loop; + for P of R.Properties.All_Values loop + declare + Text : constant String := + To_Lower_Case + ((if Utils.Contains (P.Image, ":") + then Utils.Tail (P.Image, ':') + else P.Image)); + begin + if Utils.Contains (Text, Search) then + return True; + end if; + end; + end loop; return False; end Property_Contains; diff --git a/src/alire-releases.ads b/src/alire-releases.ads index 950af1ac..ca984364 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -20,7 +20,7 @@ package Alire.Releases with Preelaborate is Description : Project_Description; Version : Semantic_Versioning.Version; Origin : Origins.Origin; - Depends_On : Conditional.Dependencies; + Dependencies : Conditional.Dependencies; Properties : Conditional.Properties; Available : Alire.Requisites.Tree) return Release; @@ -106,7 +106,7 @@ private Description : Project_Description; Version : Semantic_Versioning.Version; Origin : Origins.Origin; - Depends_On : Conditional.Dependencies; + Dependencies : Conditional.Dependencies; Properties : Conditional.Properties; Available : Alire.Requisites.Tree) return Release is (Name'Length, Description'Length, @@ -114,7 +114,7 @@ private Description, Version, Origin, - Depends_On, + Dependencies, Describe (Description) and Properties, Available); diff --git a/src/alire-root_project.adb b/src/alire-root_project.adb index 5862f683..712e3eed 100644 --- a/src/alire-root_project.adb +++ b/src/alire-root_project.adb @@ -32,7 +32,7 @@ package body Alire.Root_Project is function Set (Project : Alire.Project_Name; Version : Semantic_Versioning.Version; - Depends_On : Conditional.Dependencies := Conditional.For_Dependencies.Empty) + Dependencies : Conditional.Dependencies := Conditional.For_Dependencies.Empty) return Releases.Release is use Origins; @@ -44,7 +44,7 @@ package body Alire.Root_Project is Natural'Min (Descr'Length, Max_Description_Length)), Version, New_Filesystem (Ada.Directories.Current_Directory), - Depends_On, + Dependencies, Properties => Index.No_Properties, Available => Requisites.No_Requisites); begin diff --git a/src/alire-root_project.ads b/src/alire-root_project.ads index 00336827..a520208b 100644 --- a/src/alire-root_project.ads +++ b/src/alire-root_project.ads @@ -11,7 +11,7 @@ package Alire.Root_Project is function Set (Project : Project_Name; Version : Semantic_Versioning.Version; - Depends_On : Conditional.Dependencies := Conditional.For_Dependencies.Empty) + Dependencies : Conditional.Dependencies := Conditional.For_Dependencies.Empty) return Releases.Release; -- This function must be called in the working project alire file. -- Otherwise alr does not know what's the current project, and its version and dependencies