From 9cfb34946e7cdd873329d1f74c4f6eaf7511cbe5 Mon Sep 17 00:00:00 2001 From: Timerix Date: Sun, 7 Jun 2026 17:05:40 +0500 Subject: [PATCH] v2.3.5: added var DEFINES --- CBUILD_VERSION | 2 +- CHANGELOG.md | 5 ++++- cbuild.sh | 2 +- project.config.default | 42 +++++++++++++++++------------------------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/CBUILD_VERSION b/CBUILD_VERSION index fd06a92..3b26524 100644 --- a/CBUILD_VERSION +++ b/CBUILD_VERSION @@ -1 +1 @@ -2.3.4 \ No newline at end of file +2.3.5 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e8281..64c2a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ +## 2.3.5 ++ **CONFIG:** added var `DEFINES` which is appended to `C_ARGS` in tasks + ## 2.3.4 ++ **CONFIG:** fixed `WARN_CPP` + fixed failing if `./project.user.config.default` do not exist -+ fixed `WARN_CPP` ## 2.3.3 + now all default build dasks delete out file before building new one diff --git a/cbuild.sh b/cbuild.sh index 35934a5..8a5aa1e 100755 --- a/cbuild.sh +++ b/cbuild.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -INSTALLED_CBUILD_VERSION=2.3.4 +INSTALLED_CBUILD_VERSION=2.3.5 # set \t size to 4 spaces tabs 4 diff --git a/project.config.default b/project.config.default index 4be033d..5fb3df1 100755 --- a/project.config.default +++ b/project.config.default @@ -1,5 +1,5 @@ #!/usr/bin/env bash -CBUILD_VERSION=2.3.4 +CBUILD_VERSION=2.3.5 PROJECT="%PROJECT_NAME%" CMP_C="gcc" @@ -38,21 +38,24 @@ STATIC_LIB_FILE="$PROJECT.a" # example: "-I./include -I$DEPENDENCIES_DIR/libexample" INCLUDE="" +DEFINES="" # OS-specific options case "$OS" in WINDOWS) EXEC_FILE="$PROJECT.exe" SHARED_LIB_FILE="$PROJECT.dll" - INCLUDE="$INCLUDE " # example: "-lSDL2 -lSDL2_image" LINKER_LIBS="" + INCLUDE="$INCLUDE " + DEFINES="$DEFINES " ;; LINUX) EXEC_FILE="$PROJECT" SHARED_LIB_FILE="$PROJECT.so" - INCLUDE="$INCLUDE " LINKER_LIBS="" + INCLUDE="$INCLUDE " + DEFINES="$DEFINES " ;; *) error "operating system $OS has no configuration variants" @@ -69,7 +72,7 @@ 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="-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 $DEFINES" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" PRE_TASK_SCRIPT="" @@ -78,7 +81,7 @@ case "$TASK" in ;; # creates executable with debug info and no optimizations build_exec_dbg) - C_ARGS="-O0 -g3" + C_ARGS="-O0 -g3 $DEFINES" CPP_ARGS="$C_ARGS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" PRE_TASK_SCRIPT="" @@ -87,37 +90,29 @@ case "$TASK" in ;; # creates shared library build_shared_lib) - C_ARGS="-O2 -fpic -flto -shared" + C_ARGS="-O2 -fpic -flto -shared $DEFINES" 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="" ;; # creates shared library with debug symbols and no optimizations build_shared_lib_dbg) - C_ARGS="-O0 -g3 -fpic -shared" + C_ARGS="-O0 -g3 -fpic -shared $DEFINES" 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="" ;; # creates static library build_static_lib) - C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections" + C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections $DEFINES" CPP_ARGS="$C_ARGS" - 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" + C_ARGS="-O0 -g3 $DEFINES" CPP_ARGS="$C_ARGS" - PRE_TASK_SCRIPT="" TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh" - POST_TASK_SCRIPT="" ;; # executes $EXEC_FILE exec) @@ -137,12 +132,12 @@ 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 $DEFINES" 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="" ;; # compiles program with -pg and runs it with gprof # uses gprof2dot python script to generate function call tree (pip install gprof2dot) @@ -153,12 +148,11 @@ case "$TASK" in # 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" + -fno-optimize-sibling-calls -fopenmp $DEFINES" 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="" ;; # compiles program and runs it with callgrind (part of valgrind) # uses gprof2dot python script to generate function call tree (pip install gprof2dot) @@ -167,22 +161,20 @@ case "$TASK" in 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" + C_ARGS="-O2 -flto=auto -fuse-linker-plugin $DEFINES" 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="" ;; # compiles executable with sanitizers and executes it to find errors and warnings sanitize) OUTDIR="$OUTDIR/sanitize" - C_ARGS="-O0 -g3 -fsanitize=undefined,address" + C_ARGS="-O0 -g3 -fsanitize=undefined,address $DEFINES" 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="" ;; # rebuilds specified dependencies # EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts`