8 Commits

11 changed files with 41 additions and 22 deletions

View File

@@ -1 +1 @@
2.3.0
2.3.3

View File

@@ -1,3 +1,12 @@
## 2.3.3
+ now all default build dasks delete out file before building new one
## 2.3.2
+ fixed symlink creation in `OBJDIR/static_libs`
## 2.3.1
+ user config loads before project config
## 2.3.0
+ **CONFIG:** Added new file `./project.config.user.default`.
+ **CONFIG:** Changed `cbuild/default_tasks` to `@cbuild/default_tasks`.

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
INSTALLED_CBUILD_VERSION=2.3.0
INSTALLED_CBUILD_VERSION=2.3.3
# set \t size to 4 spaces
tabs 4
@@ -45,7 +45,7 @@ include "@cbuild/include/functions.sh"
include "@cbuild/include/config.sh"
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 "Usage: cbuild [OPTIONS] [TASKS]"
myprint "Options:"
@@ -74,7 +74,7 @@ do
exit 0
;;
'-v' | '--version')
myprint "cbuild v$INSTALLED_CBUILD_VERSION"
myprint "${GRAY}cbuild v$INSTALLED_CBUILD_VERSION"
exit 0
;;
'-c' | '--config')

View File

@@ -2,6 +2,7 @@
# delete old objects
clean_dir "$OBJDIR/objects"
rm -f "$EXEC_FILE"
# copy profiling info
prof_files=$(find "$OBJDIR/profile/" -name '*.gcda')

View File

@@ -2,6 +2,8 @@
# delete old objects
clean_dir "$OBJDIR/objects"
rm -f "$SHARED_LIB_FILE"
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C"
[ ! -z "$SRC_CPP" ] && compile_cpp "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$CPP_ARGS" "$INCLUDE" "$SRC_CPP"
link "$LINKER_ARGS" "$SHARED_LIB_FILE"

View File

@@ -2,6 +2,8 @@
# delete old objects
clean_dir "$OBJDIR/objects"
rm -f "$STATIC_LIB_FILE"
[ ! -z "$SRC_C" ] && compile_c "$CMP_C" "$STD_C" "$WARN_C" "$C_ARGS" "$INCLUDE" "$SRC_C"
[ ! -z "$SRC_CPP" ] && compile_cpp "$CMP_CPP" "$STD_CPP" "$WARN_CPP" "$CPP_ARGS" "$INCLUDE" "$SRC_CPP"
pack_static_lib "$STATIC_LIB_FILE"

View File

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

View File

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

View File

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

View File

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

View File

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