forked from bullno1/cosmo-sokol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·65 lines (50 loc) · 1.55 KB
/
build
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh -e
COSMOS="${COSMOS:-/opt/cosmos}"
if ! [ -d "${COSMOS}" ] && ! [ -f "${COSMOS}/bin/cosmocc" ]
then
if ! command -v cosmocc >/dev/null
then
echo "You need to add cosmopolitan toolchain to your environment variable:"
echo "export COSMOS=/opt/cosmos"
exit 1
fi
COSMOS="$(dirname "$(dirname "$(command -v cosmocc)")")"
fi
export COSMOS
FLAGS="-I deps/sokol \
-I deps/cimgui \
-mcosmo \
-mtiny \
-Wall"
LINUX_FLAGS="${FLAGS} -Ishims/linux"
WIN32_FLAGS="${FLAGS} -Ishims/win32 -I${COSMOS}/include/libc/nt"
mkdir -p .build
mkdir -p bin
rm -f .build/commands
compile() {
echo scripts/compile "$@" >> .build/commands
}
compile shims/sokol/sokol_windows.c ${WIN32_FLAGS}
compile shims/sokol/sokol_linux.c ${LINUX_FLAGS}
compile shims/sokol/sokol_shared.c ${FLAGS}
compile shims/sokol/sokol_cosmo.c ${FLAGS}
compile deps/cimgui/cimgui.cpp ${FLAGS}
compile deps/cimgui/imgui/imgui.cpp ${FLAGS}
compile deps/cimgui/imgui/imgui_demo.cpp ${FLAGS}
compile deps/cimgui/imgui/imgui_draw.cpp ${FLAGS}
compile deps/cimgui/imgui/imgui_tables.cpp ${FLAGS}
compile deps/cimgui/imgui/imgui_widgets.cpp ${FLAGS}
compile shims/linux/gl.c ${LINUX_FLAGS}
compile shims/linux/x11.c ${LINUX_FLAGS}
compile nvapi/nvapi.c ${WIN32_FLAGS}
compile win32_tweaks.c ${WIN32_FLAGS}
compile main.c ${FLAGS} -Invapi
if [ -t 1 ]
then
PARALLEL_FLAGS="--bar"
else
PARALLEL_FLAGS="--progress"
fi
parallel $PARALLEL_FLAGS --max-procs "$(nproc)" :::: .build/commands
objects="$(find .build -name '*.o' -not -path '*.aarch64/*')"
"$COSMOS"/bin/cosmoc++ ${FLAGS} -o bin/cosmo-sokol $objects