#!/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=" libavformat libavfilter libavcodec libswresample libswscale libavutil " IMGUI_FILES=" imgui imgui_demo imgui_draw imgui_tables imgui_widgets 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 IMGUI_FLAGS=" -Idependencies/include/imgui -Idependencies/ $OPTIMIZATION -Wall -Wformat `sdl2-config --cflags` -c " if [[ "$OSTYPE" =~ ^darwin ]]; then OSNAME="mac" IMGUI_FLAGS=" $IMGUI_FLAGS -std=c++11 -I/usr/local/include -I/opt/local/include -c " SDL_ARGS=" `sdl2-config --cflags` -framework OpenGL -ldl `sdl2-config --libs` " else OSNAME="linux" SDL_ARGS=" `sdl2-config --cflags` -lGL -ldl `sdl2-config --libs` " fi [[ -d bin ]] || mkdir bin clang $IMGUI_FLAGS -MJ bin/imguihelper.json -Isrc/include -o bin/imgui_helper_internal.o src/imgui_helper_internal.cpp if [[ "$IMGUI" == 1 ]]; then for i in $IMGUI_FILES do clang $IMGUI_FLAGS -MJ bin/$i.json -o bin/$i.o dependencies/src/imgui/$i.cpp done fi clang dependencies/src/glad.c -MJ bin/glad.json -Idependencies/include -I/usr/local/include -I/opt/local/include -c \ $WARNING_FLAGS $OPTIMIZATION $ADDITIONAL_FLAGS -o bin/glad.o clang src/main.cpp -MJ bin/main.json $WARNING_FLAGS $OPTIMIZATION $ADDITIONAL_FLAGS -o bin/real2d_"$ARCHNAME"_"$OSNAME" bin/*.o \ -Idependencies/include -Idependencies/include/imgui -Idependencies/src -Isrc/include \ -std=c++11 -lstdc++ \ $SDL_ARGS \ $OPTIONAL_FLAGS \ -I . \ -lm $(pkg-config --cflags --libs $FFMPEG_LIBS) if [[ "$DEBUG" == 1 && "$(pidof gf2)" ]]; then echo "c ec compiled" > /tmp/control_pipe.dat fi # sed -e '1s/^/[\n/' -e '$s/,$/\n]/' bin/*.json > compile_commands.json if [[ "$OSTYPE" =~ ^darwin ]]; then mkdir bin/real_"$ARCHNAME".app cp -r misc/mac_app_template/Contents bin/real_"$ARCHNAME".app cp bin/real2d_"$ARCHNAME"_"$OSNAME" bin/real_"$ARCHNAME".app/Contents/MacOS/real 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