generate.sh (995B)
1 #!/usr/bin/env bash 2 3 set -xeu 4 5 # Build blend2d static lib. 6 cmake -S blend2d -B .build -DCMAKE_BUILD_TYPE=Release -DBLEND2D_STATIC=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 7 cmake --build .build --config Release --parallel 4 8 9 # Copy public headers (blend2d uses _p to indicate "private"). 10 rm -r .headers || true 11 mkdir -p .headers 12 fd -e .h -E "*_p.h" . blend2d/src/blend2d | xargs -I {} cp {} .headers/ 13 14 # On macOS, set SDKROOT so that brew versions of libclang can find system headers. 15 if [[ "$(uname)" == "Darwin" ]]; then 16 export SDKROOT=$(xcrun --show-sdk-path) 17 fi 18 19 # Generate bindings. 20 rm -r ./binding || true 21 odin run ./odin-c-bindgen/src -out:bindgen.bin -- . 22 23 # Copy static lib to binding folder. 24 cp .build/{blend2d.lib,libblend2d.a} ./binding 2>/dev/null || true 25 26 # Apply custom patches. 27 # This is required only because bindgen is a bit naive, duplicating 28 # symbols and it misses a symbol. 29 patch -p1 binding/api.odin patch/api.odin.patch 30 patch -p1 binding/object.odin patch/object.odin.patch