A DSL for C API's to add consistency of naming schemes and comments.
You will need OCaml (>= 4.03; older versions may not work) and OPAM (at least 1.2). Instructions on how to install OCaml and OPAM can be found here.
For make coverage
you also need oasis
and bisect_ppx
. The coverage script
will attempt to install these if they are not yet installed.
Make sure to configure OPAM by running opam init
. (Depending on your
configuration you might also need to run eval `opam config env`
). Running
opam install ocamlfind ppx_deriving menhir
should install all dependencies
required for APIDSL.
Just run make
in APIDSL's root directory. The apidsl binary can be found
under ./_build/apigen.native
Alternatively, you can use Docker to build APIDSL. This is useful when your Linux distribution doesn't have the versions of dependencies required for APIDSL or you don't want to pollute your system by installing all those dependencies.
Get Docker on your system. Note that some versions of Debian and Ubuntu have it in their package repository.
Run the following. It takes about 4 minutes to run on my machine, so you can grab a cup of coffee/tea in the meantime.
# Clone this repository
git clone https://github.com/TokTok/apidsl
cd apidsl
# Build "apidsl" Docker image based on Dockerfile instructions
docker build -t apidsl .
# Run the image, i.e. execute the CMD part of the Dockerfile, mounting the
# current directory (the APIDSL repository) as /apidsl inside the image
docker run --rm -v $PWD:/apidsl apidsl
# Make sure apigen.native has appeared in the current directory
ls -lbh apigen.native
# Copy it over to /usr/local/bin
sudo cp ./apigen.native /usr/local/bin/
# Optional Cleanup
# Delete the image we have built
docker rmi apidsl ocaml/opam:alpine-3.15-ocaml-4.13-flambda-fp
# Make sure no related containers or images are left.
# They may use a lot of disk space.
docker ps -a
docker images -a
You should now have /usr/local/bin/apigen.native
.
TODO, but you can check some examples in tests directory.