diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-07-21 14:47:30 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-07-21 14:47:30 +0200 |
commit | 037ad0360056ec38eda1b3b8a74cd3ae4371630f (patch) | |
tree | 6d21bad6f694d8744107e2420d72660a135eda7a | |
parent | 03ff256dc44228c9465cd2040593a72b2d084d1e (diff) |
Add binding support executable stub for manifest parsing
-rw-r--r-- | .gitignore | 20 | ||||
-rw-r--r-- | build/root.build | 9 | ||||
-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 | ||||
-rw-r--r-- | manifest | 2 | ||||
-rw-r--r-- | repositories.manifest | 6 |
10 files changed, 123 insertions, 8 deletions
@@ -2,3 +2,23 @@ *.d *.bash + +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc diff --git a/build/root.build b/build/root.build index fdcf92b..88800ea 100644 --- a/build/root.build +++ b/build/root.build @@ -3,3 +3,12 @@ # license : MIT; see accompanying LICENSE file using bash + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx 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]}" +} @@ -16,5 +16,7 @@ build-exclude: windows*; Requires bash build-exclude: macos*; Requires bash >= 4.3 build-include: * requires: bash >= 4.3 +requires: c++14 depends: * build2 >= 0.8.0- depends: * bpkg >= 0.8.0- +depends: libbutl [0.8.0-a.0.1 0.8.0-a.1) diff --git a/repositories.manifest b/repositories.manifest new file mode 100644 index 0000000..6603e9c --- /dev/null +++ b/repositories.manifest @@ -0,0 +1,6 @@ +: 1 +summary: build2 utility library for bash repository + +: +role: prerequisite +location: ../libbutl.git##HEAD |