3 Commits

9 changed files with 31 additions and 49 deletions

View File

@@ -1 +1 @@
2.3.4
2.3.5

View File

@@ -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

View File

@@ -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

View File

@@ -4,16 +4,12 @@
clean_dir "$OBJDIR/objects"
rm -f "$EXEC_FILE"
# copy profiling info
prof_files=$(find "$OBJDIR/profile/" -name '*.gcda')
if [ -z "$prof_files" ]; then
myprint "${YELLOW}no profiling info found"
else
myprint "${GREEN}profiling info found"
for prof_file in $prof_files; do
myprint "${GRAY}$(basename $prof_file)"
cp $prof_file "$OBJDIR/objects/"
done
# copy profiling info to $OBJDIR/objects/
prof_files=$(find "$OBJDIR/profile/" -type f,l | tr '\n' ' ')
if [ ! -z "$prof_files" ]; then
myprint "${GREEN}profiling info found, copying to $OBJDIR/objects/"
myprint "${GRAY}$prof_files"
cp $prof_files "$OBJDIR/objects/"
fi
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C"

View File

@@ -2,9 +2,6 @@
cd "$OUTDIR"
# deleting all files except excutable
echo "$(find . ! -name $EXEC_FILE -type f -delete)"
# executing file with callgrind
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./$EXEC_FILE > exec.log

View File

@@ -2,9 +2,6 @@
cd "$OUTDIR"
# deleting all files except excutable
echo "$(find . ! -name $EXEC_FILE -type f -delete)"
# executing file compiled with -pg
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
./$EXEC_FILE > exec.log

View File

@@ -2,9 +2,6 @@
cd "$OUTDIR"
# deleting all files except excutable
echo "$(find . ! -name $EXEC_FILE -type f -delete)"
# executing file compiled with -fprofile-gen
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
./$EXEC_FILE > exec.log

View File

@@ -226,7 +226,7 @@ function pack_static_lib {
local outfile="$1"
myprint "${BLUE}outfile: ${GRAY}$outfile"
local objects=$(find $OBJDIR/objects -type f,l | tr '\n' ' ')
local objects=$(find $OBJDIR/objects \( -name "*.o" -o -name "*.a" \) -type f,l | tr '\n' ' ')
myprint "${BLUE}objects: ${GRAY}$objects"
if [ -z "$objects" ]; then
error "no compiled objects found"
@@ -252,7 +252,7 @@ function link {
myprint "${BLUE}args: ${GRAY}$args"
myprint "${BLUE}outfile: ${GRAY}$outfile"
local objects=$(find $OBJDIR/objects -type f,l | tr '\n' ' ')
local objects=$(find $OBJDIR/objects \( -name "*.o" -o -name "*.a" \) -type f,l | tr '\n' ' ')
myprint "${BLUE}objects: ${GRAY}$objects"
if [ -z "$objects" ]; then
error "no compiled objects found"

View File

@@ -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`