From cfd31379be5eefb22a72b5ee90ce8fd17a0802b7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 6 Apr 2017 19:46:03 +0300 Subject: Implement manifests --- unit-tests/bootstrap-manifest/driver.cxx | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 unit-tests/bootstrap-manifest/driver.cxx (limited to 'unit-tests/bootstrap-manifest/driver.cxx') 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_base::failbit, ios_base::badbit +#include + +#include +#include + +#include +#include + +#include + +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; +} -- cgit v1.1