Skip to content

Instantly share code, notes, and snippets.

@bookshelfdave
Created July 29, 2012 02:53
Show Gist options
  • Save bookshelfdave/3195858 to your computer and use it in GitHub Desktop.
Save bookshelfdave/3195858 to your computer and use it in GitHub Desktop.
R O C
git clone [email protected]:basho/riak_pb.git
cd src
rm -f *.proto
rm -f *.piqi
rm -f *.cm*
cp ../riak_pb/src/*.proto ./
piqi of-proto riak.proto
piqi of-proto riak_kv.proto
piqi of-proto riak_search.proto
cat riak.piqi.additions >> riak.proto.piqi
# rename done to isdone. "done" is a keyword in OCaml
sed -i.orig -e"s/\.name done/\.name isdone \.proto-name \"done\""/ riak_kv.proto.piqi
piqic ocaml --pp riak.proto.piqi
piqic ocaml --pp riak_kv.proto.piqi
piqic ocaml --pp riak_search.proto.piqi
ocamlfind ocamlc -package piqi.runtime -c riak_piqi.ml
ocamlfind ocamlc -package piqi.runtime -c riak_kv_piqi.ml
ocamlfind ocamlc -package piqi.runtime -c riak_search_piqi.ml
ocamlfind ocamlc -o foo -package Unix -package piqi.runtime -linkpkg riak_piqi.cmo riak.ml
@alavrik
Copy link

alavrik commented Jul 30, 2012

(piqi author here) There's a better way to handle names that conflict with OCaml keywords. Instead of using sed, you can add an extension module named riak_kv.ocaml.piqi with the following lines:

.include [ .module riak_kv ]
.extend [
    (.field RpbListKeysResp.done RpbMapRedResp.done)
    .with.ocaml-name "isdone"
]

This module will be included automatically by piqic ocaml and it will add OCaml-specific names to the existing definitions.

The complete example is available here. Note that it requires the latest version from "dev" branch.

@bookshelfdave
Copy link
Author

@alavrik great, thank you! I will give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment