fixes to dependency resolution

This commit is contained in:
Timerix22 2024-02-22 00:59:54 +06:00
parent c20e1e8f1c
commit 574ce6eab3
4 changed files with 103 additions and 96 deletions

View File

@ -1,91 +1,95 @@
###################################### ######################################
###### Build tasks ####### ###### Build tasks #######
###################################### ######################################
all: build_exec_dbg all: build_exec_dbg
# creates executable using profiling info generated by profile # creates executable using profiling info generated by profile
build_exec: profile build_exec: profile
@cbuild/call_task.sh build_exec 2>&1 | tee -a make_raw.log @cbuild/call_task.sh build_exec 2>&1 | tee -a make_raw.log
# creates executable with debug info and no optimizations # creates executable with debug info and no optimizations
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
# creates shared library # creates shared library
build_shared_lib: build_shared_lib:
@cbuild/call_task.sh build_shared_lib 2>&1 | tee make_raw.log @cbuild/call_task.sh build_shared_lib 2>&1 | tee make_raw.log
# creates shared library with debug symbols and no optimizations # creates shared library with debug symbols and no optimizations
build_shared_lib_dbg: build_shared_lib_dbg:
@cbuild/call_task.sh build_shared_lib_dbg 2>&1 | tee make_raw.log @cbuild/call_task.sh build_shared_lib_dbg 2>&1 | tee make_raw.log
# creates static library # creates static library
build_static_lib: build_static_lib:
@cbuild/call_task.sh build_static_lib 2>&1 | tee make_raw.log @cbuild/call_task.sh build_static_lib 2>&1 | tee make_raw.log
# creates static library with debug symbols and no optimizations # creates static library with debug symbols and no optimizations
build_static_lib_dbg: build_static_lib_dbg:
@cbuild/call_task.sh build_static_lib_dbg 2>&1 | tee make_raw.log @cbuild/call_task.sh build_static_lib_dbg 2>&1 | tee make_raw.log
# recompile libsome_dep.a in the next build task ######################################
#rebuild_some_dep: ###### Rebuild dependencies #######
# @cbuild/rebuild_dep.sh libsome_dep.a 2>&1 | tee make_raw.log ######################################
#rebuild_all: rebuild_some_dep # recompile libsome.a in the next build task
#rebuild_some_dep:
###################################### # @cbuild/rebuild_dep.sh libsome.a 2>&1 | tee make_raw.log
###### Launch tasks #######
###################################### #rebuild_all: rebuild_some_dep
# executes $EXEC_FILE ######################################
exec: build_exec ###### Launch tasks #######
@cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log ######################################
# executes $EXEC_FILE # executes $EXEC_FILE
exec_dbg: build_exec_dbg exec: build_exec
@cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log @cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log
# executes $EXEC_FILE with valgrind memory checker # executes $EXEC_FILE
valgrind: build_exec_dbg exec_dbg: build_exec_dbg
@cbuild/call_task.sh valgrind 2>&1 | tee -a make_raw.log @cbuild/call_task.sh exec 2>&1 | tee -a make_raw.log
# generates profiling info # executes $EXEC_FILE with valgrind memory checker
profile: valgrind: build_exec_dbg
@cbuild/call_task.sh profile 2>&1 | tee make_raw.log @cbuild/call_task.sh valgrind 2>&1 | tee -a make_raw.log
# compiles program with -pg and runs it with gprof # generates profiling info
# uses gprof2dot python script to generate function call tree (pip install gprof2dot) profile:
# requires graphviz (https://www.graphviz.org/download/source/) @cbuild/call_task.sh profile 2>&1 | tee make_raw.log
gprof:
@cbuild/call_task.sh gprof 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)
# compiles program and runs it with callgrind (part of valgrind) # requires graphviz (https://www.graphviz.org/download/source/)
# uses gprof2dot python script to generate function call tree (pip install gprof2dot) gprof:
# requires graphviz (https://www.graphviz.org/download/source/) @cbuild/call_task.sh gprof 2>&1 | tee make_raw.log
# P.S. detailed results can be viewed in KCacheGrind
callgrind: # compiles program and runs it with callgrind (part of valgrind)
@cbuild/call_task.sh callgrind 2>&1 | tee make_raw.log # uses gprof2dot python script to generate function call tree (pip install gprof2dot)
# requires graphviz (https://www.graphviz.org/download/source/)
# compiles executable with sanitizers and executes it to find errors and warnings # P.S. detailed results can be viewed in KCacheGrind
sanitize: callgrind:
@cbuild/call_task.sh sanitize 2>&1 | tee make_raw.log @cbuild/call_task.sh callgrind 2>&1 | tee make_raw.log
###################################### # compiles executable with sanitizers and executes it to find errors and warnings
###### Other tasks ####### sanitize:
###################################### @cbuild/call_task.sh sanitize 2>&1 | tee make_raw.log
# deletes generated files ######################################
clean: ###### Other tasks #######
@cbuild/call_task.sh clean 2>&1 | tee make_raw.log ######################################
# removes all unreadable characters copied from stdio # deletes generated files
fix_log: clean:
sed 's/[^[:blank:][:print:]]//g' make_raw.log \ @cbuild/call_task.sh clean 2>&1 | tee make_raw.log
| sed 's/\[0;[0-9][0-9]m//g' \
| sed 's/\[0;[0-9]m//g' \ # removes all unreadable characters copied from stdio
| sed 's/\[[0-9][0-9]m//g' \ fix_log:
| sed 's/\[[0-9]m//g' \ sed 's/[^[:blank:][:print:]]//g' make_raw.log \
| sed 's/ H //g' \ | sed 's/\[0;[0-9][0-9]m//g' \
| sed 's/\[3gH //g' \ | sed 's/\[0;[0-9]m//g' \
> make_fixed.log | 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

@ -12,12 +12,14 @@ done
set +e set +e
OLDIFS="$IFS" OLDIFS="$IFS"
IFS=$'\n' IFS=$'\n'
cd "$DEPS_BASEDIR"
for dep in $DEPS; do for dep in $DEPS; do
dep_dir=$(echo ${dep/=*/} | tr -d '[:blank:]') dep_dir=$(echo ${dep/=*/} | tr -d '[:blank:]')
myprint "${CYAN}--------------[$dep_dir]--------------" myprint "${CYAN}--------------[$dep_dir]--------------"
cd "$DEPS_BASEDIR/$dep_dir" cd "$dep_dir"
make clean make clean
cd .. cd ..
done done
IFS="$OLDIFS" IFS="$OLDIFS"
set -e cd ..
set -e

View File

@ -97,11 +97,12 @@ function handle_static_dependency {
[[ -z "$lib_build_task" ]] && error "lib_build_task is empty" [[ -z "$lib_build_task" ]] && error "lib_build_task is empty"
myprint "${BLUE}making $lib_file by task $lib_build_task" myprint "${BLUE}making $lib_file by task $lib_build_task"
local proj_root_dir="$(pwd)"
cd "$deps_basedir/$lib_project_dir" cd "$deps_basedir/$lib_project_dir"
if ! make "$lib_build_task"; then if ! make "$lib_build_task"; then
exit 1 exit 1
fi fi
cd .. cd "$proj_root_dir"
cp "$deps_basedir/$lib_project_dir/$lib_build_dir/$lib_file" "$OBJDIR/libs/" cp "$deps_basedir/$lib_project_dir/$lib_build_dir/$lib_file" "$OBJDIR/libs/"
myprint "${GREEN}copied ${CYAN}$lib_file to $OBJDIR/libs/" myprint "${GREEN}copied ${CYAN}$lib_file to $OBJDIR/libs/"
@ -112,7 +113,7 @@ function handle_static_dependency {
function resolve_dependencies { function resolve_dependencies {
deps_basedir=$1 deps_basedir=$1
deps=$2 deps=$2
[[ -z "$deps_basedir" ]] && deps_basedir=. [[ -z "$deps_basedir" ]] && deps_basedir="."
OLDIFS="$IFS" OLDIFS="$IFS"
IFS=$'\n' IFS=$'\n'
# Evalueting dependency expressions. # Evalueting dependency expressions.

View File

@ -3,5 +3,5 @@ source "cbuild/init.sh"
target_file="$1" target_file="$1"
touch ".rebuild_$target_file.tmp" touch ".rebuild_$target_file.tmp"
rm -fv "$OBJDIR/libs/$target_file.a" rm -fv "$OBJDIR/libs/$target_file"
myprint "${YELLOW}dependency ${WHITE}$target_file ${YELLOW}will be rebuilt with the next build task" myprint "${YELLOW}dependency ${WHITE}$target_file ${YELLOW}will be rebuilt with the next build task"