The clang-bind is a project to generate python bindings for C++ code using clang python bindings and pybind11.
C++
libclang
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' | sudo tee -a /etc/apt/sources.list
echo 'deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y libclang-11-dev python3-clang-11
Python
pip install -r requirements.txt
- Go to
tests/test_project/
folder - Create a build folder
- Run
cmake ..
- Run
make -j$(nproc)
- Run
python ../../../clang_bind/parse.py --com ./ ../src/simple.cpp
- Run
python ../../../clang_bind/generate.py --com json/src/simple.json
The binding code will be available in pybind11-gen/src
folder.