rebuild_dependencies

This commit is contained in:
Timerix 2024-07-18 22:06:35 +03:00
parent b7109ef9fa
commit de9a63f84b
6 changed files with 37 additions and 4 deletions

View File

@ -1,6 +1,8 @@
# v2.0.2 # v2.0.2
+ new dependency resolution system (see **config** and `example_dependency_configs`) + new dependency resolution system (see **config** and `example_dependency_configs`)
+ **config**: changed description of `OBJDIR` + **config**: changed description of `OBJDIR`
+ **config**: added task `rebuild_dependencies`
+ added variable `TASK_ARGS` which can be used in task scripts
# v2.0.1 # v2.0.1
+ updated `.gitignore` + updated `.gitignore`

View File

@ -95,6 +95,7 @@ function call_task {
local current_config_path="$1" local current_config_path="$1"
local default_config_path="$2" local default_config_path="$2"
local task="$3" local task="$3"
TASK_ARGS="$4"
print_header "${CYAN}" "─" "$PROJECT/$task" print_header "${CYAN}" "─" "$PROJECT/$task"
load_config "$current_config_path" "$default_config_path" "$task" true load_config "$current_config_path" "$default_config_path" "$task" true
@ -117,8 +118,16 @@ function call_tasks {
local tasks="$@" local tasks="$@"
load_config "$current_config_path" "$default_config_path" "" false load_config "$current_config_path" "$default_config_path" "" false
print_header "${WHITE}" "═" "$PROJECT" print_header "${WHITE}" "═" "$PROJECT"
for task in $tasks ; do project_dir="$(pwd)"
call_task "$current_config_path" "$default_config_path" "$task" for task_str in $tasks ; do
task=$(safeprint "$task_str" | sed 's/=.*//g')
local args_str=$(safeprint "$task_str" | grep -oP '(?<=\=).*' || echo "")
IFS_backup="$IFS"
IFS=',;'
args_array=($args_str)
IFS="$IFS_backup"
call_task "$current_config_path" "$default_config_path" "$task" "${args_array[@]}"
cd "$project_dir"
done done
} }

View File

@ -27,6 +27,9 @@ function load_config {
local default_config_path="$2" local default_config_path="$2"
TASK="$3" TASK="$3"
local quiet=$4 local quiet=$4
myprint "${BLUE}loading config current='$(realpath $current_config_path)' default='$(realpath $default_config_path)'"
if [ -z "$current_config_path" ]; then if [ -z "$current_config_path" ]; then
error "current_config_path is null" error "current_config_path is null"
fi fi

View File

@ -169,6 +169,12 @@ case "$TASK" in
TASK_SCRIPT=cbuild/default_tasks/exec.sh TASK_SCRIPT=cbuild/default_tasks/exec.sh
POST_TASK_SCRIPT= 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
;;
# deletes generated files # deletes generated files
clean) clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh TASK_SCRIPT=cbuild/default_tasks/clean.sh
@ -178,6 +184,6 @@ case "$TASK" in
;; ;;
# unknown task # unknown task
*) *)
error "task <$TASK> not found" error "task <$PROJECT/$TASK> not found"
;; ;;
esac esac

View File

@ -5,8 +5,10 @@ try_delete_dir_or_file "$OUTDIR"
myprint "${WHITE}deleting build logs" myprint "${WHITE}deleting build logs"
rm -rf *.log rm -rf *.log
project_dir="$(pwd)"
for dep in $ENABLED_DEPENDENCIES; do for dep in $ENABLED_DEPENDENCIES; do
load_dependency_config "$DEPENDENCY_CONFIGS_DIR/$dep.config" load_dependency_config "$DEPENDENCY_CONFIGS_DIR/$dep.config"
cd "$DEP_WORKING_DIR" cd "$DEP_WORKING_DIR"
exec_command "$DEP_CLEAN_COMMAND" exec_command "$DEP_CLEAN_COMMAND"
cd "$project_dir"
done done

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
dependencies="$TASK_ARGS"
if [ "$dependencies" = 'all' ]; then
dependencies="$ENABLED_DEPENDENCIES"
fi
if [ ! -z "$dependencies" ]; then
myprint "${BLUE}dependencies to be rebuild: $dependencies"
build_dependencies "$dependencies" true
else
myprint "${YELLOW}no dependencies specified"
fi