From 2f51cd07ffaf79a7b12809fd103bda9439cfe2dd Mon Sep 17 00:00:00 2001 From: Timerix Date: Wed, 12 Nov 2025 23:52:36 +0500 Subject: [PATCH] update to cbuild 2.3.1 --- dependencies/bearssl.config | 8 +- dependencies/bearssl.project.config | 134 ++++++++++-------- .../bearssl.project.config.user.default | 11 ++ dependencies/tlibc | 2 +- dependencies/tlibc.config | 7 +- project.config | 4 +- project.config.user.default | 2 +- 7 files changed, 101 insertions(+), 67 deletions(-) create mode 100644 dependencies/bearssl.project.config.user.default diff --git a/dependencies/bearssl.config b/dependencies/bearssl.config index 9bfbc87..207ce5f 100644 --- a/dependencies/bearssl.config +++ b/dependencies/bearssl.config @@ -1,7 +1,7 @@ #!/usr/bin/env bash -DEP_WORKING_DIR="dependencies/BearSSL" +DEP_WORKING_DIR="$DEPENDENCIES_DIR" -projconfig_path="../bearssl.project.config" +projconfig_path="bearssl.project.config" if [[ "$TASK" = *_dbg ]]; then dep_build_target="build_static_lib_dbg" else @@ -10,10 +10,10 @@ fi DEP_PRE_BUILD_COMMAND="" DEP_BUILD_COMMAND="cbuild -c $projconfig_path $dep_build_target" -DEP_POST_BUILD_COMMAND="mv -v cbuild.log ../bin/cbuild_bearssl.log" +DEP_POST_BUILD_COMMAND="" DEP_CLEAN_COMMAND="cbuild -c $projconfig_path clean" DEP_DYNAMIC_OUT_FILES="" -DEP_STATIC_OUT_FILES="../bin/libbearssl.a" +DEP_STATIC_OUT_FILES="bin/libbearssl.a" DEP_OTHER_OUT_FILES="" PRESERVE_OUT_DIRECTORY_STRUCTURE=false diff --git a/dependencies/bearssl.project.config b/dependencies/bearssl.project.config index 4c2f78a..1d1ad8b 100644 --- a/dependencies/bearssl.project.config +++ b/dependencies/bearssl.project.config @@ -1,20 +1,20 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.2.3 +CBUILD_VERSION=2.3.1 PROJECT="bearssl" CMP_C="gcc" CMP_CPP="g++" -STD_C="c11" +STD_C="c99" STD_CPP="c++11" WARN_C="-Wno-unknown-pragmas" -# WARN_CPP="-Wall -Wextra" +WARN_CPP="$WARN_C" -SRC_C="$(find src -name '*.c')" -#SRC_CPP="$(find src -name '*.cpp')" +SRC_C="$(find BearSSL/src -name '*.c')" +SRC_CPP="$(find BearSSL/src -name '*.cpp')" # Directory with dependency configs. # See cbuild/example_dependency_configs -DEPENDENCY_CONFIGS_DIR='..' +DEPENDENCY_CONFIGS_DIR='.' # List of dependency config files in DEPENDENCY_CONFIGS_DIR separated by space. ENABLED_DEPENDENCIES='' @@ -23,11 +23,11 @@ ENABLED_DEPENDENCIES='' # ├── static_libs/ - Symbolic links to static libraries used by linker. Cleans on each call of build task. # ├── 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" -OUTDIR="../bin" +OBJDIR="BearSSL/obj" +OUTDIR="bin" STATIC_LIB_FILE="lib$PROJECT.a" -INCLUDE="-I./src -I./inc" +INCLUDE="-IBearSSL/src -IBearSSL/inc" # OS-specific options case "$OS" in @@ -35,13 +35,32 @@ case "$OS" in EXEC_FILE="$PROJECT.exe" SHARED_LIB_FILE="$PROJECT.dll" LINKER_LIBS="" - DEFINE="" + INCLUDE="$INCLUDE " ;; LINUX) EXEC_FILE="$PROJECT" SHARED_LIB_FILE="$PROJECT.so" LINKER_LIBS="" - DEFINE="-DBR_USE_GETENTROPY=0" + INCLUDE="$INCLUDE -DBR_USE_GETENTROPY=0" + ;; + *) + error "operating system $OS has no configuration variants" + ;; +esac + +# OS-specific options +case "$OS" in + WINDOWS) + EXEC_FILE="$PROJECT.exe" + SHARED_LIB_FILE="$PROJECT.dll" + INCLUDE="$INCLUDE " + LINKER_LIBS="" + ;; + LINUX) + EXEC_FILE="$PROJECT" + SHARED_LIB_FILE="$PROJECT.so" + INCLUDE="$INCLUDE " + LINKER_LIBS="" ;; *) error "operating system $OS has no configuration variants" @@ -58,64 +77,64 @@ case "$TASK" in # -fprofile-use enables compiler to use profiling info files to optimize executable # -fprofile-prefix-path sets path where profiling info about objects are be saved # -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code - C_ARGS="$DEFINE -O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" + 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= + PRE_TASK_SCRIPT="" + TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh" + POST_TASK_SCRIPT="" ;; # creates executable with debug info and no optimizations build_exec_dbg) - C_ARGS="$DEFINE -O0 -g3" + 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="$DEFINE -O2 -fpic -flto -shared" + 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="$DEFINE -O0 -g3 -fpic -shared" + 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="$DEFINE -O2 -fpic -fdata-sections -ffunction-sections" + 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="$DEFINE -O0 -g3" + 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) @@ -126,25 +145,28 @@ 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="$DEFINE -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) # requires graphviz (https://www.graphviz.org/download/source/) gprof) OUTDIR="$OUTDIR/gprof" - # -pg adds code to executable, that generates file containing function call info (gmon.out) - C_ARGS="$DEFINE -O2 -flto=auto -fuse-linker-plugin -pg" + # 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" 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) @@ -153,32 +175,32 @@ case "$TASK" in callgrind) OUTDIR="$OUTDIR/callgrind" # -pg adds code to executable, that generates file containing function call info (gmon.out) - C_ARGS="$DEFINE -O2 -flto=auto -fuse-linker-plugin" + 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) OUTDIR="$OUTDIR/sanitize" - C_ARGS="$DEFINE -O0 -g3 -fsanitize=undefined,address" + 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/dependencies/bearssl.project.config.user.default b/dependencies/bearssl.project.config.user.default new file mode 100644 index 0000000..8cd62f3 --- /dev/null +++ b/dependencies/bearssl.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/dependencies/tlibc b/dependencies/tlibc index bb3b096..3034e4d 160000 --- a/dependencies/tlibc +++ b/dependencies/tlibc @@ -1 +1 @@ -Subproject commit bb3b096262106fcc503c03b1555ca196d5b780e9 +Subproject commit 3034e4d1864e008a28f870ac2688053bcb6a9ce8 diff --git a/dependencies/tlibc.config b/dependencies/tlibc.config index a7eb037..3513d93 100644 --- a/dependencies/tlibc.config +++ b/dependencies/tlibc.config @@ -1,13 +1,14 @@ #!/usr/bin/env bash -DEP_WORKING_DIR="dependencies/tlibc" -DEP_PRE_BUILD_COMMAND="" -DEP_POST_BUILD_COMMAND="" + +DEP_WORKING_DIR="$DEPENDENCIES_DIR/tlibc" if [[ "$TASK" = *_dbg ]]; then dep_build_target="build_static_lib_dbg" else dep_build_target="build_static_lib" fi +DEP_PRE_BUILD_COMMAND="" DEP_BUILD_COMMAND="cbuild $dep_build_target" +DEP_POST_BUILD_COMMAND="" DEP_CLEAN_COMMAND="cbuild clean" DEP_DYNAMIC_OUT_FILES="" DEP_STATIC_OUT_FILES="bin/tlibc.a" diff --git a/project.config b/project.config index 99e0229..72ba461 100644 --- a/project.config +++ b/project.config @@ -1,5 +1,5 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.3.0 +CBUILD_VERSION=2.3.1 PROJECT="tcp-chat" CMP_C="gcc" @@ -35,7 +35,7 @@ OBJDIR="obj" OUTDIR="bin" STATIC_LIB_FILE="$PROJECT.a" -INCLUDE="-Isrc -Idependencies/BearSSL/inc -Idependencies/tlibc/include" +INCLUDE="-Isrc -I$DEPENDENCIES_DIR/BearSSL/inc -I$DEPENDENCIES_DIR/tlibc/include" # OS-specific options case "$OS" in diff --git a/project.config.user.default b/project.config.user.default index 901aa1d..f77d4b2 100644 --- a/project.config.user.default +++ b/project.config.user.default @@ -8,4 +8,4 @@ # Example: # libexample source code is at `../libexample`, and dependency config # that specifies how to build this lib is at `dependencies/libexample.config` -DEPENDENCIES_DIR=".." +DEPENDENCIES_DIR="dependencies"