From c552070230c4ad9c92b516c28658b5c74c57e46b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 11 Jun 2015 18:12:09 +0200 Subject: Outline of parsing and serialization for manifest object model --- tests/manifest/buildfile | 11 +++++++++++ tests/manifest/driver.cxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tests/manifest/manifest | 4 ++++ 3 files changed, 61 insertions(+) create mode 100644 tests/manifest/buildfile create mode 100644 tests/manifest/driver.cxx create mode 100644 tests/manifest/manifest (limited to 'tests/manifest') diff --git a/tests/manifest/buildfile b/tests/manifest/buildfile new file mode 100644 index 0000000..ee23ca9 --- /dev/null +++ b/tests/manifest/buildfile @@ -0,0 +1,11 @@ +# file : tests/manifest/buildfile +# copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +import libs += libbutl #@@ hack to get -I + +exe{driver}: cxx{driver} ../../bpkg/lib{bpkg} $libs + +include ../../bpkg/ + +# test: ./driver manifest | diff -u manifest - diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx new file mode 100644 index 0000000..ff6005c --- /dev/null +++ b/tests/manifest/driver.cxx @@ -0,0 +1,46 @@ +// file : tests/manifest/driver.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include +#include + +#include +#include +#include + +using namespace std; +using namespace bpkg; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " " << endl; + return 1; + } + + try + { + ifstream ifs; + ifs.exceptions (ifstream::badbit | ifstream::failbit); + ifs.open (argv[1], ifstream::in | ifstream::binary); + + manifest_parser p (ifs, argv[1]); + manifests ms (p); + + manifest_serializer s (cout, "stdout"); + ms.serialize (s); + } + catch (const ios_base::failure&) + { + cerr << "io failure" << endl; + return 1; + } + catch (const std::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/tests/manifest/manifest b/tests/manifest/manifest new file mode 100644 index 0000000..25491ef --- /dev/null +++ b/tests/manifest/manifest @@ -0,0 +1,4 @@ +: 1 +name: libfoo +: +name: libbar -- cgit v1.1