Compare commits
5 Commits
b6ade8c31a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 886be342af | |||
| 33020d2b18 | |||
| 9cfb34946e | |||
| 7e7d05cfdc | |||
| 2bbabeb9ee |
@@ -1 +1 @@
|
|||||||
2.3.3
|
2.3.5
|
||||||
@@ -1,3 +1,10 @@
|
|||||||
|
## 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
|
||||||
|
|
||||||
## 2.3.3
|
## 2.3.3
|
||||||
+ now all default build dasks delete out file before building new one
|
+ now all default build dasks delete out file before building new one
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
INSTALLED_CBUILD_VERSION=2.3.3
|
INSTALLED_CBUILD_VERSION=2.3.5
|
||||||
|
|
||||||
# set \t size to 4 spaces
|
# set \t size to 4 spaces
|
||||||
tabs 4
|
tabs 4
|
||||||
|
|||||||
@@ -4,16 +4,12 @@
|
|||||||
clean_dir "$OBJDIR/objects"
|
clean_dir "$OBJDIR/objects"
|
||||||
rm -f "$EXEC_FILE"
|
rm -f "$EXEC_FILE"
|
||||||
|
|
||||||
# copy profiling info
|
# copy profiling info to $OBJDIR/objects/
|
||||||
prof_files=$(find "$OBJDIR/profile/" -name '*.gcda')
|
prof_files=$(find "$OBJDIR/profile/" -type f,l | tr '\n' ' ')
|
||||||
if [ -z "$prof_files" ]; then
|
if [ ! -z "$prof_files" ]; then
|
||||||
myprint "${YELLOW}no profiling info found"
|
myprint "${GREEN}profiling info found, copying to $OBJDIR/objects/"
|
||||||
else
|
myprint "${GRAY}$prof_files"
|
||||||
myprint "${GREEN}profiling info found"
|
cp $prof_files "$OBJDIR/objects/"
|
||||||
for prof_file in $prof_files; do
|
|
||||||
myprint "${GRAY}$(basename $prof_file)"
|
|
||||||
cp $prof_file "$OBJDIR/objects/"
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C"
|
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C"
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
cd "$OUTDIR"
|
cd "$OUTDIR"
|
||||||
|
|
||||||
# deleting all files except excutable
|
|
||||||
echo "$(find . ! -name $EXEC_FILE -type f -delete)"
|
|
||||||
|
|
||||||
# executing file with callgrind
|
# executing file with callgrind
|
||||||
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
|
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
|
||||||
valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./$EXEC_FILE > exec.log
|
valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./$EXEC_FILE > exec.log
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
cd "$OUTDIR"
|
cd "$OUTDIR"
|
||||||
|
|
||||||
# deleting all files except excutable
|
|
||||||
echo "$(find . ! -name $EXEC_FILE -type f -delete)"
|
|
||||||
|
|
||||||
# executing file compiled with -pg
|
# executing file compiled with -pg
|
||||||
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
|
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
|
||||||
./$EXEC_FILE > exec.log
|
./$EXEC_FILE > exec.log
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
cd "$OUTDIR"
|
cd "$OUTDIR"
|
||||||
|
|
||||||
# deleting all files except excutable
|
|
||||||
echo "$(find . ! -name $EXEC_FILE -type f -delete)"
|
|
||||||
|
|
||||||
# executing file compiled with -fprofile-gen
|
# executing file compiled with -fprofile-gen
|
||||||
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
|
myprint "${BLUE}executing $OUTDIR/$EXEC_FILE"
|
||||||
./$EXEC_FILE > exec.log
|
./$EXEC_FILE > exec.log
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ function load_config {
|
|||||||
|
|
||||||
# load project user config
|
# load project user config
|
||||||
local proj_conf_user_file="$proj_conf_file.user"
|
local proj_conf_user_file="$proj_conf_file.user"
|
||||||
|
if [ -f "$proj_conf_user_file.default" ]; then
|
||||||
file_copy_default_if_not_present "$proj_conf_user_file" "$proj_conf_user_file.default"
|
file_copy_default_if_not_present "$proj_conf_user_file" "$proj_conf_user_file.default"
|
||||||
myprint "${BLUE}loading ${WHITE}'$proj_conf_user_file'"
|
myprint "${BLUE}loading ${WHITE}'$proj_conf_user_file'"
|
||||||
# throw error on undefined variable usage
|
# throw error on undefined variable usage
|
||||||
@@ -26,6 +27,7 @@ function load_config {
|
|||||||
include "$proj_conf_user_file"
|
include "$proj_conf_user_file"
|
||||||
# don't throw error on undefined variable usage
|
# don't throw error on undefined variable usage
|
||||||
set +u
|
set +u
|
||||||
|
fi
|
||||||
|
|
||||||
myprint "${BLUE}loading ${WHITE}'$proj_conf_file'"
|
myprint "${BLUE}loading ${WHITE}'$proj_conf_file'"
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ function pack_static_lib {
|
|||||||
local outfile="$1"
|
local outfile="$1"
|
||||||
myprint "${BLUE}outfile: ${GRAY}$outfile"
|
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"
|
myprint "${BLUE}objects: ${GRAY}$objects"
|
||||||
if [ -z "$objects" ]; then
|
if [ -z "$objects" ]; then
|
||||||
error "no compiled objects found"
|
error "no compiled objects found"
|
||||||
@@ -252,7 +252,7 @@ function link {
|
|||||||
myprint "${BLUE}args: ${GRAY}$args"
|
myprint "${BLUE}args: ${GRAY}$args"
|
||||||
myprint "${BLUE}outfile: ${GRAY}$outfile"
|
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"
|
myprint "${BLUE}objects: ${GRAY}$objects"
|
||||||
if [ -z "$objects" ]; then
|
if [ -z "$objects" ]; then
|
||||||
error "no compiled objects found"
|
error "no compiled objects found"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
CBUILD_VERSION=2.3.3
|
CBUILD_VERSION=2.3.5
|
||||||
|
|
||||||
PROJECT="%PROJECT_NAME%"
|
PROJECT="%PROJECT_NAME%"
|
||||||
CMP_C="gcc"
|
CMP_C="gcc"
|
||||||
@@ -38,21 +38,24 @@ STATIC_LIB_FILE="$PROJECT.a"
|
|||||||
|
|
||||||
# example: "-I./include -I$DEPENDENCIES_DIR/libexample"
|
# example: "-I./include -I$DEPENDENCIES_DIR/libexample"
|
||||||
INCLUDE=""
|
INCLUDE=""
|
||||||
|
DEFINES=""
|
||||||
|
|
||||||
# OS-specific options
|
# OS-specific options
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
WINDOWS)
|
WINDOWS)
|
||||||
EXEC_FILE="$PROJECT.exe"
|
EXEC_FILE="$PROJECT.exe"
|
||||||
SHARED_LIB_FILE="$PROJECT.dll"
|
SHARED_LIB_FILE="$PROJECT.dll"
|
||||||
INCLUDE="$INCLUDE "
|
|
||||||
# example: "-lSDL2 -lSDL2_image"
|
# example: "-lSDL2 -lSDL2_image"
|
||||||
LINKER_LIBS=""
|
LINKER_LIBS=""
|
||||||
|
INCLUDE="$INCLUDE "
|
||||||
|
DEFINES="$DEFINES "
|
||||||
;;
|
;;
|
||||||
LINUX)
|
LINUX)
|
||||||
EXEC_FILE="$PROJECT"
|
EXEC_FILE="$PROJECT"
|
||||||
SHARED_LIB_FILE="$PROJECT.so"
|
SHARED_LIB_FILE="$PROJECT.so"
|
||||||
INCLUDE="$INCLUDE "
|
|
||||||
LINKER_LIBS=""
|
LINKER_LIBS=""
|
||||||
|
INCLUDE="$INCLUDE "
|
||||||
|
DEFINES="$DEFINES "
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "operating system $OS has no configuration variants"
|
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-use enables compiler to use profiling info files to optimize executable
|
||||||
# -fprofile-prefix-path sets path where profiling info about objects are be saved
|
# -fprofile-prefix-path sets path where profiling info about objects are be saved
|
||||||
# -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code
|
# -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"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
PRE_TASK_SCRIPT=""
|
PRE_TASK_SCRIPT=""
|
||||||
@@ -78,7 +81,7 @@ case "$TASK" in
|
|||||||
;;
|
;;
|
||||||
# creates executable with debug info and no optimizations
|
# creates executable with debug info and no optimizations
|
||||||
build_exec_dbg)
|
build_exec_dbg)
|
||||||
C_ARGS="-O0 -g3"
|
C_ARGS="-O0 -g3 $DEFINES"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
PRE_TASK_SCRIPT=""
|
PRE_TASK_SCRIPT=""
|
||||||
@@ -87,37 +90,29 @@ case "$TASK" in
|
|||||||
;;
|
;;
|
||||||
# creates shared library
|
# creates shared library
|
||||||
build_shared_lib)
|
build_shared_lib)
|
||||||
C_ARGS="-O2 -fpic -flto -shared"
|
C_ARGS="-O2 -fpic -flto -shared $DEFINES"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
||||||
PRE_TASK_SCRIPT=""
|
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# creates shared library with debug symbols and no optimizations
|
# creates shared library with debug symbols and no optimizations
|
||||||
build_shared_lib_dbg)
|
build_shared_lib_dbg)
|
||||||
C_ARGS="-O0 -g3 -fpic -shared"
|
C_ARGS="-O0 -g3 -fpic -shared $DEFINES"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
|
||||||
PRE_TASK_SCRIPT=""
|
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# creates static library
|
# creates static library
|
||||||
build_static_lib)
|
build_static_lib)
|
||||||
C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections"
|
C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections $DEFINES"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
PRE_TASK_SCRIPT=""
|
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# creates static library with debug symbols and no optimizations
|
# creates static library with debug symbols and no optimizations
|
||||||
build_static_lib_dbg)
|
build_static_lib_dbg)
|
||||||
C_ARGS="-O0 -g3"
|
C_ARGS="-O0 -g3 $DEFINES"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
PRE_TASK_SCRIPT=""
|
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# executes $EXEC_FILE
|
# executes $EXEC_FILE
|
||||||
exec)
|
exec)
|
||||||
@@ -137,12 +132,12 @@ case "$TASK" in
|
|||||||
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
||||||
# -fprofile-generate generates executable with profiling code
|
# -fprofile-generate generates executable with profiling code
|
||||||
# -fprofile-prefix-path sets path where profiling info about objects will be saved
|
# -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"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/profile.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/profile.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# compiles program with -pg and runs it with gprof
|
# compiles program with -pg and runs it with gprof
|
||||||
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
# 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
|
# https://github.com/msys2/MINGW-packages/issues/8503#issuecomment-1365475205
|
||||||
C_ARGS="-O0 -g -pg -no-pie -fno-omit-frame-pointer
|
C_ARGS="-O0 -g -pg -no-pie -fno-omit-frame-pointer
|
||||||
-fno-inline-functions -fno-inline-functions-called-once
|
-fno-inline-functions -fno-inline-functions-called-once
|
||||||
-fno-optimize-sibling-calls -fopenmp"
|
-fno-optimize-sibling-calls -fopenmp $DEFINES"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/gprof.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/gprof.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# compiles program and runs it with callgrind (part of valgrind)
|
# compiles program and runs it with callgrind (part of valgrind)
|
||||||
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
|
||||||
@@ -167,22 +161,20 @@ case "$TASK" in
|
|||||||
callgrind)
|
callgrind)
|
||||||
OUTDIR="$OUTDIR/callgrind"
|
OUTDIR="$OUTDIR/callgrind"
|
||||||
# -pg adds code to executable, that generates file containing function call info (gmon.out)
|
# -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"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/callgrind.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/callgrind.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# compiles executable with sanitizers and executes it to find errors and warnings
|
# compiles executable with sanitizers and executes it to find errors and warnings
|
||||||
sanitize)
|
sanitize)
|
||||||
OUTDIR="$OUTDIR/sanitize"
|
OUTDIR="$OUTDIR/sanitize"
|
||||||
C_ARGS="-O0 -g3 -fsanitize=undefined,address"
|
C_ARGS="-O0 -g3 -fsanitize=undefined,address $DEFINES"
|
||||||
CPP_ARGS="$C_ARGS"
|
CPP_ARGS="$C_ARGS"
|
||||||
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
|
||||||
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
|
||||||
TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
|
TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
|
||||||
POST_TASK_SCRIPT=""
|
|
||||||
;;
|
;;
|
||||||
# rebuilds specified dependencies
|
# rebuilds specified dependencies
|
||||||
# EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts`
|
# EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts`
|
||||||
|
|||||||
Reference in New Issue
Block a user