cbuild v2.0

This commit is contained in:
Timerix 2024-07-19 00:05:48 +03:00
parent 4c5e774be0
commit f4ed73a2a4
7 changed files with 41 additions and 98 deletions

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "kerep"] [submodule "kerep"]
path = kerep path = kerep
url = https://timerix.ddns.net:3322/Timerix/kerep.git url = https://timerix.ddns.net:3322/Timerix/kerep.git
[submodule "cbuild"]
path = cbuild
url = https://timerix.ddns.net:3322/Timerix/cbuild.git

View File

@ -1,75 +0,0 @@
######################################
###### Build tasks #######
######################################
all: build_exec_dbg
# creates executable using profiling 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
# recompile libkerep.a in the next build task
rebuild_kerep:
@cbuild/rebuild_dep.sh libkerep.a 2>&1 | tee make_raw.log
#rebuild_all: rebuild_kerep
######################################
###### 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

1
cbuild

@ -1 +0,0 @@
Subproject commit 6d285a88d869e7710a196aaa91a162658fe0efc0

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
CBUILD_VERSION=7 CBUILD_VERSION=2.0.2
CONFIG_VERSION=1 CONFIG_VERSION=2
PROJECT="port-tunnel" PROJECT="port-tunnel"
CMP_C="gcc" CMP_C="gcc"
@ -14,20 +14,17 @@ SRC_CPP="$( find src -name '*.cpp')"
#TESTS_C="$( find tests -name '*.c')" #TESTS_C="$( find tests -name '*.c')"
#TESTS_CPP="$(find tests -name '*.cpp')" #TESTS_CPP="$(find tests -name '*.cpp')"
# dir with dependeicy dirs # Directory with dependency configs.
DEPS_BASEDIR="." # See cbuild/example_dependency_configs
# EXAMPLE: "dependency_dir='build_task out_dir lib_file' DEPENDENCY_CONFIGS_DIR='.'
# other_depndency_dir=..." # List of dependency config files in DEPENDENCY_CONFIGS_DIR separated by space.
# Dependencies must be declared on separate lines ENABLED_DEPENDENCIES='libkerep'
# Values can be override by resetting one of dependencies:
# DEPS="$DEPS
# dependency_dir='...'"
DEPS="kerep='build_static_lib bin libkerep.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.
# └── profile/ - gcc *.gcda profiling info files
OBJDIR="obj" OBJDIR="obj"
OUTDIR="bin" OUTDIR="bin"
STATIC_LIB_FILE="lib$PROJECT.a" STATIC_LIB_FILE="lib$PROJECT.a"
@ -74,8 +71,7 @@ case "$TASK" in
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT= POST_TASK_SCRIPT=
DEPS="$DEPS ENABLED_DEPENDENCIES="libkerep-dbg"
kerep='build_static_lib_dbg bin libkerep.a'"
;; ;;
# executes $EXEC_FILE # executes $EXEC_FILE
exec) exec)
@ -83,7 +79,7 @@ case "$TASK" in
;; ;;
# executes $EXEC_FILE with valgrind memory checker # executes $EXEC_FILE with valgrind memory checker
valgrind) valgrind)
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$PROJECT/ --leak-check=full --show-leak-kinds=all" 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 TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
;; ;;
# generates profiling info # generates profiling info
@ -139,6 +135,12 @@ case "$TASK" in
TASK_SCRIPT=cbuild/default_tasks/exec.sh TASK_SCRIPT=cbuild/default_tasks/exec.sh
POST_TASK_SCRIPT= 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 # deletes generated files
clean) clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh TASK_SCRIPT=cbuild/default_tasks/clean.sh

2
kerep

@ -1 +1 @@
Subproject commit 2d98bd7719fd305985999722526f27feacb78ffb Subproject commit b1299ebd311789887031523ec4a768f9eefb4bce

10
libkerep-dbg.config Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
DEP_WORKING_DIR='kerep'
DEP_PRE_BUILD_COMMAND=''
DEP_BUILD_COMMAND='cbuild build_static_lib'
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=''

10
libkerep.config Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
DEP_WORKING_DIR='kerep'
DEP_PRE_BUILD_COMMAND=''
DEP_BUILD_COMMAND='cbuild build_static_lib'
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=''