blob: f4fb702e562a6e9eb58e4bbe0a40ae6242f39ba2 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/bin/bash
OPTIMIZATION="-O2" # Enable optimization.
DEBUG=0 # Compile with debug UI.
IMGUI=1 # Compile ImGui libs. Our custom ImGui functions still compile on zero.
PERF=0 # Print cycle stats.
STABLE=1 # Compile experimental stable-diffusion-webui support; requires curl.
# Add flag overrides to this file (it's untracked on the tree)
if test -f build_ops; then
source build_ops
fi
FFMPEG_LIBS="
libavdevice
libavformat
libavfilter
libavcodec
libswresample
libswscale
libavutil
"
IMGUI_FILES="
imgui
imgui_demo
imgui_draw
imgui_tables
imgui_widgets
"
IMGUI_FILES_IMPL="
imgui_impl_sdl
imgui_impl_opengl3
"
WARNING_FLAGS="
-Wall -Wextra \
-Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable \
-Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-but-set-parameter \
-Wno-missing-braces -Wno-format-security \
-fno-exceptions -Wno-strict-aliasing \
-Wno-write-strings
"
if [[ "$DEBUG" == 1 ]]; then
WARNING_FLAGS="$WARNING_FLAGS -DDEBUG=1"
fi
if [[ "$THREADED" == 1 ]]; then
WARNING_FLAGS="$WARNING_FLAGS -DTHREADED=1"
fi
if [[ "$PERF" == 1 ]]; then
WARNING_FLAGS="$WARNING_FLAGS -DPERF=1"
fi
if [[ "$STABLE" == 1 ]]; then
WARNING_FLAGS="$WARNING_FLAGS -DSTABLE=1"
OPTIONAL_FLAGS="$OPTIONAL_FLAGS -lcurl"
fi
if [[ "$(uname -m)" == "x86_64" ]]; then
ARCHNAME="x86"
ADDITIONAL_FLAGS="
-march=native
"
else
ARCHNAME="arm"
ADDITIONAL_FLAGS="
-march=armv8.5-a+sve
"
WARNING_FLAGS="$WARNING_FLAGS -DARM=1"
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
OSNAME="mac"
IMGUI_FLAGS="
-std=c++11 -Iimgui -Iimgui/backends $OPTIMIZATION -Wall -Wformat `sdl2-config --cflags` -I/usr/local/include -I/opt/local/include -c
"
SDL_ARGS="
`sdl2-config --cflags` -framework OpenGL -ldl `sdl2-config --libs`
"
else
OSNAME="linux"
IMGUI_FLAGS="
-Iimgui -Iimgui/backends $OPTIMIZATION -Wall -Wformat `sdl2-config --cflags` -c
"
SDL_ARGS="
`sdl2-config --cflags` -lGL -ldl `sdl2-config --libs`
"
fi
GLAD_FLAGS="
-Ilib/glad/include
"
[[ -d bin ]] || mkdir bin
clang $IMGUI_FLAGS -o bin/my_imgui_internal_widgets.o my_imgui_internal_widgets.cpp
if [[ "$IMGUI" == 1 ]]; then
for i in $IMGUI_FILES
do
clang $IMGUI_FLAGS -o bin/$i.o imgui/$i.cpp
done
for i in $IMGUI_FILES_IMPL
do
clang $IMGUI_FLAGS -o bin/$i.o imgui/backends/$i.cpp
done
fi
clang lib/glad.c $GLAD_FLAGS -I/usr/local/include -I/opt/local/include -c \
$WARNING_FLAGS $OPTIMIZATION $ADDITIONAL_FLAGS -o bin/glad.o
clang main.cpp $WARNING_FLAGS $OPTIMIZATION $ADDITIONAL_FLAGS -o bin/real2d_"$ARCHNAME"_"$OSNAME" bin/*.o \
$GLAD_FLAGS \
-std=c++11 -lstdc++ -Iimgui -Iimgui/backends \
$SDL_ARGS \
$OPTIONAL_FLAGS \
-I . \
-lm -I /usr/local/include # $(pkg-config --cflags --libs $FFMPEG_LIBS)
if [[ "$OSTYPE" =~ ^darwin ]]; then
mv bin/real2d_"$ARCHNAME"_"$OSNAME" lib/mac_app_template/Contents/MacOS/real
mkdir bin/real_"$ARCHNAME".app
cp -r lib/mac_app_template/Contents bin/real_"$ARCHNAME".app
xattr -cr bin/real_"$ARCHNAME".app
dylibbundler -od -b -x bin/real_"$ARCHNAME".app/Contents/MacOS/real -d bin/real_"$ARCHNAME".app/Contents/libs
fi
|