moved srcipts to include/ and changed function include()

This commit is contained in:
Timerix 2025-11-09 22:20:58 +05:00
parent 05f3b9a0a0
commit 579dd5916e
9 changed files with 54 additions and 48 deletions

View File

@ -1,10 +1,13 @@
## 2.3.0
+ added ***project user config***! Read more in `./project.config.user.default`
+ renamed default config to `project.config.default`
+ Added ***project user config***! Read more in `./project.config.user.default`
+ Changed `include` function: replaced prefix `cbuild/` with `@cbuild/`.
+ **CONFIG:** Changed `cbuild/default_tasks` to `@cbuild/default_tasks`
+ Moved most scripts to `include/`
+ Renamed default config to `./project.config.default`
## 2.2.4
+ **default config**: C standard changed to C99
+ **default config**: enabled more warnings
+ *default config*: C standard changed to C99
+ *default config*: enabled more warnings
+ added file `default_vscode/c_cpp_properties.json`
+ fixed copying of `default_vscode` files

View File

@ -33,16 +33,16 @@ fi
function include {
local script_path="$1"
if [[ "$script_path" == cbuild/* ]]; then
script_path="$CBUILD_INSTALL_DIR/$(echo $script_path | sed 's,^cbuild/,,')"
if [[ "$script_path" == @cbuild/* ]]; then
script_path="$CBUILD_INSTALL_DIR/$(echo $script_path | sed 's,^@cbuild/,,')"
fi
# echp "including script $script_path"
. "$script_path"
}
include "cbuild/myprint.sh"
include "cbuild/functions.sh"
include "cbuild/config.sh"
include "@cbuild/include/myprint.sh"
include "@cbuild/include/functions.sh"
include "@cbuild/include/config.sh"
function print_help {
myprint "cbuild v$INSTALLED_CBUILD_VERSION"

0
chmod_scripts.sh → include/chmod_scripts.sh Executable file → Normal file
View File

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash
include cbuild/myprint.sh
include cbuild/functions.sh
include cbuild/detect_os.sh
include "@cbuild/include/myprint.sh"
include "@cbuild/include/functions.sh"
include "@cbuild/include/detect_os.sh"
function load_config {
local project_config_path="$1"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
include "cbuild/myprint.sh"
include "@cbuild/include/myprint.sh"
function detect_os {
local uname_result="$(uname -o)"

2
functions.sh → include/functions.sh Executable file → Normal file
View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
include "cbuild/myprint.sh"
include "@cbuild/include/myprint.sh"
function exec_script_line {
local script="$1"

View File

@ -71,61 +71,61 @@ case "$TASK" in
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT=""
TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
POST_TASK_SCRIPT=""
;;
# creates executable with debug info and no optimizations
build_exec_dbg)
C_ARGS="-O0 -g3"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT=""
TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
POST_TASK_SCRIPT=""
;;
# creates shared library
build_shared_lib)
C_ARGS="-O2 -fpic -flto -shared"
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=
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"
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=
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"
CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
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"
CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT=""
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
POST_TASK_SCRIPT=""
;;
# executes $EXEC_FILE
exec)
TASK_SCRIPT=cbuild/default_tasks/exec.sh
TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
;;
# executes $EXEC_FILE with valgrind memory checker
valgrind)
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd)/ --leak-check=full --show-leak-kinds=all"
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
TASK_SCRIPT="@cbuild/default_tasks/valgrind.sh"
;;
# generates profiling info
profile)
@ -139,9 +139,9 @@ case "$TASK" in
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
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=
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)
@ -152,9 +152,9 @@ case "$TASK" in
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg"
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=
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)
@ -166,9 +166,9 @@ case "$TASK" in
C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
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=
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)
@ -176,19 +176,19 @@ case "$TASK" in
C_ARGS="-O0 -g3 -fsanitize=undefined,address"
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=
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`
# 'all' can be specified to rebuild all dependencies
rebuild_dependencies)
TASK_SCRIPT=cbuild/default_tasks/rebuild_dependencies.sh
TASK_SCRIPT="@cbuild/default_tasks/rebuild_dependencies.sh"
;;
# deletes generated files
clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh
TASK_SCRIPT="@cbuild/default_tasks/clean.sh"
;;
# nothing to do
"" | no_task)

View File

@ -66,9 +66,12 @@ if [ -f "$bootstrap_install_path" ]; then
local_bootstrap_version_int=$(echo $local_bootstrap_version | sed 's/\.//g')
if [[ $local_bootstrap_version_int > $installed_bootstrap_version_int ]]; then
echo "Found outdated bootstrap.sh in '$CBUILD_INSTALL_DIR', updating"
ln -sf "$(realpath $CBUILD_INSTALL_DIR/bootstrap.sh)" -T "$bootstrap_install_path"
fi
else
echo "Not found bootstrap.sh in '$CBUILD_INSTALL_DIR', installing"
ln -sf "$(realpath $CBUILD_INSTALL_DIR/bootstrap.sh)" -T "$bootstrap_install_path"
fi
echo "Link bootstrap.sh to $CBUILD_BIN_DIR"
ln -sf "$(realpath $bootstrap_install_path)" -T "$CBUILD_BIN_DIR/cbuild"