From ef0e6c709051fc46968d64dcf1c86bd197fe45c2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 6 Apr 2017 18:58:03 +0300 Subject: Invent notion of header for machine_manifest --- bbot/manifest | 16 +++++----------- bbot/manifest.cxx | 40 +++++++++++++++++----------------------- tests/buildtab/buildfile | 2 +- tests/manifest/buildfile | 2 +- tests/manifest/machine.test | 6 +++--- tests/variable/buildfile | 2 +- tests/variable/testscript | 2 +- 7 files changed, 29 insertions(+), 41 deletions(-) diff --git a/bbot/manifest b/bbot/manifest index bf0471e..2cedbb6 100644 --- a/bbot/manifest +++ b/bbot/manifest @@ -26,15 +26,14 @@ namespace bbot class LIBBBOT_EXPORT machine_manifest { public: + // A "machine header". + // std::string id; std::string name; + std::string summary; - // Absent if inside task_request_manifest. - // butl::optional type; - std::string summary; - machine_manifest (std::string i, std::string n, std::string s) : id (std::move (i)), name (std::move (n)), summary (std::move (s)) {} @@ -43,16 +42,11 @@ namespace bbot machine_manifest (butl::manifest_parser&, bool ignore_unknown = false); machine_manifest (butl::manifest_parser&, butl::manifest_name_value start, + bool header_only = false, bool ignore_unknown = false); void serialize (butl::manifest_serializer&) const; - - private: - machine_manifest (butl::manifest_parser&, - butl::manifest_name_value start, - bool in_list, - bool ignore_unknown); }; using machine_manifests = std::vector; @@ -72,7 +66,7 @@ namespace bbot // std::string fingerprint; - machine_manifests machines; + machine_manifests machines; // Only machine headers. public: task_request_manifest () = default; // VC export. diff --git a/bbot/manifest.cxx b/bbot/manifest.cxx index b9c623e..a40d633 100644 --- a/bbot/manifest.cxx +++ b/bbot/manifest.cxx @@ -80,13 +80,7 @@ namespace bbot } machine_manifest:: - machine_manifest (parser& p, name_value nv, bool iu) - : machine_manifest (p, nv, true, iu) - { - } - - machine_manifest:: - machine_manifest (parser& p, name_value nv, bool il, bool iu) + machine_manifest (parser& p, name_value nv, bool ho, bool iu) { auto bad_name = [&p, &nv] (const string& d) { @@ -131,9 +125,19 @@ namespace bbot name = move (v); } + else if (n == "summary") + { + if (!summary.empty ()) + bad_name ("machine summary redefinition"); + + if (v.empty ()) + bad_value ("empty machine summary"); + + summary = move (v); + } else if (n == "type") { - if (il) + if (ho) bad_name ("machine type not allowed"); if (type) @@ -148,16 +152,6 @@ namespace bbot type = static_cast (i - b); } - else if (n == "summary") - { - if (!summary.empty ()) - bad_name ("machine summary redefinition"); - - if (v.empty ()) - bad_value ("empty machine summary"); - - summary = move (v); - } else if (!iu) bad_name ("unknown name '" + n + "' in machine manifest"); } @@ -170,11 +164,11 @@ namespace bbot if (name.empty ()) bad_value ("no machine name specified"); - if (!il && !type) - bad_value ("no machine type specified"); - if (summary.empty ()) bad_value ("no machine summary specified"); + + if (!ho && !type) + bad_value ("no machine type specified"); } void machine_manifest:: @@ -186,6 +180,7 @@ namespace bbot s.next ("", "1"); // Start of manifest. s.next ("id", id); s.next ("name", name); + s.next ("summary", summary); if (type) { @@ -194,7 +189,6 @@ namespace bbot s.next ("type", machine_type_names[v]); } - s.next ("summary", summary); s.next ("", ""); // End of manifest. } @@ -265,7 +259,7 @@ namespace bbot // Parse machine manifests. // for (nv = p.next (); !nv.empty (); nv = p.next ()) - machines.emplace_back (machine_manifest (p, nv, iu)); + machines.emplace_back (machine_manifest (p, nv, true, iu)); if (machines.empty ()) bad_value ("no task request machines specified"); diff --git a/tests/buildtab/buildfile b/tests/buildtab/buildfile index f156dbf..466c8ad 100644 --- a/tests/buildtab/buildfile +++ b/tests/buildtab/buildfile @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -import libs += libbutl%lib{butl} +import libs = libbutl%lib{butl} exe{driver}: cxx{driver} ../../bbot/lib{bbot} $libs test{testscript} diff --git a/tests/manifest/buildfile b/tests/manifest/buildfile index 002dbb0..b9af8ef 100644 --- a/tests/manifest/buildfile +++ b/tests/manifest/buildfile @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -import libs += libbutl%lib{butl} +import libs = libbutl%lib{butl} exe{driver}: cxx{driver} ../../bbot/lib{bbot} $libs test{*} diff --git a/tests/manifest/machine.test b/tests/manifest/machine.test index cd50bd4..96619f9 100644 --- a/tests/manifest/machine.test +++ b/tests/manifest/machine.test @@ -15,8 +15,8 @@ test.options += -m : 1 id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 name: windows_10-msvc_14 - type: kvm summary: Windows 10 build 1607 with VC 14 update 3 + type: kvm EOF : nspawn @@ -25,8 +25,8 @@ test.options += -m : 1 id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 name: windows_10-msvc_14 - type: nspawn summary: Windows 10 build 1607 with VC 14 update 3 + type: nspawn EOF } @@ -36,8 +36,8 @@ $* <'stdin:6:1: error: single machine manifest expected' == 1 : 1 id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 name: windows_10-msvc_14 -type: kvm summary: Windows 10 build 1607 with VC 14 update 3 +type: kvm : EOI diff --git a/tests/variable/buildfile b/tests/variable/buildfile index 7fb5105..e9c0cf2 100644 --- a/tests/variable/buildfile +++ b/tests/variable/buildfile @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -import libs += libbutl%lib{butl} +import libs = libbutl%lib{butl} exe{driver}: cxx{driver} ../../bbot/lib{bbot} $libs test{testscript} diff --git a/tests/variable/testscript b/tests/variable/testscript index d3d9302..3269a37 100644 --- a/tests/variable/testscript +++ b/tests/variable/testscript @@ -7,7 +7,7 @@ test.options += -u : valid : { - $* <> EOO + $* <>EOO config.cc.coptions="-O3 -stdlib='libc++'" ab'c="x y"' var=xy -- cgit v1.1