blob: e2618e9d46690d91d81ec6b46f91f07ea258500f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
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 \
-Ilib/include \
--parse-from-main-header-dirs \
--create-output-dirs \
--overwrite-files \
--hs-output-dir lib \
--module RGFW.Generated \
--define-macro=RGFW_OPENGL \
--define-macro=RGFW_EXPORT \
--define-macro=RGFW_IMPLEMENTATION \
$HBC_ARGS \
RGFW.h
echo "# file tree generated:"
tree lib
set +x
|