diff options
Diffstat (limited to 'libs')
-rwxr-xr-x | libs/common | 1 | ||||
-rwxr-xr-x | libs/project | 75 |
2 files changed, 74 insertions, 2 deletions
diff --git a/libs/common b/libs/common index da6fe754..a27ff785 100755 --- a/libs/common +++ b/libs/common @@ -34,6 +34,7 @@ VARIANTS="variants" BLOBS="blobs" BLOBS_IGNORE="blobs-ignore" BLOBS_DISCOVER="blobs-discover" +DEPENDENCIES="dependencies" DOTEPOCH=".epoch" DOTRNDSEED=".rndseed" diff --git a/libs/project b/libs/project index 99d29927..a073beef 100755 --- a/libs/project +++ b/libs/project @@ -1,6 +1,7 @@ #!/usr/bin/env bash # Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr> +# Copyright (C) 2018 Andrew Robbins <contact@andrewrobbins.info> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,9 +16,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -PROJECT_ACTIONS_GENERIC=(usage download extract update build install release clean) +PROJECT_ACTIONS_GENERIC=(usage dependencies download extract update build install release clean) PROJECT_ACTIONS_GENERIC_IGNORE_CHECK=(usage clean) -PROJECT_ACTIONS_HELPERS=(arguments) +PROJECT_ACTIONS_HELPERS=(arguments dependencies) INSTALL_REGEX='\([^:]*\):\(.*\)' @@ -55,6 +56,76 @@ project_check() { fi } +project_dependencies() { + local project=$1 + shift + + local -a dependencies + mapfile -t dependencies < <(project_file_contents_herit "$project" "$CONFIGS" "$DEPENDENCIES" "$@") + + if [[ -n ${dependencies[*]} ]]; then + printf '%s\n' "${dependencies[@]}" + fi +} + +project_dependencies_check() { + local project=$1 + shift + + local -a dependencies + mapfile -t dependencies < <(project_dependencies "$project" "$@") + + local -i count=${#dependencies[@]} + local -i missing=0 + + for ((i = 0; i < count; i++)); do + local -a dependency=(${dependencies[i]}) + + project_check "${dependency[0]}" || let missing++ + done + + return $missing +} + +project_dependencies_sources_check() { + local project=$1 + shift + + local -a dependencies + mapfile -t dependencies < <(project_dependencies "$project" "$@") + + local -i count=${#dependencies[@]} + local -i missing=0 + + for ((i = 0; i < count; i++)); do + local -a dependency=(${dependencies[i]}) + + project_sources_directory_filled_check "${dependency[0]}" \ + || let missing++ + done + + return $missing +} + +project_dependencies_action_arguments() { + local action=$1 + local project=$2 + shift 2 + + local -a dependencies + mapfile -t dependencies < <(project_dependencies "$project" "$@") + + local -i count=${#dependencies[@]} + + for ((i = 0; i < count; i++)); do + local -a dependency=(${dependencies[i]}) + + if project_function_check "${dependency[0]}" "$action"; then + project_action_arguments "$action" "${dependency[@]}" + fi + done +} + project_function_check() { local project=$1 local function=$2 |