aboutsummaryrefslogtreecommitdiff
path: root/bbot/machine-manifest.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-29 10:54:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-29 10:54:31 +0200
commita69f728a710bcc4e17913a57ffb01da076467bfb (patch)
treeb881854f9419975d87fdaf3b2f51db6492c97edf /bbot/machine-manifest.hxx
parentf179ab72a8c623383f68eac3e30635700d88dde9 (diff)
Convert to use utility library
Diffstat (limited to 'bbot/machine-manifest.hxx')
-rw-r--r--bbot/machine-manifest.hxx118
1 files changed, 118 insertions, 0 deletions
diff --git a/bbot/machine-manifest.hxx b/bbot/machine-manifest.hxx
new file mode 100644
index 0000000..efcdda4
--- /dev/null
+++ b/bbot/machine-manifest.hxx
@@ -0,0 +1,118 @@
+// file : bbot/machine-manifest.hxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : TBC; see accompanying LICENSE file
+
+#ifndef BBOT_MACHINE_MANIFEST_HXX
+#define BBOT_MACHINE_MANIFEST_HXX
+
+#include <map>
+
+#include <libbutl/manifest-forward.hxx>
+
+#include <libbbot/manifest.hxx> // machine_header
+
+#include <bbot/types.hxx>
+#include <bbot/utility.hxx>
+
+#include <bbot/bootstrap-manifest.hxx>
+
+namespace bbot
+{
+ // Machine type.
+ //
+ enum class machine_type {kvm, nspawn};
+
+ string
+ to_string (machine_type);
+
+ machine_type
+ to_machine_type (const string&); // Throws invalid_argument.
+
+ // Machine.
+ //
+ class machine_manifest: public machine_header_manifest
+ {
+ public:
+ machine_type type;
+ optional<string> mac; // Required in bootstrapped machine manifest.
+ optional<strings> options; // Note: could be quoted.
+
+ strings
+ unquoted_options () const; // Return empty if absent.
+
+ machine_manifest (std::string i,
+ std::string n,
+ std::string s,
+ machine_type t,
+ optional<string> m,
+ optional<strings> o)
+ : machine_header_manifest (std::move (i),
+ std::move (n),
+ std::move (s)),
+ type (t),
+ mac (std::move (m)),
+ options (std::move (o)) {}
+
+ public:
+ machine_manifest () = default; // VC export.
+ machine_manifest (butl::manifest_parser&, bool ignore_unknown = false);
+ machine_manifest (butl::manifest_parser&,
+ butl::manifest_name_value start,
+ bool ignore_unknown = false);
+
+ void
+ serialize (butl::manifest_serializer&) const;
+ };
+
+ // Toolchain.
+ //
+ class toolchain_manifest
+ {
+ public:
+
+ // Toolchain id (SHAXXX).
+ //
+ string id;
+
+ explicit
+ toolchain_manifest (string i): id (i) {}
+
+ public:
+ toolchain_manifest () = default; // VC export.
+ toolchain_manifest (butl::manifest_parser&, bool ignore_unknown = false);
+ toolchain_manifest (butl::manifest_parser&,
+ butl::manifest_name_value start,
+ bool ignore_unknown = false);
+
+ void
+ serialize (butl::manifest_serializer&) const;
+ };
+
+ // The manifest stored in <name>-<toolchain>/ consists of the machine
+ // manifest (original), toolchain manifest, and bootstrap manifest.
+ //
+ class bootstrapped_machine_manifest
+ {
+ public:
+ machine_manifest machine;
+ toolchain_manifest toolchain;
+ bootstrap_manifest bootstrap;
+
+ bootstrapped_machine_manifest (machine_manifest m,
+ toolchain_manifest t,
+ bootstrap_manifest b)
+ : machine (move (m)), toolchain (move (t)), bootstrap (move (b)) {}
+
+ public:
+ bootstrapped_machine_manifest () = default; // VC export.
+ bootstrapped_machine_manifest (butl::manifest_parser&,
+ bool ignore_unknown = false);
+
+ void
+ serialize (butl::manifest_serializer&) const;
+ };
+
+ using bootstrapped_machine_manifests = vector<bootstrapped_machine_manifest>;
+}
+
+#endif // BBOT_MACHINE_MANIFEST_HXX