Lets you automate your average C/C++ binding creation process!
Now with D language target support!
Just as you expect, it takes your C/C++ headers and writes extern(C)/extern(C++) bindings!
Merely a simple script tool for parsing C/C++ source files based on clang compiler. In short - it searches for top level declarations and converts them to D usable form.
(void(0));
[1] - It operates on AST level, which is done AFTER preprocessing stage, and it seems there is no way to modify such stuff without writting temp copy and mix these two passes.
This tool is just a personal script for automating my daily binding making process. It may contain bugs, vulnerabilities, security holes, or holes. Use of this software may cause cancer (whatever this means), and/or your hamster's death, if you does not have a hamster it will summon one from another dimension and then kill it.
USE ON YOUR OWN RISK!
AT THIS POINT I AM NOT READY TO ACCEPT PULL REQUESTS, COME BACK LATER
*Clang 6 might work as well, but is not supported.
Please note that building LLVM alone will take about 45 minutes on my machine (AMD FX-8350, 16GB, SATA-3 SSD), and over 1.5 hours with Clang
mkdir build
cd build
cmake ../ -DCMAKE_GENERATOR_PLATFORM=x64 -DLLVM_DIR=/path/to/llvm/build
cmake --build . --config Release
extra step for dub builds
cd ..
./dubBuild
-DCMAKE_GENERATOR_PLATFORM=x64
here is not required, just shows how to quickly generate x64 on Windows
-DGENTOOL_LIB=ON
can be used to build library usable with D main executable, doing this will generate dubBuild.{sh|bat}
file with set up paths and variables for building with dub
Linux note:
It may fail to link due to lib order, in this case try using lld linker
Note
Since Clang 9 some Linux package management systems taken a step to use LLVM/Clang as dynamic library, this is not recommended approach, in case if you have issues with it build and use static libs instead. Even though for personal use this might work, you are on your own.
After these steps you will have nice and compact 66 MB executable.
To build docker image simply run
docker build -t gentool .
Relax and enjoy Embrace the new pain and suffering possibilities when making extern(C)/extern(C++) bindings!