initial commit
This commit is contained in:
commit
2e1fcb9536
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# build results
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
src/generated/
|
||||||
|
imgui.ini
|
||||||
|
|
||||||
|
# IDE files
|
||||||
|
.vs/
|
||||||
|
.vshistory/
|
||||||
|
.editorconfig
|
||||||
|
*.user
|
||||||
|
*.vcxproj.filters
|
||||||
|
|
||||||
|
# other files
|
||||||
|
.old*/
|
||||||
|
old/
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
logs/
|
||||||
|
log/
|
||||||
|
*.log
|
||||||
10
.gitmodules
vendored
Normal file
10
.gitmodules
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[submodule "dependencies/imgui"]
|
||||||
|
path = dependencies/imgui
|
||||||
|
url = https://github.com/ocornut/imgui.git
|
||||||
|
branch = docking
|
||||||
|
[submodule "dependencies/imnodes"]
|
||||||
|
path = dependencies/imnodes
|
||||||
|
url = https://github.com/Nelarius/imnodes.git
|
||||||
|
[submodule "dependencies/resource_embedder"]
|
||||||
|
path = dependencies/resource_embedder
|
||||||
|
url = https://timerix.ddns.net:3322/Timerix/resource_embedder.git
|
||||||
1
.vscode/.gitignore
vendored
Normal file
1
.vscode/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
settings.json
|
||||||
17
.vscode/c_cpp_properties.json
vendored
Normal file
17
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "all",
|
||||||
|
"defines": [
|
||||||
|
"SDL_DISABLE_ANALYZE_MACROS",
|
||||||
|
"DEBUG=1"
|
||||||
|
],
|
||||||
|
"includePath": [
|
||||||
|
"dependencies/include/SDL2",
|
||||||
|
"dependencies/imgui",
|
||||||
|
"${default}"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
28
.vscode/launch.json
vendored
Normal file
28
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "gdb_debug",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/bin/ougge",
|
||||||
|
"windows": { "program": "${workspaceFolder}/bin/ougge.exe" },
|
||||||
|
"preLaunchTask": "build_exec_dbg",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}/bin",
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
32
.vscode/tasks.json
vendored
Normal file
32
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build_exec_dbg",
|
||||||
|
"detail": "build project with debug symbols",
|
||||||
|
"type": "cppbuild",
|
||||||
|
"command": "bash",
|
||||||
|
"args": [
|
||||||
|
"-c",
|
||||||
|
"cbuild build_exec_dbg"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher": ["$gcc"],
|
||||||
|
"group": {
|
||||||
|
"kind": "build"
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": true,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": false,
|
||||||
|
"clear": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
38
README.md
Normal file
38
README.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# ougge
|
||||||
|
A game engine or something, idk.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
1. Clone the repository
|
||||||
|
```sh
|
||||||
|
git clone --recurse-submodules https://timerix.ddns.net:3322/Timerix/ougge.git
|
||||||
|
```
|
||||||
|
2. Install [cbuild](https://timerix.ddns.net:3322/Timerix/cbuild.git)
|
||||||
|
3. Install **SDL2** from package manager or compile it from source.
|
||||||
|
**If you are using msys, switch to mingw64 sh.**
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/libsdl-org/SDL.git
|
||||||
|
cd SDL
|
||||||
|
./configure
|
||||||
|
make -j [number of cpu threads]
|
||||||
|
```
|
||||||
|
Then you can install it systemwide (on **Linux**):
|
||||||
|
```sh
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
or copy to ./dependencies/precompiled/ (on **Windows**):
|
||||||
|
```sh
|
||||||
|
mkdir -p ../ougge/dependencies/precompiled/
|
||||||
|
cp ./build/.libs/SDL2.dll ../ougge/dependencies/precompiled/
|
||||||
|
```
|
||||||
|
If it doesn't work, read [SDL/INSTALL.txt](https://github.com/libsdl-org/SDL/blob/SDL2/INSTALL.txt) and [SDL/docs/README.md](https://github.com/libsdl-org/SDL/blob/SDL2/docs/README.md).
|
||||||
|
4. Symlink SDL headers directory to `dependencies/include`
|
||||||
|
```sh
|
||||||
|
cd ../ougge
|
||||||
|
ln -s SDL2_HEADERS_DIRECTORY_ABSOLUTE_PATH -T dependencies/include/SDL2
|
||||||
|
```
|
||||||
|
Location of the headers can be found by `pkg-config --cflags --libs sdl2`.
|
||||||
|
Mingw installs SDL2 headers to `/mingw64/include/SDL2`.
|
||||||
|
5. Compile the program
|
||||||
|
```sh
|
||||||
|
cbuild build_exec_dbg
|
||||||
|
```
|
||||||
2
dependencies/.gitignore
vendored
Normal file
2
dependencies/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/include/
|
||||||
|
/precompiled/
|
||||||
1
dependencies/imgui
vendored
Submodule
1
dependencies/imgui
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 271910e3495e686a252b4b85369dec0605ba0d20
|
||||||
12
dependencies/imgui.config
vendored
Normal file
12
dependencies/imgui.config
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
DEP_WORKING_DIR='dependencies/imgui'
|
||||||
|
DEP_PRE_BUILD_COMMAND=''
|
||||||
|
if [[ "$TASK" = *_dbg ]]; then
|
||||||
|
DEP_BUILD_COMMAND='cbuild -c ../imgui.project.config build_static_lib_dbg'
|
||||||
|
else
|
||||||
|
DEP_BUILD_COMMAND='cbuild -c ../imgui.project.config build_static_lib'
|
||||||
|
fi
|
||||||
|
DEP_POST_BUILD_COMMAND=''
|
||||||
|
DEP_CLEAN_COMMAND='cbuild clean -c ../imgui.project.config'
|
||||||
|
DEP_STATIC_OUT_FILES='../bin/libimgui.a'
|
||||||
|
DEP_DYNAMIC_OUT_FILES=''
|
||||||
101
dependencies/imgui.project.config
vendored
Normal file
101
dependencies/imgui.project.config
vendored
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
CBUILD_VERSION=2.1.2
|
||||||
|
CONFIG_VERSION=1
|
||||||
|
|
||||||
|
PROJECT="imgui"
|
||||||
|
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.cpp
|
||||||
|
imgui_demo.cpp
|
||||||
|
imgui_draw.cpp
|
||||||
|
imgui_tables.cpp
|
||||||
|
imgui_widgets.cpp
|
||||||
|
backends/imgui_impl_sdl2.cpp
|
||||||
|
backends/imgui_impl_opengl3.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"
|
||||||
|
STATIC_LIB_FILE="lib$PROJECT.a"
|
||||||
|
|
||||||
|
# header include directories
|
||||||
|
INCLUDE="-I. -I../include/SDL2"
|
||||||
|
|
||||||
|
# OS-specific options
|
||||||
|
case "$OS" in
|
||||||
|
WINDOWS)
|
||||||
|
EXEC_FILE="$PROJECT.exe"
|
||||||
|
SHARED_LIB_FILE="lib$PROJECT.dll"
|
||||||
|
;;
|
||||||
|
LINUX)
|
||||||
|
EXEC_FILE="$PROJECT"
|
||||||
|
SHARED_LIB_FILE="lib$PROJECT.so"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "operating system $OS has no configuration variants"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# TASKS
|
||||||
|
case "$TASK" in
|
||||||
|
# creates shared library
|
||||||
|
build_shared_lib)
|
||||||
|
C_ARGS="-O2 -fpic -flto -shared"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS -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"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS -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"
|
||||||
|
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"
|
||||||
|
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
|
||||||
1
dependencies/imnodes
vendored
Submodule
1
dependencies/imnodes
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 8563e1655bd9bb1f249e6552cc6274d506ee788b
|
||||||
12
dependencies/imnodes.config
vendored
Normal file
12
dependencies/imnodes.config
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
DEP_WORKING_DIR='dependencies/imnodes'
|
||||||
|
DEP_PRE_BUILD_COMMAND=''
|
||||||
|
if [[ "$TASK" = *_dbg ]]; then
|
||||||
|
DEP_BUILD_COMMAND='cbuild -c ../imnodes.project.config build_static_lib_dbg'
|
||||||
|
else
|
||||||
|
DEP_BUILD_COMMAND='cbuild -c ../imnodes.project.config build_static_lib'
|
||||||
|
fi
|
||||||
|
DEP_POST_BUILD_COMMAND=''
|
||||||
|
DEP_CLEAN_COMMAND='cbuild clean -c ../imnodes.project.config'
|
||||||
|
DEP_STATIC_OUT_FILES='../bin/libimnodes.a'
|
||||||
|
DEP_DYNAMIC_OUT_FILES=''
|
||||||
95
dependencies/imnodes.project.config
vendored
Normal file
95
dependencies/imnodes.project.config
vendored
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
CBUILD_VERSION=2.1.2
|
||||||
|
CONFIG_VERSION=1
|
||||||
|
|
||||||
|
PROJECT="imnodes"
|
||||||
|
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="imnodes.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"
|
||||||
|
STATIC_LIB_FILE="lib$PROJECT.a"
|
||||||
|
|
||||||
|
# header include directories
|
||||||
|
INCLUDE="-I. -I../imgui -I../imgui/backends"
|
||||||
|
|
||||||
|
# OS-specific options
|
||||||
|
case "$OS" in
|
||||||
|
WINDOWS)
|
||||||
|
EXEC_FILE="$PROJECT.exe"
|
||||||
|
SHARED_LIB_FILE="lib$PROJECT.dll"
|
||||||
|
;;
|
||||||
|
LINUX)
|
||||||
|
EXEC_FILE="$PROJECT"
|
||||||
|
SHARED_LIB_FILE="lib$PROJECT.so"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "operating system $OS has no configuration variants"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# TASKS
|
||||||
|
case "$TASK" in
|
||||||
|
# creates shared library
|
||||||
|
build_shared_lib)
|
||||||
|
C_ARGS="-O2 -fpic -flto -shared"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS -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"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS -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"
|
||||||
|
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"
|
||||||
|
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
|
||||||
21
dependencies/precompiled.config
vendored
Normal file
21
dependencies/precompiled.config
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
mkdir -p 'dependencies/precompiled'
|
||||||
|
DEP_WORKING_DIR='dependencies/precompiled'
|
||||||
|
DEP_PRE_BUILD_COMMAND=''
|
||||||
|
DEP_BUILD_COMMAND=''
|
||||||
|
DEP_POST_BUILD_COMMAND=''
|
||||||
|
DEP_CLEAN_COMMAND=''
|
||||||
|
# won't be copied to project $OUTDIR
|
||||||
|
DEP_STATIC_OUT_FILES=$(find dependencies/precompiled -name '*.a' | sed 's,dependencies/precompiled/,,')
|
||||||
|
# will be copied tp project $OUTDIR
|
||||||
|
case $OS in
|
||||||
|
WINDOWS)
|
||||||
|
DEP_DYNAMIC_OUT_FILES=$(find dependencies/precompiled -name '*.dll' | sed 's,dependencies/precompiled/,,')
|
||||||
|
;;
|
||||||
|
LINUX)
|
||||||
|
DEP_DYNAMIC_OUT_FILES=$(find dependencies/precompiled -name '*.so' | sed 's,dependencies/precompiled/,,')
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "operating system $OS has no configuration variants"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
1
dependencies/resource_embedder
vendored
Submodule
1
dependencies/resource_embedder
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 9cc2fd7814eb6172b753fa1c7e2bea9656033755
|
||||||
8
dependencies/resources.config
vendored
Normal file
8
dependencies/resources.config
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
DEP_WORKING_DIR='dependencies/resource_embedder'
|
||||||
|
DEP_PRE_BUILD_COMMAND='./build.sh'
|
||||||
|
DEP_BUILD_COMMAND='../compile_resources.sh'
|
||||||
|
DEP_POST_BUILD_COMMAND=''
|
||||||
|
DEP_CLEAN_COMMAND='rm -f ./resource_embedder ./resource_embedder.exe ../obj/resources.c ../bin/resources.o'
|
||||||
|
DEP_STATIC_OUT_FILES='../bin/resources.o'
|
||||||
|
DEP_DYNAMIC_OUT_FILES=
|
||||||
191
project.config
Normal file
191
project.config
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
CBUILD_VERSION=2.1.2
|
||||||
|
CONFIG_VERSION=1
|
||||||
|
|
||||||
|
PROJECT="ougge"
|
||||||
|
CMP_C="gcc"
|
||||||
|
CMP_CPP="g++"
|
||||||
|
STD_C="c11"
|
||||||
|
STD_CPP="c++17"
|
||||||
|
WARN_C="-Wall -Wno-discarded-qualifiers -Wextra -Wno-unused-parameter"
|
||||||
|
WARN_CPP="-Wall -Wextra -Wno-unused-parameter"
|
||||||
|
SRC_C="$(find src -name '*.c')"
|
||||||
|
SRC_CPP="$(find src -name '*.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='imnodes imgui precompiled'
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
STATIC_LIB_FILE="lib$PROJECT.a"
|
||||||
|
|
||||||
|
# header include directories
|
||||||
|
INCLUDE="-I./dependencies/imgui -I./dependencies/include/SDL2"
|
||||||
|
|
||||||
|
# OS-specific options
|
||||||
|
case "$OS" in
|
||||||
|
WINDOWS)
|
||||||
|
EXEC_FILE="$PROJECT.exe"
|
||||||
|
SHARED_LIB_FILE="$PROJECT.dll"
|
||||||
|
LINKER_LIBS="-lopengl32 -lpthread"
|
||||||
|
;;
|
||||||
|
LINUX)
|
||||||
|
EXEC_FILE="$PROJECT"
|
||||||
|
SHARED_LIB_FILE="$PROJECT.so"
|
||||||
|
LINKER_LIBS="-lSDL2 -lGL"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "operating system $OS has no configuration variants"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
# TASKS
|
||||||
|
case "$TASK" in
|
||||||
|
# creates executable using profiling info if it exists
|
||||||
|
build_exec)
|
||||||
|
# -flto applies more optimizations across object files
|
||||||
|
# -flto=auto is needed to multithreaded copilation
|
||||||
|
# -fuse-linker-plugin is required to use static libs with lto
|
||||||
|
# -fprofile-use enables compiler to use profiling info files to optimize executable
|
||||||
|
# -fprofile-prefix-path sets path where profiling info about objects are be saved
|
||||||
|
# -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
|
PRE_TASK_SCRIPT=
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
POST_TASK_SCRIPT=
|
||||||
|
;;
|
||||||
|
# creates executable with debug info and no optimizations
|
||||||
|
build_exec_dbg)
|
||||||
|
C_ARGS="-O0 -g3"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
|
PRE_TASK_SCRIPT=
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
POST_TASK_SCRIPT=
|
||||||
|
;;
|
||||||
|
# creates shared library
|
||||||
|
build_shared_lib)
|
||||||
|
C_ARGS="-O2 -fpic -flto -shared"
|
||||||
|
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"
|
||||||
|
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 -fpic -fdata-sections -ffunction-sections"
|
||||||
|
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"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
PRE_TASK_SCRIPT=
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
|
||||||
|
POST_TASK_SCRIPT=
|
||||||
|
;;
|
||||||
|
# executes $EXEC_FILE
|
||||||
|
exec)
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/exec.sh
|
||||||
|
;;
|
||||||
|
# executes $EXEC_FILE with valgrind memory checker
|
||||||
|
valgrind)
|
||||||
|
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd) --leak-check=full --show-leak-kinds=all"
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
|
||||||
|
;;
|
||||||
|
# generates profiling info
|
||||||
|
profile)
|
||||||
|
OUTDIR="$OUTDIR/profile"
|
||||||
|
# -flto applies more optimizations across object files
|
||||||
|
# -flto=auto is needed to multithreaded copilation
|
||||||
|
# -fuse-linker-plugin is required to use static libs with lto
|
||||||
|
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
||||||
|
# -fprofile-generate generates executable with profiling code
|
||||||
|
# -fprofile-prefix-path sets path where profiling info about objects will be saved
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
|
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/profile.sh
|
||||||
|
POST_TASK_SCRIPT=
|
||||||
|
;;
|
||||||
|
# compiles program with -pg and runs it with gprof
|
||||||
|
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||||
|
# requires graphviz (https://www.graphviz.org/download/source/)
|
||||||
|
gprof)
|
||||||
|
OUTDIR="$OUTDIR/gprof"
|
||||||
|
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
|
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/gprof.sh
|
||||||
|
POST_TASK_SCRIPT=
|
||||||
|
;;
|
||||||
|
# compiles program and runs it with callgrind (part of valgrind)
|
||||||
|
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||||
|
# requires graphviz (https://www.graphviz.org/download/source/)
|
||||||
|
# P.S. detailed results can be viewed in KCacheGrind
|
||||||
|
callgrind)
|
||||||
|
OUTDIR="$OUTDIR/callgrind"
|
||||||
|
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
||||||
|
C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
|
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/callgrind.sh
|
||||||
|
POST_TASK_SCRIPT=
|
||||||
|
;;
|
||||||
|
# compiles executable with sanitizers and executes it to find errors and warnings
|
||||||
|
sanitize)
|
||||||
|
OUTDIR="$OUTDIR/sanitize"
|
||||||
|
C_ARGS="-O0 -g3 -fsanitize=undefined,address"
|
||||||
|
CPP_ARGS="$C_ARGS"
|
||||||
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
|
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/exec.sh
|
||||||
|
POST_TASK_SCRIPT=
|
||||||
|
;;
|
||||||
|
# rebuilds specified dependencies
|
||||||
|
# EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts`
|
||||||
|
# 'all' can be specified to rebuild all dependencies
|
||||||
|
rebuild_dependencies)
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/rebuild_dependencies.sh
|
||||||
|
;;
|
||||||
|
# deletes generated files
|
||||||
|
clean)
|
||||||
|
TASK_SCRIPT=cbuild/default_tasks/clean.sh
|
||||||
|
POST_TASK_SCRIPT=tasks/clean_additions.sh
|
||||||
|
;;
|
||||||
|
# nothing to do
|
||||||
|
"" | no_task)
|
||||||
|
;;
|
||||||
|
# unknown task
|
||||||
|
*)
|
||||||
|
error "task <$PROJECT/$TASK> not found"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
15
src/UsefulException.cpp
Normal file
15
src/UsefulException.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "UsefulException.hpp"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
UsefulException_::UsefulException_(const std::string& _message, const std::string& _file, const std::string& _func, int _line_n)
|
||||||
|
: message(_message), file(_file), function(_func), line_n(_line_n)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<message<<'\n';
|
||||||
|
ss<<" at "<<file<<':'<<_line_n<<" in "<<function;
|
||||||
|
complete_text = ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
char const* UsefulException_::what() const noexcept {
|
||||||
|
return complete_text.c_str();
|
||||||
|
}
|
||||||
21
src/UsefulException.hpp
Normal file
21
src/UsefulException.hpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#define UsefulException(MSG) UsefulException_(MSG, __FILE__, __func__, __LINE__)
|
||||||
|
|
||||||
|
class UsefulException_ : public std::exception {
|
||||||
|
std::string message;
|
||||||
|
std::string file;
|
||||||
|
std::string function;
|
||||||
|
int line_n;
|
||||||
|
std::string complete_text;
|
||||||
|
|
||||||
|
public:
|
||||||
|
UsefulException_(const std::string& msg, const std::string& _file, const std::string& _func, int line_n);
|
||||||
|
|
||||||
|
virtual char const* what() const noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define useful_assert(EXPR, ERRMSG) if(!EXPR) throw UsefulException(ERRMSG);
|
||||||
66
src/format.cpp
Normal file
66
src/format.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "UsefulException.hpp"
|
||||||
|
#include "std.hpp"
|
||||||
|
|
||||||
|
std::string _format(const std::string& format_str, const size_t args_count, ...){
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl, args_count);
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
for(size_t i = 0; i < format_str.length(); i++){
|
||||||
|
char c = format_str[i];
|
||||||
|
|
||||||
|
// format specifier
|
||||||
|
if(c == '%'){
|
||||||
|
c = format_str[++i];
|
||||||
|
bool l = false;
|
||||||
|
while(c == 'l'){
|
||||||
|
l = true;
|
||||||
|
c = format_str[++i];
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(c){
|
||||||
|
case 'u':
|
||||||
|
if(l) ss<<(u64)va_arg(vl, u64);
|
||||||
|
else ss<<(u32)va_arg(vl, u32);
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
case 'd':
|
||||||
|
if(l) ss<<(i64)va_arg(vl, i64);
|
||||||
|
else ss<<(i32)va_arg(vl, i32);
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
// f32 is promoted to f64 when passed through '...'
|
||||||
|
ss<<(f64)va_arg(vl, f64);
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
ss<<(void*)va_arg(vl, void*);
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
if(l) ss<<std::hex<<(u64)va_arg(vl, u64);
|
||||||
|
else ss<<std::hex<<(u32)va_arg(vl, u32);
|
||||||
|
break;
|
||||||
|
case 's': {
|
||||||
|
const char* cptr = va_arg(vl,char*);
|
||||||
|
if(cptr != nullptr)
|
||||||
|
ss<<cptr;
|
||||||
|
else ss<<"<nullptr>";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'c':
|
||||||
|
ss<<(char)va_arg(vl,int);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw UsefulException("invalid format cpecifier");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// regular character
|
||||||
|
else ss<<c;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(vl);
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
7
src/format.hpp
Normal file
7
src/format.hpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "../dependencies/kerep/src/base/std.h"
|
||||||
|
|
||||||
|
std::string _format(const std::string& format_str, const size_t args_count, ...);
|
||||||
|
#define format(FORMAT_STR, ARGS...) _format(FORMAT_STR, count_args(ARGS) ,##ARGS)
|
||||||
9
src/main.cpp
Normal file
9
src/main.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#define SDL_MAIN_HANDLED
|
||||||
|
#include <SDL.h>
|
||||||
|
#include "std.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, const char** argv){
|
||||||
|
std::cout<<"UwU"<<std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
60
src/std.hpp
Normal file
60
src/std.hpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
typedef int8_t i8;
|
||||||
|
typedef uint8_t u8;
|
||||||
|
typedef int16_t i16;
|
||||||
|
typedef uint16_t u16;
|
||||||
|
typedef int32_t i32;
|
||||||
|
typedef uint32_t u32;
|
||||||
|
typedef int64_t i64;
|
||||||
|
typedef uint64_t u64;
|
||||||
|
typedef float f32;
|
||||||
|
typedef double f64;
|
||||||
|
/// anonymous pointer without specified freeMembers() func
|
||||||
|
typedef void* Pointer;
|
||||||
|
|
||||||
|
#define nameof(V) #V
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma comment(lib, "mincore_downlevel.lib") // Support OS older than SDK
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS 1
|
||||||
|
#define EXPORT __declspec(dllexport)
|
||||||
|
#define CALL __cdecl
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define EXPORT __attribute__((visibility("default")))
|
||||||
|
#if __SIZEOF_POINTER__ == 4
|
||||||
|
#define CALL __attribute__((__cdecl__))
|
||||||
|
#else
|
||||||
|
#define CALL
|
||||||
|
#endif
|
||||||
|
#ifndef typeof
|
||||||
|
#define typeof(X) __typeof__(X)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#pragma GCC error "unknown compiler"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __count_args( \
|
||||||
|
a0, a1, a2, a3, a4, a5, a6, a7 , \
|
||||||
|
a8, a9, a10,a11,a12,a13,a14,a15, \
|
||||||
|
a16,a17,a18,a19,a20,a21,a22,a23, \
|
||||||
|
a24,a25,a26,a27,a28,a29,a30,a31, \
|
||||||
|
a32,a33,a34,a35,a36,a37,a38,a39, \
|
||||||
|
a40,a41,a42,a43,a44,a45,a46,a47, \
|
||||||
|
a48,a49,a50,a51,a52,a53,a54,a55, \
|
||||||
|
a56,a57,a58,a59,a60,a61,a62,a63, \
|
||||||
|
a64,...) a64
|
||||||
|
// Macro for counting variadic arguments (max 64)
|
||||||
|
// (see usage in kprint.h)
|
||||||
|
#define count_args(ARGS...) __count_args( \
|
||||||
|
ARGS, \
|
||||||
|
64,63,62,61,60,59,58,57, \
|
||||||
|
56,55,54,53,52,51,50,49, \
|
||||||
|
48,47,46,45,44,43,42,41, \
|
||||||
|
40,39,38,37,36,35,34,33, \
|
||||||
|
32,31,30,29,28,27,26,25, \
|
||||||
|
24,23,22,21,20,19,18,17, \
|
||||||
|
16,15,14,13,12,11,10,9, \
|
||||||
|
8, 7, 6, 5, 4, 3, 2, 1, 0)
|
||||||
3
tasks/clean_additions.sh
Normal file
3
tasks/clean_additions.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
try_delete_dir_or_file src/generated
|
||||||
Loading…
Reference in New Issue
Block a user