migration to gitea and cbuild 2.1

This commit is contained in:
Timerix 2024-07-21 06:35:17 +03:00
parent 461b92ccc3
commit 1644aa4e9b
30 changed files with 364 additions and 243 deletions

18
.gitignore vendored
View File

@ -1,9 +1,8 @@
# build results # build results
bin/ bin/
obj/ obj/
libs/ src/generated/
*.log imgui.ini
*.tmp
# IDE files # IDE files
.vs/ .vs/
@ -12,8 +11,13 @@ libs/
*.user *.user
*.vcxproj.filters *.vcxproj.filters
# user files # other files
.old*/ .old*/
current.config old/
src/generated/ tmp/
imgui.ini temp/
*.tmp
*.temp
logs/
log/
*.log

22
.gitmodules vendored
View File

@ -1,18 +1,10 @@
[submodule "cbuild"] [submodule "dependencies/kerep"]
path = cbuild
url = https://github.com/Timerix22/cbuild.git
[submodule "kerep"]
path = dependencies/kerep path = dependencies/kerep
url = https://github.com/Timerix22/kerep.git url = https://timerix.ddns.net:3322/Timerix/kerep.git
[submodule "SDL2"] [submodule "dependencies/imgui"]
path = dependencies/SDL2
url = https://github.com/Timerix22/SDL.git
branch = SDL2
[submodule "imgui"]
path = dependencies/imgui path = dependencies/imgui
url = https://github.com/Timerix22/imgui.git url = https://github.com/ocornut/imgui.git
branch = docking_cbuild branch = docking
[submodule "imnodes"] [submodule "dependencies/imnodes"]
path = dependencies/imnodes path = dependencies/imnodes
url = https://github.com/Timerix22/imnodes url = https://github.com/Nelarius/imnodes.git
branch = master_cbuild

2
.vscode/.gitignore vendored
View File

@ -1,2 +0,0 @@
settings.json
c_cpp_properties.json

26
.vscode/launch.json vendored
View File

@ -2,33 +2,11 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "gdb_debug_unix", "name": "gdb_debug",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/bin/GraphC", "program": "${workspaceFolder}/bin/GraphC",
"preLaunchTask": "build_exec_dbg", "windows": { "program": "${workspaceFolder}/bin/GraphC.exe" },
"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
}
]
},
// the only difference is .exe
{
"name": "gdb_debug_win",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/GraphC.exe",
"preLaunchTask": "build_exec_dbg", "preLaunchTask": "build_exec_dbg",
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}/bin", "cwd": "${workspaceFolder}/bin",

14
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
"C_Cpp.codeAnalysis.exclude": {
"**/dependencies/": true
},
"C_Cpp.default.defines": [
"SDL_DISABLE_ANALYZE_MACROS",
"DEBUG=1"
],
"C_Cpp.default.includePath": [
"dependencies/include/SDL2",
"dependencies/imgui",
"${default}"
]
}

View File

@ -1,91 +0,0 @@
######################################
###### Build tasks #######
######################################
default: build_exec_dbg
# creates executable using profile info generated by profile
build_exec: # profile
@cbuild/call_task.sh build_exec 2>&1 | tee -a make_raw.log
# creates executable with debug info and no optimizations
build_exec_dbg:
@cbuild/call_task.sh build_exec_dbg 2>&1 | tee make_raw.log
######################################
###### Rebuild dependencies #######
######################################
# recompile kerep.a in the next build task
rebuild_kerep:
@cbuild/rebuild_dep.sh libkerep.a 2>&1 | tee make_raw.log
# recompile imgui.a in the next build task
rebuild_imgui:
@cbuild/rebuild_dep.sh libimgui.a 2>&1 | tee make_raw.log
rebuild_imnodes:
@cbuild/rebuild_dep.sh libimnodes.a 2>&1 | tee make_raw.log
# writes ttf fonts fron ./fonts/ to C compressed arrays in C source files
# builds static library from font arrays definitions
embed_fonts:
@cbuild/call_task.sh embed_fonts 2>&1 | tee make_raw.log
rebuild_all: rebuild_kerep rebuild_imgui rebuild_imnodes embed_fonts
######################################
###### Launch tasks #######
######################################
# executes $EXEC_FILE
exec: build_exec
@cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log
# executes $EXEC_FILE
exec_dbg: build_exec_dbg
@cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log
# executes $EXEC_FILE with valgrind memory checker
valgrind: build_exec_dbg
@cbuild/call_task.sh valgrind 2>&1 | tee -a make_raw.log
# generates profiling info
profile:
@cbuild/call_task.sh profile 2>&1 | tee make_raw.log
# 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:
@cbuild/call_task.sh gprof 2>&1 | tee make_raw.log
# 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:
@cbuild/call_task.sh callgrind 2>&1 | tee make_raw.log
# compiles executable with sanitizers and executes it to find errors and warnings
sanitize:
@cbuild/call_task.sh sanitize 2>&1 | tee make_raw.log
######################################
###### Other tasks #######
######################################
# deletes generated files
clean:
@cbuild/call_task.sh clean 2>&1 | tee make_raw.log
# removes all unreadable characters copied from stdio
fix_log:
sed 's/[^[:blank:][:print:]]//g' make_raw.log \
| sed 's/\[0;[0-9][0-9]m//g' \
| sed 's/\[0;[0-9]m//g' \
| sed 's/\[[0-9][0-9]m//g' \
| sed 's/\[[0-9]m//g' \
| sed 's/ H //g' \
| sed 's/\[3gH //g' \
> make_fixed.log

View File

@ -5,30 +5,37 @@ GUI is based on [Dear ImGui](https://github.com/ocornut/imgui) and [SDL](https:/
## Installation ## Installation
1. Clone the repository 1. Clone the repository
```shell ```sh
git clone --recurse-submodules https://github.com/Timerix22/GraphC git clone --recurse-submodules https://timerix.ddns.net:3322/Timerix/GraphC.git
``` ```
2. Install **SDL2** from package manager or compile it from source. 2. Install [cbuild](https://timerix.ddns.net:3322/Timerix/cbuild.git)
**If you are using msys, switch to mingw64 shell.** 3. Install **SDL2** from package manager or compile it from source.
```shell **If you are using msys, switch to mingw64 sh.**
cd dependencies/SDL2 ```sh
cd ..
git clone https://github.com/libsdl-org/SDL.git
cd SDL
./configure ./configure
make -j [number of cpu threads] make -j [number of cpu threads]
``` ```
Then you can install it systemwide: Then you can install it systemwide (on **Linux**):
```shell ```sh
make install sudo make install
``` ```
or copy to ./libs: or copy to ./libs (on **Windows**):
```shell ```sh
mkdir -p ../../libs mkdir -p GraphC/libs
cp ./build/.libs/SDL2.dll ../../libs/ cp ./build/.libs/SDL2.dll GraphC/libs/
``` ```
If it didn't work, read [SDL docs](dependencies/SDL2/docs/README.md) and [INSTALL.txt](dependencies/SDL2/INSTALL.txt). 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`
3. Compile the program ```sh
```shell cd GraphC
make build_exec ln -s SDL2_HEADERS_DIRECTORY_ABSOLUTE_PATH dependencies/include/
```
Location of the headers can be found by `pkg-config --cppflags --libs sdl2`.
Mingw installs SDL2 headers to `/mingw64/include/SDL2`.
5. Compile the program
```sh
cbuild build_exec
``` ```
4. Copy program files from `bin/*` to any directory

1
cbuild

@ -1 +0,0 @@
Subproject commit 574ce6eab3b65e05888adad95a0211f532dd1125

2
dependencies/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/include/
/precompiled/

1
dependencies/SDL2 vendored

@ -1 +0,0 @@
Subproject commit 903d888cc31d283ccaaaa7e5b5a324c50a103e87

2
dependencies/imgui vendored

@ -1 +1 @@
Subproject commit fc74d2ab7d44709d9c3245e323dbfce6a1ac4ac0 Subproject commit 02cc7d451c65f249d64e92d267119fb3d624fda6

12
dependencies/imgui.config vendored Executable file
View 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 Executable file
View 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 +1 @@
Subproject commit bbdb8be78f6fc1bf1ef842e752ee70f1c3c620a4 Subproject commit 8563e1655bd9bb1f249e6552cc6274d506ee788b

12
dependencies/imnodes.config vendored Executable file
View 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 Executable file
View 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

2
dependencies/kerep vendored

@ -1 +1 @@
Subproject commit 0e370b31ba98ec85720a4a5295b995348c247d3c Subproject commit e722cd0353ed08a6bc9789835020bb1271e8e24c

14
dependencies/kerep.config vendored Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
DEP_WORKING_DIR='dependencies/kerep'
DEP_PRE_BUILD_COMMAND=''
if [[ "$TASK" = *_dbg ]]; then
DEP_BUILD_COMMAND='cbuild build_static_lib_dbg'
else
DEP_BUILD_COMMAND='cbuild build_static_lib'
fi
DEP_POST_BUILD_COMMAND=''
DEP_CLEAN_COMMAND='cbuild clean'
# won't be copied to project $OUTDIR
DEP_STATIC_OUT_FILES='bin/libkerep.a'
# will be copied tp project $OUTDIR
DEP_DYNAMIC_OUT_FILES=''

20
dependencies/precompiled.config vendored Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
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

65
default.config → project.config Normal file → Executable file
View File

@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
CBUILD_VERSION=7 CBUILD_VERSION=2.1.2
CONFIG_VERSION=6 CONFIG_VERSION=7
PROJECT="GraphC" PROJECT="GraphC"
CMP_C="gcc" CMP_C="gcc"
@ -11,40 +11,36 @@ WARN_C="-Wall -Wno-discarded-qualifiers -Wextra -Wno-unused-parameter"
WARN_CPP="-Wall -Wextra -Wno-unused-parameter" WARN_CPP="-Wall -Wextra -Wno-unused-parameter"
SRC_C="$(find src -name '*.c')" SRC_C="$(find src -name '*.c')"
SRC_CPP="$(find src -name '*.cpp')" SRC_CPP="$(find src -name '*.cpp')"
#TESTS_C="$( find tests -name '*.c')"
#TESTS_CPP="$(find tests -name '*.cpp')"
# dir with dependeicy dirs # Directory with dependency configs.
DEPS_BASEDIR="dependencies" # See cbuild/example_dependency_configs
# EXAMPLE: "dependency_dir='build_task out_dir lib_file' DEPENDENCY_CONFIGS_DIR='dependencies'
# other_depndency_dir=..." # List of dependency config files in DEPENDENCY_CONFIGS_DIR separated by space.
# Dependencies must be declared on separate lines ENABLED_DEPENDENCIES='precompiled kerep imgui imnodes'
# Values can be override by resetting one of dependencies:
# DEPS="$DEPS
# dependency_dir='...'"
DEPS="kerep='build_static_lib bin libkerep.a'
imgui='build_static_lib bin libimgui.a'
imnodes='build_static_lib bin libimnodes.a'"
# OBJDIR structure: # OBJDIR structure:
# ├── objects - dir where compiled *.o files are stored. cleans every call of build task # ├── objects/ - Compiled object files. Cleans on each call of build task
# ├── profile - dir where gcc *.gcda profiling info files stored # ├── static_libs/ - Symbolic links to static libraries used by linker. Cleans on each call of build task.
# ├── libs - there you can put static libs and linker will find them # ├── static_libs/ - Symbolic links to dynamic libraries used by linker. Cleans on each call of build task.
# └── out - output files are created here and then copied to OUTDIR # └── profile/ - gcc *.gcda profiling info files
OBJDIR="obj" OBJDIR="obj"
OUTDIR="bin" OUTDIR="bin"
STATIC_LIB_FILE="lib$PROJECT.a"
# header include directories
INCLUDE="-I./dependencies/imgui -I./dependencies/include/SDL2"
# OS-specific options # OS-specific options
case "$OS" in case "$OS" in
WINDOWS) WINDOWS)
EXEC_FILE="$PROJECT.exe" EXEC_FILE="$PROJECT.exe"
INCLUDE="-I./dependencies/imgui -I./dependencies/SDL2/include" SHARED_LIB_FILE="$PROJECT.dll"
LINKER_LIBS="-L./libs/ -l:SDL2.dll -lopengl32 -lpthread -lws2_32" LINKER_LIBS="-lopengl32 -lpthread -lws2_32"
;; ;;
LINUX) LINUX)
EXEC_FILE="$PROJECT" EXEC_FILE="$PROJECT"
INCLUDE="-I./dependencies/imgui -I./dependencies/SDL2/include" SHARED_LIB_FILE="$PROJECT.so"
LINKER_LIBS="-L./libs/ -lSDL2 -lGL" LINKER_LIBS="-lSDL2 -lGL"
;; ;;
*) *)
error "operating system $OS has no configuration variants" error "operating system $OS has no configuration variants"
@ -74,18 +70,16 @@ case "$TASK" in
#-fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects #-fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
DEPS_BUILD_TASK=build_static_lib
;; ;;
# creates executable with debug info and no optimizations # creates executable with debug info and no optimizations
build_exec_dbg) build_exec_dbg)
C_ARGS="-O0 -g -DDEBUG=1" C_ARGS="-O0 -g -DDEBUG=1"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
DEPS_BUILD_TASK=build_static_lib_dbg
;; ;;
# executes $EXEC_FILE # executes $EXEC_FILE
exec) exec)
@ -93,7 +87,7 @@ case "$TASK" in
;; ;;
# executes $EXEC_FILE with valgrind memory checker # executes $EXEC_FILE with valgrind memory checker
valgrind) valgrind)
VALGRIND_ARGS="-s --log-file=valgrind.log --read-var-info=yes --track-origins=yes --fullpath-after=$PROJECT/ --leak-check=full --show-leak-kinds=all" VALGRIND_ARGS="-s --log-file=valgrind.log --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd) --leak-check=full --show-leak-kinds=all"
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
;; ;;
# generates profiling info # generates profiling info
@ -108,10 +102,9 @@ case "$TASK" in
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=cbuild/default_tasks/profile.sh POST_TASK_SCRIPT=cbuild/default_tasks/profile.sh
DEPS_BUILD_TASK=build_static_lib
;; ;;
# compiles program with -pg and runs it with gprof # compiles program with -pg and runs it with gprof
# uses gprof2dot python script to generate function call tree (pip install gprof2dot) # uses gprof2dot python script to generate function call tree (pip install gprof2dot)
@ -122,10 +115,9 @@ case "$TASK" in
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=cbuild/default_tasks/gprof.sh POST_TASK_SCRIPT=cbuild/default_tasks/gprof.sh
DEPS_BUILD_TASK=build_static_lib
;; ;;
# compiles executable with sanitizers and executes it to find errors and warnings # compiles executable with sanitizers and executes it to find errors and warnings
sanitize) sanitize)
@ -133,10 +125,9 @@ case "$TASK" in
C_ARGS="-O0 -g3 -fsanitize=undefined,address" C_ARGS="-O0 -g3 -fsanitize=undefined,address"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=cbuild/default_tasks/exec.sh POST_TASK_SCRIPT=cbuild/default_tasks/exec.sh
DEPS_BUILD_TASK=build_static_lib
;; ;;
# compiles program and runs it with callgrind (part of valgrind) # compiles program and runs it with callgrind (part of valgrind)
# uses gprof2dot python script to generate function call tree (pip install gprof2dot) # uses gprof2dot python script to generate function call tree (pip install gprof2dot)
@ -148,7 +139,7 @@ case "$TASK" in
C_ARGS="-O2 -flto=auto -fuse-linker-plugin" C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=cbuild/default_tasks/callgrind.sh POST_TASK_SCRIPT=cbuild/default_tasks/callgrind.sh
;; ;;
@ -158,7 +149,7 @@ case "$TASK" in
POST_TASK_SCRIPT=tasks/clean_additions.sh POST_TASK_SCRIPT=tasks/clean_additions.sh
;; ;;
# nothing to do # nothing to do
no_task) "" | no_task)
;; ;;
# unknown task # unknown task
*) *)

View File

@ -534,7 +534,7 @@ public:
if(root == null_node_ptr) if(root == null_node_ptr)
ss<<" \"null\"\n"; ss<<" \"null\"\n";
else { else {
ss<<" \"null-parent\" -> \""<<root->key<<"\"\n"; ss<<" \"null\" -> \""<<root->key<<"\"\n";
_generateGraphVizCodeForChildren(ss, root); _generateGraphVizCodeForChildren(ss, root);
} }
ss<<"}"; ss<<"}";

View File

@ -1,5 +1,5 @@
#include "exceptions.hpp" #include "exceptions.hpp"
#include "../../dependencies/SDL2/include/SDL.h" #include <SDL.h>
namespace GraphC::gui { namespace GraphC::gui {

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "../../dependencies/imgui/imgui.h" #include "imgui.h"
#include "../generated/fonts_embedded.h" #include "../generated/fonts_embedded.h"
namespace GraphC::gui::fonts { namespace GraphC::gui::fonts {

View File

@ -1,6 +1,6 @@
#include "gui.hpp" #include "gui.hpp"
#include "../../dependencies/imgui/backends/imgui_impl_sdl2.h" #include "backends/imgui_impl_sdl2.h"
#include "../../dependencies/imgui/backends/imgui_impl_opengl3.h" #include "backends/imgui_impl_opengl3.h"
namespace GraphC::gui { namespace GraphC::gui {

View File

@ -2,9 +2,9 @@
#include "../../dependencies/kerep/src/base/std.h" #include "../../dependencies/kerep/src/base/std.h"
#include "../../dependencies/kerep/src/kprint/kprintf.h" #include "../../dependencies/kerep/src/kprint/kprintf.h"
#include "../../dependencies/SDL2/include/SDL.h" #include <SDL.h>
#include "../../dependencies/SDL2/include/SDL_opengl.h" #include <SDL_opengl.h>
#include "../../dependencies/imgui/imgui.h" #include "imgui.h"
#include "../format.hpp" #include "../format.hpp"
#include "GraphEditor.hpp" #include "GraphEditor.hpp"
#include "imgui_extensions.hpp" #include "imgui_extensions.hpp"

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "../../dependencies/imgui/imgui.h" #include "imgui.h"
namespace ImGui { namespace ImGui {

View File

@ -1,12 +1,9 @@
#include <iostream> #include <iostream>
// SDL redefines main function for compatibility.
// THe following define disables this feature.
#define SDL_MAIN_HANDLED
#include "gui/gui.hpp" #include "gui/gui.hpp"
// SDL for some reason redefines main
#ifdef main
#undef main
#endif
int main(const int argc, const char* const* argv){ int main(const int argc, const char* const* argv){
if(setlocale(LC_CTYPE, "C.UTF-8")!=0) if(setlocale(LC_CTYPE, "C.UTF-8")!=0)
kprintf("\e[93msetlocale failed!\n"); kprintf("\e[93msetlocale failed!\n");

3
tasks/clean_additions.sh Normal file → Executable file
View File

@ -1,4 +1,3 @@
#!/usr/bin/bash #!/usr/bin/env bash
try_delete_dir_or_file fonts/generated try_delete_dir_or_file fonts/generated
try_delete_dir_or_file libs/fonts_embedded.a

2
tasks/embed_fonts.sh Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
cd fonts cd fonts
SRC_C="" SRC_C=""
HEADER="generated/fonts_embedded.h" HEADER="generated/fonts_embedded.h"

View File

@ -1,22 +0,0 @@
#!/bin/bash
# compile fonts
if [ ! -f libs/fonts_embedded.a ]; then
if ! make embed_fonts; then
exit 1
fi
fi
set -x
# copy precompiled static libs to objects
static_libs=$(find "libs/" -name '*.a')
[[ -n "$static_libs" ]] && cp $static_libs "$OBJDIR/libs/"
# copy precompiled shared libs to outdir
if [ "$OS" == 'WINDOWS' ]; then
dynamic_libs=$(find "libs/" -name '*.dll')
else
dynamic_libs=$(find "libs/" -name '*.so')
fi
[[ -n "$dynamic_libs" ]] && cp $dynamic_libs "$OUTDIR/"
set +x