7 Commits

Author SHA1 Message Date
3198f8905e v2.3.2: fixed symlink creation 2025-11-19 13:47:34 +05:00
458652d0c5 default project config change 2025-11-12 15:13:10 +05:00
7ef47c567c default user config change 2025-11-12 15:11:32 +05:00
1a4ad2a3f0 default user config change 2025-11-12 15:10:40 +05:00
f0ee39084e v2.3.1 2025-11-12 14:34:08 +05:00
e655f05da6 stopped writing {GRAY} before each message in myprint() 2025-11-12 14:33:22 +05:00
5cc2e1c2ad load user config before project config 2025-11-12 14:31:22 +05:00
8 changed files with 33 additions and 22 deletions

View File

@@ -1 +1 @@
2.3.0 2.3.2

View File

@@ -1,3 +1,9 @@
## 2.3.2
+ fixed symlink creation in `OBJDIR/static_libs`
## 2.3.1
+ user config loads before project config
## 2.3.0 ## 2.3.0
+ **CONFIG:** Added new file `./project.config.user.default`. + **CONFIG:** Added new file `./project.config.user.default`.
+ **CONFIG:** Changed `cbuild/default_tasks` to `@cbuild/default_tasks`. + **CONFIG:** Changed `cbuild/default_tasks` to `@cbuild/default_tasks`.

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
INSTALLED_CBUILD_VERSION=2.3.0 INSTALLED_CBUILD_VERSION=2.3.2
# set \t size to 4 spaces # set \t size to 4 spaces
tabs 4 tabs 4
@@ -45,7 +45,7 @@ include "@cbuild/include/functions.sh"
include "@cbuild/include/config.sh" include "@cbuild/include/config.sh"
function print_help { function print_help {
myprint "cbuild v$INSTALLED_CBUILD_VERSION" myprint "${GRAY}cbuild v$INSTALLED_CBUILD_VERSION"
myprint "C/C++ project build system written in bash." myprint "C/C++ project build system written in bash."
myprint "Usage: cbuild [OPTIONS] [TASKS]" myprint "Usage: cbuild [OPTIONS] [TASKS]"
myprint "Options:" myprint "Options:"
@@ -74,7 +74,7 @@ do
exit 0 exit 0
;; ;;
'-v' | '--version') '-v' | '--version')
myprint "cbuild v$INSTALLED_CBUILD_VERSION" myprint "${GRAY}cbuild v$INSTALLED_CBUILD_VERSION"
exit 0 exit 0
;; ;;
'-c' | '--config') '-c' | '--config')

View File

@@ -10,8 +10,6 @@ function load_config {
#true or false #true or false
local quiet=$3 local quiet=$3
myprint "${BLUE}loading ${WHITE}'$proj_conf_file'"
if [ -z "$proj_conf_file" ]; then if [ -z "$proj_conf_file" ]; then
error "config path is null" error "config path is null"
fi fi
@@ -19,6 +17,18 @@ function load_config {
error "${YELLOW}$proj_conf_file doesn't exist" error "${YELLOW}$proj_conf_file doesn't exist"
fi fi
# load project user config
local proj_conf_user_file="$proj_conf_file.user"
file_copy_default_if_not_present "$proj_conf_user_file" "$proj_conf_user_file.default"
myprint "${BLUE}loading ${WHITE}'$proj_conf_user_file'"
# throw error on undefined variable usage
set -u
include "$proj_conf_user_file"
# don't throw error on undefined variable usage
set +u
myprint "${BLUE}loading ${WHITE}'$proj_conf_file'"
OS=$(detect_os) OS=$(detect_os)
ARCH=$(detect_arch) ARCH=$(detect_arch)
myprint_quiet $quiet "${GREEN}detected OS: $OS" myprint_quiet $quiet "${GREEN}detected OS: $OS"
@@ -48,15 +58,8 @@ function load_config {
myprint "${YELLOW}Install it to get latest bugfixes." myprint "${YELLOW}Install it to get latest bugfixes."
fi fi
# throw error on undefined variable usage
set -u set -u
include "$proj_conf_file" include "$proj_conf_file"
# load project user config
local proj_conf_user_file="$proj_conf_file.user"
file_copy_default_if_not_present "$proj_conf_user_file" "$proj_conf_user_file.default"
myprint "${BLUE}loading ${WHITE}'$proj_conf_user_file'"
include "$proj_conf_user_file"
mkdir -p "$OUTDIR" mkdir -p "$OUTDIR"
mkdir -p "$OBJDIR/objects" mkdir -p "$OBJDIR/objects"
@@ -64,7 +67,6 @@ function load_config {
mkdir -p "$OBJDIR/dynamic_libs" mkdir -p "$OBJDIR/dynamic_libs"
mkdir -p "$OBJDIR/profile" mkdir -p "$OBJDIR/profile"
# dont thorw error on undefined variable
set +u set +u
myprint_quiet $quiet "${GREEN}config loading completed" myprint_quiet $quiet "${GREEN}config loading completed"

View File

@@ -4,7 +4,6 @@ include "@cbuild/include/myprint.sh"
function detect_os { function detect_os {
local uname_result="$(uname -o)" local uname_result="$(uname -o)"
# myprint "uname result: '$uname_result'"
case "$uname_result" in case "$uname_result" in
Msys | Cygwin | MS/Windows) Msys | Cygwin | MS/Windows)
safeprint WINDOWS safeprint WINDOWS

View File

@@ -137,8 +137,8 @@ function build_dependency {
# creates symbolic link to each file in $OBJDIR/static_libs # creates symbolic link to each file in $OBJDIR/static_libs
for file in $DEP_STATIC_OUT_FILES; do for file in $DEP_STATIC_OUT_FILES; do
# doesnt return error if called not like this # doesnt return error if called not like this
f=$(realpath $file) real_file=$(realpath $file)
ln -sfv $f "$proj_root_dir/$OBJDIR/static_libs" ln -sfv "$real_file" "$proj_root_dir/$OBJDIR/static_libs/"
done done
fi fi
@@ -233,7 +233,9 @@ function pack_static_lib {
fi fi
local command="ar rcs $OUTDIR/$outfile $objects" local command="ar rcs $OUTDIR/$outfile $objects"
myprint "$command" print_hline "${GRAY}" "─"
myprint "${GRAY}$command"
print_hline "${GRAY}" "─"
if $command if $command
then then
myprint "${GREEN}file $CYAN$outfile ${GREEN}created" myprint "${GREEN}file $CYAN$outfile ${GREEN}created"
@@ -268,7 +270,9 @@ function link {
done done
local command="$CMP_CPP $objects $static_libs $args $dynamic_libs_args -o $OUTDIR/$outfile" local command="$CMP_CPP $objects $static_libs $args $dynamic_libs_args -o $OUTDIR/$outfile"
myprint "$command" print_hline "${GRAY}" "─"
myprint "${GRAY}$command"
print_hline "${GRAY}" "─"
if $command if $command
then then
myprint "${GREEN}file $CYAN$outfile ${GREEN}created" myprint "${GREEN}file $CYAN$outfile ${GREEN}created"

View File

@@ -18,7 +18,7 @@ function safeprint {
# prints text with special characters and resets color # prints text with special characters and resets color
function myprint { function myprint {
printf "${GRAY}$@${GRAY}\n" printf "$@${GRAY}\n"
} }
function myprint_quiet { function myprint_quiet {

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
CBUILD_VERSION=2.3.0 CBUILD_VERSION=2.3.2
PROJECT="%PROJECT_NAME%" PROJECT="%PROJECT_NAME%"
CMP_C="gcc" CMP_C="gcc"
@@ -35,7 +35,7 @@ OBJDIR="obj"
OUTDIR="bin" OUTDIR="bin"
STATIC_LIB_FILE="$PROJECT.a" STATIC_LIB_FILE="$PROJECT.a"
# example: "-I./include" # example: "-I./include -I$DEPENDENCIES_DIR/libexample"
INCLUDE="" INCLUDE=""
# OS-specific options # OS-specific options