diff --git a/.gitignore b/.gitignore index 9dcc8ce..b603471 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ # build results bin/ obj/ -libs/ -*.log -*.tmp +src/generated/ +imgui.ini # IDE files .vs/ @@ -12,8 +11,13 @@ libs/ *.user *.vcxproj.filters -# user files +# other files .old*/ -current.config -src/generated/ -imgui.ini +old/ +tmp/ +temp/ +*.tmp +*.temp +logs/ +log/ +*.log diff --git a/.gitmodules b/.gitmodules index 99e802a..2ec8316 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,18 +1,10 @@ -[submodule "cbuild"] - path = cbuild - url = https://github.com/Timerix22/cbuild.git -[submodule "kerep"] +[submodule "dependencies/kerep"] path = dependencies/kerep - url = https://github.com/Timerix22/kerep.git -[submodule "SDL2"] - path = dependencies/SDL2 - url = https://github.com/Timerix22/SDL.git - branch = SDL2 -[submodule "imgui"] + url = https://timerix.ddns.net:3322/Timerix/kerep.git +[submodule "dependencies/imgui"] path = dependencies/imgui - url = https://github.com/Timerix22/imgui.git - branch = docking_cbuild -[submodule "imnodes"] + url = https://github.com/ocornut/imgui.git + branch = docking +[submodule "dependencies/imnodes"] path = dependencies/imnodes - url = https://github.com/Timerix22/imnodes - branch = master_cbuild + url = https://github.com/Nelarius/imnodes.git diff --git a/.vscode/.gitignore b/.vscode/.gitignore index adc53b1..e69de29 100644 --- a/.vscode/.gitignore +++ b/.vscode/.gitignore @@ -1,2 +0,0 @@ -settings.json -c_cpp_properties.json diff --git a/.vscode/launch.json b/.vscode/launch.json index 476c11a..ef35bbf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,33 +2,11 @@ "version": "0.2.0", "configurations": [ { - "name": "gdb_debug_unix", + "name": "gdb_debug", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/bin/GraphC", - "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 - } - ] - }, - // the only difference is .exe - { - "name": "gdb_debug_win", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/bin/GraphC.exe", + "windows": { "program": "${workspaceFolder}/bin/GraphC.exe" }, "preLaunchTask": "build_exec_dbg", "stopAtEntry": false, "cwd": "${workspaceFolder}/bin", diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..079483e --- /dev/null +++ b/.vscode/settings.json @@ -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}" + ] +} diff --git a/Makefile b/Makefile deleted file mode 100644 index ec1b968..0000000 --- a/Makefile +++ /dev/null @@ -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 diff --git a/README.md b/README.md index a9cd128..9b9d7c8 100644 --- a/README.md +++ b/README.md @@ -5,30 +5,37 @@ GUI is based on [Dear ImGui](https://github.com/ocornut/imgui) and [SDL](https:/ ## Installation 1. Clone the repository -```shell -git clone --recurse-submodules https://github.com/Timerix22/GraphC +```sh +git clone --recurse-submodules https://timerix.ddns.net:3322/Timerix/GraphC.git ``` -2. Install **SDL2** from package manager or compile it from source. - **If you are using msys, switch to mingw64 shell.** - ```shell - cd dependencies/SDL2 +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 + cd .. + git clone https://github.com/libsdl-org/SDL.git + cd SDL ./configure make -j [number of cpu threads] ``` - Then you can install it systemwide: - ```shell - make install + Then you can install it systemwide (on **Linux**): + ```sh + sudo make install ``` - or copy to ./libs: - ```shell - mkdir -p ../../libs - cp ./build/.libs/SDL2.dll ../../libs/ + or copy to ./libs (on **Windows**): + ```sh + mkdir -p GraphC/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). - -3. Compile the program -```shell -make build_exec -``` - -4. Copy program files from `bin/*` to any directory + 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 GraphC + 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 + ``` \ No newline at end of file diff --git a/cbuild b/cbuild deleted file mode 160000 index 574ce6e..0000000 --- a/cbuild +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 574ce6eab3b65e05888adad95a0211f532dd1125 diff --git a/dependencies/.gitignore b/dependencies/.gitignore new file mode 100644 index 0000000..4119546 --- /dev/null +++ b/dependencies/.gitignore @@ -0,0 +1,2 @@ +/include/ +/precompiled/ diff --git a/dependencies/SDL2 b/dependencies/SDL2 deleted file mode 160000 index 903d888..0000000 --- a/dependencies/SDL2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 903d888cc31d283ccaaaa7e5b5a324c50a103e87 diff --git a/dependencies/imgui b/dependencies/imgui index fc74d2a..02cc7d4 160000 --- a/dependencies/imgui +++ b/dependencies/imgui @@ -1 +1 @@ -Subproject commit fc74d2ab7d44709d9c3245e323dbfce6a1ac4ac0 +Subproject commit 02cc7d451c65f249d64e92d267119fb3d624fda6 diff --git a/dependencies/imgui.config b/dependencies/imgui.config new file mode 100755 index 0000000..7c708b4 --- /dev/null +++ b/dependencies/imgui.config @@ -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='' diff --git a/dependencies/imgui.project.config b/dependencies/imgui.project.config new file mode 100755 index 0000000..861ddfe --- /dev/null +++ b/dependencies/imgui.project.config @@ -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 diff --git a/dependencies/imnodes b/dependencies/imnodes index bbdb8be..8563e16 160000 --- a/dependencies/imnodes +++ b/dependencies/imnodes @@ -1 +1 @@ -Subproject commit bbdb8be78f6fc1bf1ef842e752ee70f1c3c620a4 +Subproject commit 8563e1655bd9bb1f249e6552cc6274d506ee788b diff --git a/dependencies/imnodes.config b/dependencies/imnodes.config new file mode 100755 index 0000000..c7ec1a0 --- /dev/null +++ b/dependencies/imnodes.config @@ -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='' diff --git a/dependencies/imnodes.project.config b/dependencies/imnodes.project.config new file mode 100755 index 0000000..52c6953 --- /dev/null +++ b/dependencies/imnodes.project.config @@ -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 diff --git a/dependencies/kerep b/dependencies/kerep index 0e370b3..e722cd0 160000 --- a/dependencies/kerep +++ b/dependencies/kerep @@ -1 +1 @@ -Subproject commit 0e370b31ba98ec85720a4a5295b995348c247d3c +Subproject commit e722cd0353ed08a6bc9789835020bb1271e8e24c diff --git a/dependencies/kerep.config b/dependencies/kerep.config new file mode 100755 index 0000000..5f411ec --- /dev/null +++ b/dependencies/kerep.config @@ -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='' diff --git a/dependencies/precompiled.config b/dependencies/precompiled.config new file mode 100755 index 0000000..80b7a20 --- /dev/null +++ b/dependencies/precompiled.config @@ -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 diff --git a/default.config b/project.config old mode 100644 new mode 100755 similarity index 73% rename from default.config rename to project.config index df08bc3..f7c0761 --- a/default.config +++ b/project.config @@ -1,6 +1,6 @@ -#!/bin/bash -CBUILD_VERSION=7 -CONFIG_VERSION=6 +#!/usr/bin/env bash +CBUILD_VERSION=2.1.2 +CONFIG_VERSION=7 PROJECT="GraphC" CMP_C="gcc" @@ -11,40 +11,36 @@ 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')" -#TESTS_C="$( find tests -name '*.c')" -#TESTS_CPP="$(find tests -name '*.cpp')" -# dir with dependeicy dirs -DEPS_BASEDIR="dependencies" -# EXAMPLE: "dependency_dir='build_task out_dir lib_file' -# other_depndency_dir=..." -# Dependencies must be declared on separate lines -# 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'" +# 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='precompiled kerep imgui imnodes' # OBJDIR structure: -# ├── objects - dir where compiled *.o files are stored. cleans every call of build task -# ├── profile - dir where gcc *.gcda profiling info files stored -# ├── libs - there you can put static libs and linker will find them -# └── out - output files are created here and then copied to OUTDIR +# ├── 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" - INCLUDE="-I./dependencies/imgui -I./dependencies/SDL2/include" - LINKER_LIBS="-L./libs/ -l:SDL2.dll -lopengl32 -lpthread -lws2_32" + SHARED_LIB_FILE="$PROJECT.dll" + LINKER_LIBS="-lopengl32 -lpthread -lws2_32" ;; LINUX) EXEC_FILE="$PROJECT" - INCLUDE="-I./dependencies/imgui -I./dependencies/SDL2/include" - LINKER_LIBS="-L./libs/ -lSDL2 -lGL" + SHARED_LIB_FILE="$PROJECT.so" + LINKER_LIBS="-lSDL2 -lGL" ;; *) error "operating system $OS has no configuration variants" @@ -64,7 +60,7 @@ case "$TASK" in STATIC_LIB_FILE="fonts_embedded.a" TASK_SCRIPT=tasks/embed_fonts.sh ;; - + # creates executable using profile info generated by build_profile build_exec) # -flto applies more optimizations across object files @@ -74,18 +70,16 @@ case "$TASK" in #-fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT=tasks/pre_build.sh + PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - DEPS_BUILD_TASK=build_static_lib ;; # creates executable with debug info and no optimizations build_exec_dbg) C_ARGS="-O0 -g -DDEBUG=1" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT=tasks/pre_build.sh + PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - DEPS_BUILD_TASK=build_static_lib_dbg ;; # executes $EXEC_FILE exec) @@ -93,7 +87,7 @@ case "$TASK" in ;; # executes $EXEC_FILE with valgrind memory checker 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 ;; # 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" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS" - PRE_TASK_SCRIPT=tasks/pre_build.sh + PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_exec.sh POST_TASK_SCRIPT=cbuild/default_tasks/profile.sh - DEPS_BUILD_TASK=build_static_lib ;; # compiles program with -pg and runs it with gprof # 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" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS" - PRE_TASK_SCRIPT=tasks/pre_build.sh + PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_exec.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 sanitize) @@ -133,10 +125,9 @@ case "$TASK" in C_ARGS="-O0 -g3 -fsanitize=undefined,address" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS" - PRE_TASK_SCRIPT=tasks/pre_build.sh + PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_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) # 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" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS" - PRE_TASK_SCRIPT=tasks/pre_build.sh + PRE_TASK_SCRIPT= TASK_SCRIPT=cbuild/default_tasks/build_exec.sh POST_TASK_SCRIPT=cbuild/default_tasks/callgrind.sh ;; @@ -158,7 +149,7 @@ case "$TASK" in POST_TASK_SCRIPT=tasks/clean_additions.sh ;; # nothing to do - no_task) + "" | no_task) ;; # unknown task *) diff --git a/src/RBTree.hpp b/src/RBTree.hpp index 40dc6ca..e04c8c2 100644 --- a/src/RBTree.hpp +++ b/src/RBTree.hpp @@ -534,7 +534,7 @@ public: if(root == null_node_ptr) ss<<" \"null\"\n"; else { - ss<<" \"null-parent\" -> \""<key<<"\"\n"; + ss<<" \"null\" -> \""<key<<"\"\n"; _generateGraphVizCodeForChildren(ss, root); } ss<<"}"; diff --git a/src/gui/exceptions.cpp b/src/gui/exceptions.cpp index a3c714e..cd8126c 100644 --- a/src/gui/exceptions.cpp +++ b/src/gui/exceptions.cpp @@ -1,5 +1,5 @@ #include "exceptions.hpp" -#include "../../dependencies/SDL2/include/SDL.h" +#include namespace GraphC::gui { diff --git a/src/gui/fonts.hpp b/src/gui/fonts.hpp index 6c42678..85e0ad1 100644 --- a/src/gui/fonts.hpp +++ b/src/gui/fonts.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../../dependencies/imgui/imgui.h" +#include "imgui.h" #include "../generated/fonts_embedded.h" namespace GraphC::gui::fonts { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index e30bbe5..c5666c1 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -1,6 +1,6 @@ #include "gui.hpp" -#include "../../dependencies/imgui/backends/imgui_impl_sdl2.h" -#include "../../dependencies/imgui/backends/imgui_impl_opengl3.h" +#include "backends/imgui_impl_sdl2.h" +#include "backends/imgui_impl_opengl3.h" namespace GraphC::gui { diff --git a/src/gui/gui.hpp b/src/gui/gui.hpp index 3530cc1..fba8393 100644 --- a/src/gui/gui.hpp +++ b/src/gui/gui.hpp @@ -2,9 +2,9 @@ #include "../../dependencies/kerep/src/base/std.h" #include "../../dependencies/kerep/src/kprint/kprintf.h" -#include "../../dependencies/SDL2/include/SDL.h" -#include "../../dependencies/SDL2/include/SDL_opengl.h" -#include "../../dependencies/imgui/imgui.h" +#include +#include +#include "imgui.h" #include "../format.hpp" #include "GraphEditor.hpp" #include "imgui_extensions.hpp" diff --git a/src/gui/imgui_extensions.hpp b/src/gui/imgui_extensions.hpp index 96cf2cb..65fa14a 100644 --- a/src/gui/imgui_extensions.hpp +++ b/src/gui/imgui_extensions.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../../dependencies/imgui/imgui.h" +#include "imgui.h" namespace ImGui { diff --git a/src/main.cpp b/src/main.cpp index dc1d200..a2bc04e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,12 +1,9 @@ #include +// SDL redefines main function for compatibility. +// THe following define disables this feature. +#define SDL_MAIN_HANDLED #include "gui/gui.hpp" - -// SDL for some reason redefines main -#ifdef main - #undef main -#endif - int main(const int argc, const char* const* argv){ if(setlocale(LC_CTYPE, "C.UTF-8")!=0) kprintf("\e[93msetlocale failed!\n"); diff --git a/tasks/clean_additions.sh b/tasks/clean_additions.sh old mode 100644 new mode 100755 index c20e009..d2c0230 --- a/tasks/clean_additions.sh +++ b/tasks/clean_additions.sh @@ -1,4 +1,3 @@ -#!/usr/bin/bash +#!/usr/bin/env bash try_delete_dir_or_file fonts/generated -try_delete_dir_or_file libs/fonts_embedded.a diff --git a/tasks/embed_fonts.sh b/tasks/embed_fonts.sh old mode 100644 new mode 100755 index b526fcc..69ba5dc --- a/tasks/embed_fonts.sh +++ b/tasks/embed_fonts.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cd fonts SRC_C="" HEADER="generated/fonts_embedded.h" diff --git a/tasks/pre_build.sh b/tasks/pre_build.sh deleted file mode 100644 index 6e86b2f..0000000 --- a/tasks/pre_build.sh +++ /dev/null @@ -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