diff options
Diffstat (limited to 'libbutl')
-rw-r--r-- | libbutl/.gitignore | 1 | ||||
-rw-r--r-- | libbutl/buildfile | 12 | ||||
-rw-r--r-- | libbutl/manifest-parser.bash.in | 7 | ||||
-rw-r--r-- | libbutl/manifest-serializer.bash.in | 3 | ||||
-rw-r--r-- | libbutl/manifest.cxx | 59 | ||||
-rw-r--r-- | libbutl/utility.bash.in | 12 |
6 files changed, 86 insertions, 8 deletions
diff --git a/libbutl/.gitignore b/libbutl/.gitignore new file mode 100644 index 0000000..6b2eb75 --- /dev/null +++ b/libbutl/.gitignore @@ -0,0 +1 @@ +manifest diff --git a/libbutl/buildfile b/libbutl/buildfile index 1255424..03dd084 100644 --- a/libbutl/buildfile +++ b/libbutl/buildfile @@ -2,8 +2,16 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file +import libs = libbutl%lib{butl} + ./: bash{$path.base($path.base(*.bash.in))} bash{utility}: in{utility} -bash{manifest-parser}: in{manifest-parser} bash{utility} -bash{manifest-serializer}: in{manifest-serializer} bash{utility} +bash{manifest-parser}: in{manifest-parser} bash{utility} exe{manifest} +bash{manifest-serializer}: in{manifest-serializer} bash{utility} exe{manifest} + +exe{manifest}: cxx{manifest} $libs + +# Install our binding support executables next to the modules. +# +exe{*}: install = bin/libbutl/ diff --git a/libbutl/manifest-parser.bash.in b/libbutl/manifest-parser.bash.in index 3ac2fc7..4af565a 100644 --- a/libbutl/manifest-parser.bash.in +++ b/libbutl/manifest-parser.bash.in @@ -22,12 +22,7 @@ fi # function butl_parse_manifest () { - printf ":1\0" - printf "name:foo\0" - printf "version:1.2.3\0" - printf "description:foo\nexecutable\0" - printf "depends:libfoo\0" - printf "depends:libbar\0" + "$(butl_path)/manifest" parse } # Start the manifest parsing co-process setting the following "return" diff --git a/libbutl/manifest-serializer.bash.in b/libbutl/manifest-serializer.bash.in index c180a4b..24eac65 100644 --- a/libbutl/manifest-serializer.bash.in +++ b/libbutl/manifest-serializer.bash.in @@ -17,6 +17,9 @@ fi # function butl_serialize_manifest () { + # @@ TODO + #"$(butl_path)/manifest" serialize + local n v while IFS=: read -r -d '' n v; do printf "$n: $v\n" diff --git a/libbutl/manifest.cxx b/libbutl/manifest.cxx new file mode 100644 index 0000000..9319b71 --- /dev/null +++ b/libbutl/manifest.cxx @@ -0,0 +1,59 @@ +// file : libbutl/manifest.cxx +// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <string> +#include <iostream> + +#include <libbutl/utility.mxx> +#include <libbutl/manifest-parser.mxx> +#include <libbutl/manifest-serializer.mxx> + +using namespace std; +using namespace butl; + +static int +cmd_parse () +{ + //@@ TODO + + const char m[] = + ":1\0" + "name:foo\0" + "version:1.2.3\0" + "description:foo\nexecutable\0" + "depends:libfoo\0" + "depends:libbar"; // Last \0 will be added. + + cout.write (m, sizeof (m)); + + return 0; +} + +static int +cmd_serialize () +{ + //@@ TODO + + return 0; +} + +int +main (int argc, char* argv[]) +{ + // We should switch to CLI if we need anything more elaborate. + // + if (argc < 2) + { + cerr << "error: missing command" << endl; + return 1; + } + + string c (argv[1]); + + if (c == "parse") return cmd_parse (); + if (c == "serialize") return cmd_serialize (); + + cerr << "error: unknown command '" << c << "'" << endl; + return 1; +} diff --git a/libbutl/utility.bash.in b/libbutl/utility.bash.in index e284c55..1face1a 100644 --- a/libbutl/utility.bash.in +++ b/libbutl/utility.bash.in @@ -12,3 +12,15 @@ if (( BASH_VERSINFO[0] < 4 || BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] < 3 )); echo 'error: bash 4.3 or later is required' 2>&1 exit 1 fi + +# Return the libbutl/ module directory. +# +# This is used to run the binding support executables. +# +function butl_path () +{ + # BASH_SOURCE[0] contains the source path of the function being executed + # (that is, us). + # + dirname "${BASH_SOURCE[0]}" +} |