diff --git a/Makefile b/Makefile index 0bd17cd..3f0f054 100644 --- a/Makefile +++ b/Makefile @@ -49,10 +49,18 @@ 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 +# 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 rezults 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 diff --git a/cbuild b/cbuild index 5e23ef8..ef6a3f8 160000 --- a/cbuild +++ b/cbuild @@ -1 +1 @@ -Subproject commit 5e23ef8156a85a981d60152990bde53d6e8eefe9 +Subproject commit ef6a3f82c429ec232e1b910eecbdece76de933b3 diff --git a/default.config b/default.config index 6ef5ff7..913fe59 100644 --- a/default.config +++ b/default.config @@ -1,6 +1,6 @@ #!/bin/bash -CBUILD_VERSION=6 -CONFIG_VERSION=6 +CBUILD_VERSION=7 +CONFIG_VERSION=7 PROJECT="kerep" CMP_C="gcc" @@ -14,13 +14,23 @@ SRC_CPP="$( find src -name '*.cpp')" TESTS_C="$( find tests -name '*.c')" TESTS_CPP="$(find tests -name '*.cpp')" +# dir with dependeicy dirs +DEPS_BASEDIR="." +# 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="" + # 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 OBJDIR="obj" OUTDIR="bin" -STATIC_LIB_FILE="$PROJECT.a" +STATIC_LIB_FILE="lib$PROJECT.a" # OS-specific options case "$OS" in @@ -135,6 +145,20 @@ case "$TASK" in 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 rezults 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" + PRE_TASK_SCRIPT=tasks/pre_build.sh + TASK_SCRIPT=cbuild/default_tasks/build_exec.sh + POST_TASK_SCRIPT=cbuild/default_tasks/callgrind.sh + ;; # compiles executable with sanitizers and executes it to find errors and warnings sanitize) OUTDIR="$OUTDIR/sanitize" @@ -149,6 +173,9 @@ case "$TASK" in clean) TASK_SCRIPT=cbuild/default_tasks/clean.sh ;; + # nothing to do + no_task) + ;; # unknown task *) error "task <$TASK> not found"