105 lines
3.1 KiB
Bash
105 lines
3.1 KiB
Bash
#!/usr/bin/env bash
|
|
CBUILD_VERSION=2.2.1
|
|
CONFIG_VERSION=1
|
|
|
|
PROJECT="cimgui"
|
|
CMP_C="gcc"
|
|
CMP_CPP="g++"
|
|
STD_C="c11"
|
|
STD_CPP="c++11"
|
|
WARN_C="-Wall -Wno-discarded-qualifiers -Wno-unused-parameter"
|
|
WARN_CPP="-Wall -Wno-unused-parameter"
|
|
SRC_C=""
|
|
SRC_CPP="imgui/imgui.cpp
|
|
imgui/imgui_demo.cpp
|
|
imgui/imgui_draw.cpp
|
|
imgui/imgui_tables.cpp
|
|
imgui/imgui_widgets.cpp
|
|
imgui/backends/imgui_impl_sdl2.cpp
|
|
imgui/backends/imgui_impl_sdlrenderer2.cpp
|
|
cimgui.cpp"
|
|
|
|
# Directory with dependency configs.
|
|
# See cbuild/example_dependency_configs
|
|
DEPENDENCY_CONFIGS_DIR='dependencies'
|
|
# List of dependency config files in DEPENDENCY_CONFIGS_DIR separated by space.
|
|
ENABLED_DEPENDENCIES=''
|
|
|
|
# OBJDIR structure:
|
|
# ├── objects/ - Compiled object files. Cleans on each call of build task
|
|
# ├── static_libs/ - Symbolic links to static libraries used by linker. Cleans on each call of build task.
|
|
# ├── static_libs/ - Symbolic links to dynamic libraries used by linker. Cleans on each call of build task.
|
|
# └── profile/ - gcc *.gcda profiling info files
|
|
OBJDIR="../obj"
|
|
OUTDIR="../bin"
|
|
|
|
# header include directories
|
|
INCLUDE="-I. -I./imgui -I../include/SDL2"
|
|
|
|
STATIC_LIB_FILE="$PROJECT.a"
|
|
# OS-specific options
|
|
case "$OS" in
|
|
WINDOWS)
|
|
SHARED_LIB_FILE="$PROJECT.dll"
|
|
LINKER_LIBS="-L../precompiled/$OS-$ARCH -l:SDL2.dll"
|
|
DEFINE="-DIMGUI_API=__declspec(dllexport)"
|
|
;;
|
|
LINUX)
|
|
SHARED_LIB_FILE="$PROJECT.so"
|
|
LINKER_LIBS="-lSDL2"
|
|
DEFINE="-DIMGUI_API=__attribute__((__visibility__(\"default\")))"
|
|
;;
|
|
*)
|
|
error "operating system $OS has no configuration variants"
|
|
;;
|
|
esac
|
|
|
|
# TASKS
|
|
case "$TASK" in
|
|
# creates shared library
|
|
build_shared_lib)
|
|
C_ARGS="-O2 -fpic -shared $DEFINE"
|
|
CPP_ARGS="$C_ARGS"
|
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
|
PRE_TASK_SCRIPT=
|
|
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
|
|
POST_TASK_SCRIPT=
|
|
;;
|
|
# creates shared library with debug symbols and no optimizations
|
|
build_shared_lib_dbg)
|
|
C_ARGS="-O0 -g3 -fpic -shared $DEFINE"
|
|
CPP_ARGS="$C_ARGS"
|
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
|
PRE_TASK_SCRIPT=
|
|
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
|
|
POST_TASK_SCRIPT=
|
|
;;
|
|
# creates static library
|
|
build_static_lib)
|
|
C_ARGS="-O2 $DEFINE"
|
|
CPP_ARGS="$C_ARGS"
|
|
PRE_TASK_SCRIPT=
|
|
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
|
|
POST_TASK_SCRIPT=
|
|
;;
|
|
# creates static library with debug symbols and no optimizations
|
|
build_static_lib_dbg)
|
|
C_ARGS="-O0 -g3 $DEFINE"
|
|
CPP_ARGS="$C_ARGS"
|
|
PRE_TASK_SCRIPT=
|
|
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
|
|
POST_TASK_SCRIPT=
|
|
;;
|
|
# deletes generated files
|
|
clean)
|
|
TASK_SCRIPT=cbuild/default_tasks/clean.sh
|
|
;;
|
|
# nothing to do
|
|
"" | no_task)
|
|
;;
|
|
# unknown task
|
|
*)
|
|
error "task <$TASK> not found"
|
|
;;
|
|
esac
|