From 344b4375f9dafc4671d70832d42b56af4fb1f28b Mon Sep 17 00:00:00 2001 From: Timerix Date: Sun, 9 Nov 2025 23:46:47 +0500 Subject: [PATCH] updated to cbuild 2.3.0 --- dependencies/tlibc | 2 +- project.config | 81 +++++++++++++++++++------------------ project.config.user.default | 11 +++++ tasks/strip.sh | 4 -- 4 files changed, 54 insertions(+), 44 deletions(-) create mode 100644 project.config.user.default delete mode 100644 tasks/strip.sh diff --git a/dependencies/tlibc b/dependencies/tlibc index 4cc226b..bb3b096 160000 --- a/dependencies/tlibc +++ b/dependencies/tlibc @@ -1 +1 @@ -Subproject commit 4cc226b57af3691b9c6062499ce0a18755047c59 +Subproject commit bb3b096262106fcc503c03b1555ca196d5b780e9 diff --git a/project.config b/project.config index cc0a9ff..99e0229 100644 --- a/project.config +++ b/project.config @@ -1,5 +1,5 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.2.3 +CBUILD_VERSION=2.3.0 PROJECT="tcp-chat" CMP_C="gcc" @@ -18,7 +18,7 @@ WARN_C="-Wall -Wextra -Werror=incompatible-pointer-types" WARN_CPP="$WARN_C" SRC_C="$(find src -name '*.c')" -#SRC_CPP="$(find src -name '*.cpp')" +SRC_CPP="$(find src -name '*.cpp')" # Directory with dependency configs. # See cbuild/example_dependency_configs @@ -33,7 +33,7 @@ ENABLED_DEPENDENCIES='tlibc bearssl' # └── profile/ - gcc *.gcda profiling info files OBJDIR="obj" OUTDIR="bin" -STATIC_LIB_FILE="lib$PROJECT.a" +STATIC_LIB_FILE="$PROJECT.a" INCLUDE="-Isrc -Idependencies/BearSSL/inc -Idependencies/tlibc/include" @@ -69,61 +69,61 @@ case "$TASK" in C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT= - TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - POST_TASK_SCRIPT="tasks/strip.sh" + PRE_TASK_SCRIPT="" + TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh" + POST_TASK_SCRIPT="@cbuild/default_tasks/strip_exec.sh" ;; # creates executable with debug info and no optimizations build_exec_dbg) C_ARGS="-O0 -g3" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT= - TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="" + TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh" + POST_TASK_SCRIPT="" ;; # creates shared library build_shared_lib) C_ARGS="-O2 -fpic -flto -shared" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" - PRE_TASK_SCRIPT= - TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="" + TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh" + POST_TASK_SCRIPT="" ;; # creates shared library with debug symbols and no optimizations build_shared_lib_dbg) C_ARGS="-O0 -g3 -fpic -shared" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" - PRE_TASK_SCRIPT= - TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="" + TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh" + POST_TASK_SCRIPT="" ;; # creates static library build_static_lib) C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections" CPP_ARGS="$C_ARGS" - PRE_TASK_SCRIPT= - TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="" + TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh" + POST_TASK_SCRIPT="" ;; # creates static library with debug symbols and no optimizations build_static_lib_dbg) C_ARGS="-O0 -g3" CPP_ARGS="$C_ARGS" - PRE_TASK_SCRIPT= - TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="" + TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh" + POST_TASK_SCRIPT="" ;; # executes $EXEC_FILE exec) - TASK_SCRIPT=cbuild/default_tasks/exec.sh + TASK_SCRIPT="@cbuild/default_tasks/exec.sh" ;; # executes $EXEC_FILE with valgrind memory checker valgrind) 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 profile) @@ -134,12 +134,13 @@ case "$TASK" in # -pg adds code to executable, that generates file containing function call info (gmon.out) # -fprofile-generate generates executable with profiling code # -fprofile-prefix-path sets path where profiling info about objects will be saved - C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" + C_ARGS="-O2 -flto=auto -fuse-linker-plugin + -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - TASK_SCRIPT=cbuild/default_tasks/profile.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh" + TASK_SCRIPT="@cbuild/default_tasks/profile.sh" + POST_TASK_SCRIPT="" ;; # compiles program with -pg and runs it with gprof # uses gprof2dot python script to generate function call tree (pip install gprof2dot) @@ -148,12 +149,14 @@ case "$TASK" in OUTDIR="$OUTDIR/gprof" # arguments that emit some call counter code and disable optimizations to see function names # https://github.com/msys2/MINGW-packages/issues/8503#issuecomment-1365475205 - C_ARGS="-O0 -g -pg -no-pie -fno-omit-frame-pointer -fno-inline-functions -fno-inline-functions-called-once -fno-optimize-sibling-calls -fopenmp" + C_ARGS="-O0 -g -pg -no-pie -fno-omit-frame-pointer + -fno-inline-functions -fno-inline-functions-called-once + -fno-optimize-sibling-calls -fopenmp" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - TASK_SCRIPT=cbuild/default_tasks/gprof.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh" + 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) @@ -165,9 +168,9 @@ case "$TASK" in C_ARGS="-O2 -flto=auto -fuse-linker-plugin" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - TASK_SCRIPT=cbuild/default_tasks/callgrind.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh" + TASK_SCRIPT="@cbuild/default_tasks/callgrind.sh" + POST_TASK_SCRIPT="" ;; # compiles executable with sanitizers and executes it to find errors and warnings sanitize) @@ -175,19 +178,19 @@ case "$TASK" in C_ARGS="-O0 -g3 -fsanitize=undefined,address" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" - PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh - TASK_SCRIPT=cbuild/default_tasks/exec.sh - POST_TASK_SCRIPT= + PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh" + TASK_SCRIPT="@cbuild/default_tasks/exec.sh" + 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 + TASK_SCRIPT="@cbuild/default_tasks/rebuild_dependencies.sh" ;; # deletes generated files clean) - TASK_SCRIPT=cbuild/default_tasks/clean.sh + TASK_SCRIPT="@cbuild/default_tasks/clean.sh" ;; # nothing to do "" | no_task) diff --git a/project.config.user.default b/project.config.user.default new file mode 100644 index 0000000..901aa1d --- /dev/null +++ b/project.config.user.default @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Project user config is ignored by git. +# Here you can add variables that users might want to change +# on their local machine, without commiting to the repository. + +# Directory where you install dependencies. +# Do not confuse with DEPENDENCY_CONFIGS_DIR +# Example: +# libexample source code is at `../libexample`, and dependency config +# that specifies how to build this lib is at `dependencies/libexample.config` +DEPENDENCIES_DIR=".." diff --git a/tasks/strip.sh b/tasks/strip.sh deleted file mode 100644 index 31eb8c8..0000000 --- a/tasks/strip.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -exe_path="$OUTDIR/$EXEC_FILE" -myprint "${BLUE}stripping symbols from ${WHITE}$exe_path" -strip -s "$exe_path"