cbuild v7

This commit is contained in:
Timerix22 2023-05-24 22:24:07 +06:00
parent 729888b9d9
commit b19c020235
6 changed files with 47 additions and 53 deletions

View File

@ -12,12 +12,12 @@ build_exec: profile
build_exec_dbg: build_exec_dbg:
@cbuild/call_task.sh build_exec_dbg 2>&1 | tee make_raw.log @cbuild/call_task.sh build_exec_dbg 2>&1 | tee make_raw.log
# recompile kerep.a in the next build task # recompile libkerep.a in the next build task
rebuild_kerep: rebuild_kerep:
@tasks/rebuild_lib.sh kerep @cbuild/rebuild_dep.sh libkerep.a 2>&1 | tee make_raw.log
# recompile utf8proc.a in the next build task # recompile libutf8proc.a in the next build task
rebuild_utf8proc: rebuild_utf8proc:
@tasks/rebuild_lib.sh utf8proc @cbuild/rebuild_dep.sh libutf8proc.a 2>&1 | tee make_raw.log
rebuild_all: rebuild_kerep rebuild_utf8proc rebuild_all: rebuild_kerep rebuild_utf8proc
@ -46,6 +46,13 @@ profile:
gprof: gprof:
@cbuild/call_task.sh gprof 2>&1 | tee make_raw.log @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 # compiles executable with sanitizers and executes it to find errors and warnings
sanitize: sanitize:
@cbuild/call_task.sh sanitize 2>&1 | tee make_raw.log @cbuild/call_task.sh sanitize 2>&1 | tee make_raw.log

2
cbuild

@ -1 +1 @@
Subproject commit 5e23ef8156a85a981d60152990bde53d6e8eefe9 Subproject commit ef6a3f82c429ec232e1b910eecbdece76de933b3

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
CBUILD_VERSION=6 CBUILD_VERSION=7
CONFIG_VERSION=3 CONFIG_VERSION=4
PROJECT="scolte" PROJECT="scolte"
CMP_C="gcc" CMP_C="gcc"
@ -14,6 +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
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="kerep='build_static_lib bin libkerep.a'
utf8proc='libutf8proc.a . libutf8proc.a'"
# OBJDIR structure: # OBJDIR structure:
# ├── objects/ - dir where compiled *.o files are stored. cleans every call of build task # ├── objects/ - dir where compiled *.o files are stored. cleans every call of build task
# ├── profile/ - dir where gcc *.gcda profiling info files stored # ├── profile/ - dir where gcc *.gcda profiling info files stored
@ -47,7 +58,6 @@ case "$TASK" in
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=tasks/pre_build.sh
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)
@ -56,7 +66,8 @@ case "$TASK" in
LINKER_ARGS="$CPP_ARGS" LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh PRE_TASK_SCRIPT=tasks/pre_build.sh
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
DEPS_BUILD_TASK=build_static_lib_dbg DEPS="$DEPS
kerep='build_static_lib_dbg bin libkerep.a'"
;; ;;
# executes $EXEC_FILE # executes $EXEC_FILE
exec) exec)
@ -96,6 +107,20 @@ case "$TASK" in
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
;; ;;
# 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 # compiles executable with sanitizers and executes it to find errors and warnings
sanitize) sanitize)
OUTDIR="$OUTDIR/sanitize" OUTDIR="$OUTDIR/sanitize"
@ -111,6 +136,9 @@ case "$TASK" in
TASK_SCRIPT=cbuild/default_tasks/clean.sh TASK_SCRIPT=cbuild/default_tasks/clean.sh
POST_TASK_SCRIPT=tasks/clean_additions.sh POST_TASK_SCRIPT=tasks/clean_additions.sh
;; ;;
# nothing to do
no_task)
;;
# unknown task # unknown task
*) *)
error "task <$TASK> not found" error "task <$TASK> not found"

View File

@ -1,14 +1,4 @@
#!/usr/bin/bash #!/usr/bin/bash
set -eo pipefail set -eo pipefail
for tmpfile in $(ls -a | grep -e '\.rebuild.*\.tmp'); do
try_delete_dir_or_file "$tmpfile"
done
for submodule in kerep utf8proc; do
cd "$submodule"
make clean
cd ..
done
try_delete_dir_or_file src/generated try_delete_dir_or_file src/generated

View File

@ -1,28 +1,5 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eo pipefail
# if $lib_project.a doesn't exist or rebuild_* task was executed, builds static lib # generate source code for views/*.tui.dtsod
function handle_static_dependency {
local lib_project="$1"
local lib_build_task="$2"
local lib_build_rezults="$3"
if [ ! -f "$OBJDIR/libs/$lib_project.a" ] || [ -f .rebuild_$lib_project.tmp ]; then
[[ -z "$lib_build_task" ]] && error "lib_build_task is empty"
myprint "${BLUE}making $lib_project task <$lib_build_task>"
cd $lib_project
if ! make "$lib_build_task"; then
exit 1
fi
cd ..
cp $lib_build_rezults $OBJDIR/libs/
myprint "${GREEN}copied ${CYAN}$lib_project.a"
rm -f .rebuild_$lib_project.tmp
fi
}
handle_static_dependency kerep "$DEPS_BUILD_TASK" kerep/bin/kerep.a
handle_static_dependency utf8proc libutf8proc.a utf8proc/libutf8proc.a
source tasks/build_view.sh source tasks/build_view.sh

View File

@ -1,8 +0,0 @@
#!/bin/bash
set -eo pipefail
source cbuild/colors.sh
source cbuild/functions.sh
touch ".rebuild_$1.tmp"
rm -fv "obj/libs/$1.a"
myprint "${YELLOW}$1.a will be rebuilt in the next build task"