cbuild updated

This commit is contained in:
Timerix22 2023-02-13 21:52:45 +06:00
parent cdcd18ea66
commit 9aee4065a8
8 changed files with 129 additions and 38 deletions

10
.gitignore vendored
View File

@ -1,12 +1,16 @@
# Build results # build results
bin/ bin/
obj/ obj/
*.log
*.tmp
# user files # IDE files
.old*/
.vs/ .vs/
.vshistory/ .vshistory/
.editorconfig .editorconfig
*.user *.user
*.vcxproj.filters *.vcxproj.filters
# other files
.old*/
current.config current.config

View File

@ -1,18 +1,56 @@
all: build_exec ######################################
###### Build tasks #######
######################################
##### Build cbuild/default_tasks ###### all: build_exec_dbg
build_exec:
@cbuild/call_task.sh build_exec
build_exec_dbg:
@cbuild/call_task.sh build_exec_dbg
##### Launch cbuild/default_tasks ###### # generates different profile info
build_profile:
@cbuild/call_task.sh build_profile 2>&1 | tee make_raw.log
# creates executable using profile info generated by build_profile
build_exec: build_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
######################################
###### Launch tasks #######
######################################
# executes $EXEC_FILE
exec: build_exec exec: build_exec
@cbuild/call_task.sh 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 valgrind: build_exec_dbg
@cbuild/call_task.sh valgrind @cbuild/call_task.sh valgrind 2>&1 | tee -a make_raw.log
##### Recompile kerep.a ###### ######################################
###### 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
# recompile kerep.a in the next build task
rebuild_kerep: rebuild_kerep:
@cbuild/call_task.sh rebuild_kerep @cbuild/call_task.sh rebuild_kerep

2
cbuild

@ -1 +1 @@
Subproject commit 81358b72f8dc602d694f46ea42c2b64d9b0b41c6 Subproject commit 112fcc04652d6ce65fbde215cd3d1f8935db2a7c

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
CBUILD_VERSION=4 CBUILD_VERSION=5
CONFIG_VERSION=1 CONFIG_VERSION=2
PROJECT=scolte PROJECT=scolte
CMP_C=gcc CMP_C=gcc
@ -14,44 +14,85 @@ 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')"
OUTDIR=bin # OBJDIR structure:
OBJDIR=obj # ├── objects - dir where compiled *.o files are stored. cleans every call of build task
PRE_TASK_SCRIPT=tasks/pre_build.sh # ├── profile - dir where gcc *.gcda profiling info files stored
POST_TASK_SCRIPT= # ├── libs - there you can put static libs and linker will find them
# └── out - output files are created here and then copied to OUTDIR
OBJDIR="obj"
OUTDIR="bin"
case $OS in # OS-specific options
case "$OS" in
WINDOWS) WINDOWS)
EXEC_FILE=$PROJECT.exe EXEC_FILE="$PROJECT.exe"
SHARED_LIB_FILE="$PROJECT.dll"
;; ;;
LINUX) LINUX)
EXEC_FILE=$PROJECT EXEC_FILE="$PROJECT"
;; ;;
*) *)
printf "${RED}operating system $OS has no configuration variants\n" error "operating system $OS has no configuration variants"
exit 1
;; ;;
esac esac
case $TASK in # TASKS
build_exec) case "$TASK" in
C_ARGS="-O2" rebuild_kerep)
TASK_SCRIPT=tasks/rebuild_kerep.sh
;;
# generates different profile info
build_profile)
OUTDIR="$OUTDIR/profile"
# -flto applies more optimizations across object files
# -flto=auto is needed to multithreaded copilation
# -fuse-linker-plugin is required to use static libs with lto, it strips away all
# -pg adds code to executable, that generates file containing function call info (gmon.out)
# -fprofile-generate
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_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/profile.sh
KEREP_BUILD_TASK=build_static_lib
;;
# creates executable using profile info generated by build_profile
build_exec)
# -flto applies more optimizations across object files
# -flto=auto is needed to multithreaded copilation
# -fuse-linker-plugin is required to use static libs with lto, it strips away all
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
KEREP_BUILD_TASK=build_static_lib KEREP_BUILD_TASK=build_static_lib
;; ;;
# creates executable with debug info and no optimizations
build_exec_dbg) build_exec_dbg)
C_ARGS="-O0 -g" C_ARGS="-O0 -g"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="" LINKER_ARGS="$CPP_ARGS"
PRE_TASK_SCRIPT=tasks/pre_build.sh
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
KEREP_BUILD_TASK=build_static_lib_dbg KEREP_BUILD_TASK=build_static_lib_dbg
;; ;;
# executes $EXEC_FILE
exec) exec)
TASK_SCRIPT=cbuild/default_tasks/exec.sh TASK_SCRIPT=cbuild/default_tasks/exec.sh
;; ;;
# executes $EXEC_FILE with valgrind memory checker
valgrind) 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=$PROJECT/ --leak-check=full --show-leak-kinds=all"
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
;; ;;
# deletes generated files
clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh
;;
# unknown task
*)
error "task <$TASK> not found"
;;
esac esac

2
kerep

@ -1 +1 @@
Subproject commit d2eb241d0df5c88958888afa9f577c3dd1414d21 Subproject commit dbf2c2772c832bbb6f8f56b9741a21722daa01a2

4
tasks/clean_additions.sh Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/bash
myprint "${WHITE}deleting .kerep_rebuild.tmp"
rm -rf .kerep_rebuild.tmp

View File

@ -1,13 +1,17 @@
#!/bin/bash #!/bin/bash
if [ ! -f "kerep/bin/kerep.a" ] || [ -f .rebuild_kerep ] # check if kerep static lib exists or kerep_rebuild task was executed
then if [ ! -f "$OBJDIR/libs/kerep.a" ] || [ -f .rebuild_kerep.tmp ]; then
[[ -z "$KEREP_BUILD_TASK" ]] && error "KEREP_BUILD_TASK is empty"
myprint "${BLUE}making kerep task <$KEREP_BUILD_TASK>"
cd kerep cd kerep
if ! make "$KEREP_BUILD_TASK"; then if ! make "$KEREP_BUILD_TASK"; then
exit 1 exit 1
fi fi
cd .. cd ..
rm -rf .rebuild_kerep
cp kerep/bin/kerep.a $OBJDIR/libs/
myprint "${GREEN}copied ${CYAN}kerep.a"
rm .rebuild_kerep.tmp
fi fi
cp kerep/bin/kerep.a obj/
printf "${GREEN}copied ${CYAN}kerep.a\n"

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
touch .rebuild_kerep touch .rebuild_kerep.tmp
printf "kerep.a will be rebuilt in the next build task" myprint "${YELLOW}kerep.a will be rebuilt in the next build task"