diff --git a/CHANGELOG.md b/CHANGELOG.md index e4eab53..df1d845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v2.0.2 + 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 + updated `.gitignore` diff --git a/cbuild.sh b/cbuild.sh index 8f260e6..ecf05d6 100644 --- a/cbuild.sh +++ b/cbuild.sh @@ -95,6 +95,7 @@ function call_task { local current_config_path="$1" local default_config_path="$2" local task="$3" + TASK_ARGS="$4" print_header "${CYAN}" "─" "$PROJECT/$task" load_config "$current_config_path" "$default_config_path" "$task" true @@ -117,8 +118,16 @@ function call_tasks { local tasks="$@" load_config "$current_config_path" "$default_config_path" "" false print_header "${WHITE}" "═" "$PROJECT" - for task in $tasks ; do - call_task "$current_config_path" "$default_config_path" "$task" + project_dir="$(pwd)" + 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 } diff --git a/config.sh b/config.sh index db6600e..c2248e1 100644 --- a/config.sh +++ b/config.sh @@ -27,6 +27,9 @@ function load_config { local default_config_path="$2" TASK="$3" local quiet=$4 + + myprint "${BLUE}loading config current='$(realpath $current_config_path)' default='$(realpath $default_config_path)'" + if [ -z "$current_config_path" ]; then error "current_config_path is null" fi diff --git a/default.config b/default.config index a5992bf..957001a 100644 --- a/default.config +++ b/default.config @@ -169,6 +169,12 @@ case "$TASK" in 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 + ;; # deletes generated files clean) TASK_SCRIPT=cbuild/default_tasks/clean.sh @@ -178,6 +184,6 @@ case "$TASK" in ;; # unknown task *) - error "task <$TASK> not found" + error "task <$PROJECT/$TASK> not found" ;; esac diff --git a/default_tasks/clean.sh b/default_tasks/clean.sh index 49366b4..4dddd49 100644 --- a/default_tasks/clean.sh +++ b/default_tasks/clean.sh @@ -5,8 +5,10 @@ try_delete_dir_or_file "$OUTDIR" myprint "${WHITE}deleting build logs" rm -rf *.log +project_dir="$(pwd)" for dep in $ENABLED_DEPENDENCIES; do load_dependency_config "$DEPENDENCY_CONFIGS_DIR/$dep.config" cd "$DEP_WORKING_DIR" exec_command "$DEP_CLEAN_COMMAND" + cd "$project_dir" done diff --git a/default_tasks/rebuild_dependencies.sh b/default_tasks/rebuild_dependencies.sh new file mode 100644 index 0000000..b9622e7 --- /dev/null +++ b/default_tasks/rebuild_dependencies.sh @@ -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