aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/bootstrap-manifest/driver.cxx
diff options
context:
space:
mode:
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;
+}