aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/bootstrap-manifest/driver.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-04-06 19:46:03 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-04-06 21:20:37 +0300
commitcfd31379be5eefb22a72b5ee90ce8fd17a0802b7 (patch)
tree19fa3727e1799c98938681f79328b60d63afff19 /unit-tests/bootstrap-manifest/driver.cxx
parente3af4c881790a95be2676a7f4fb8df4136f8a3f3 (diff)
Implement manifests
Diffstat (limited to 'unit-tests/bootstrap-manifest/driver.cxx')
-rw-r--r--unit-tests/bootstrap-manifest/driver.cxx62
1 files changed, 62 insertions, 0 deletions
diff --git a/unit-tests/bootstrap-manifest/driver.cxx b/unit-tests/bootstrap-manifest/driver.cxx
new file mode 100644
index 0000000..3531383
--- /dev/null
+++ b/unit-tests/bootstrap-manifest/driver.cxx
@@ -0,0 +1,62 @@
+// file : unit-tests/bootstrap-manifest/driver.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <ios> // ios_base::failbit, ios_base::badbit
+#include <iostream>
+
+#include <butl/manifest-parser>
+#include <butl/manifest-serializer>
+
+#include <bbot/types>
+#include <bbot/utility>
+
+#include <bbot/bootstrap-manifest>
+
+using namespace std;
+using namespace butl;
+using namespace bbot;
+
+// Usage: argv[0] (-t|-b|-bm)
+//
+// Read and parse manifest from STDIN and serialize it to STDOUT. The
+// following options specify the manifest type.
+//
+// -t parse toolchain manifest
+// -b parse bootstrap manifest
+// -bm parse bootstrapped machine manifest
+//
+int
+main (int argc, char* argv[])
+try
+{
+ assert (argc == 2);
+ string opt (argv[1]);
+
+ cin.exceptions (ios_base::failbit | ios_base::badbit);
+ cout.exceptions (ios_base::failbit | ios_base::badbit);
+
+ manifest_parser p (cin, "stdin");
+ manifest_serializer s (cout, "stdout");
+
+ if (opt == "-t")
+ toolchain_manifest (p).serialize (s);
+ else if (opt == "-b")
+ bootstrap_manifest (p).serialize (s);
+ else if (opt == "-bm")
+ bootstrapped_machine_manifest (p).serialize (s);
+ else
+ assert (false);
+
+ return 0;
+}
+catch (const manifest_parsing& e)
+{
+ cerr << e << endl;
+ return 1;
+}
+catch (const manifest_serialization& e)
+{
+ cerr << e << endl;
+ return 1;
+}