diff options
Diffstat (limited to 'generate.sh')
| -rwxr-xr-x | generate.sh | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/generate.sh b/generate.sh index 87c9761..e2618e9 100755 --- a/generate.sh +++ b/generate.sh @@ -1,11 +1,51 @@ -echo "#" -echo "# generating library RGFW.Generated in folder lib" -echo "#" +set -x +echo "# copying header..." + +mkdir -p lib/include +cp rgfw/RGFW.h lib/include/RGFW.h + +echo "# creating flags for hs-bindgen-cli..." + +export CFLAGS=$(pkg-config --cflags x11 xcursor xrandr xi gl xrender xext xfixes) +HBC_ARGS="" + +for token in $CFLAGS; do + case "$token" in + -I* ) HBC_ARGS="$HBC_ARGS $token" ;; + -D* ) HBC_ARGS="$HBC_ARGS --define-macro ${token#-D}" ;; + * ) HBC_ARGS="$HBC_ARGS --clang-option $token" ;; + esac +done + +echo "# creating c file from header..." + +cat > lib/RGFW.c <<EOF +#define RGFW_IMPLEMENTATION +#define RGFW_OPENGL +#define RGFW_EXPORT +#include "RGFW.h" +EOF + +echo "# creating c object file..." + +clang -c lib/RGFW.c -o lib/RGFW.o $CFLAGS -Ilib/include + +echo "# generating library RGFW.Generated..." + hs-bindgen-cli preprocess \ - -Irgfw \ + -Ilib/include \ + --parse-from-main-header-dirs \ --create-output-dirs \ --overwrite-files \ --hs-output-dir lib \ --module RGFW.Generated \ - --clang-option=-DRGFW_OPENGL \ + --define-macro=RGFW_OPENGL \ + --define-macro=RGFW_EXPORT \ + --define-macro=RGFW_IMPLEMENTATION \ + $HBC_ARGS \ RGFW.h + +echo "# file tree generated:" +tree lib + +set +x |
