diff options
author | Andrew Robbins <contact@andrewrobbins.info> | 2019-01-21 21:14:32 -0500 |
---|---|---|
committer | Andrew Robbins <contact@andrewrobbins.info> | 2019-01-22 03:11:41 -0500 |
commit | 6f7846b4f3dcea6cdc3752643d5bb8726d301fc5 (patch) | |
tree | 81a4797bfadcc31c8b1ec7eb93a6ad70a3b97ba4 /libs/project | |
parent | baff46b5ea55de2adb7438e354f07f8808e69393 (diff) | |
download | librebootfr-6f7846b4f3dcea6cdc3752643d5bb8726d301fc5.tar.gz librebootfr-6f7846b4f3dcea6cdc3752643d5bb8726d301fc5.zip |
Add preliminary dependency handling support
Projects may now declare other projects it depends upon through
the file "dependencies" located in a project's $CONFIGS directory.
This file requires that each dependency listed, one per line,
correspond to a project in the $PROJECTS directory; the dependency
may be in any form accepted by the libreboot script, e.g:
./libreboot build $dependency
Multiple dependencies files, one per target, are read provided
they are located in target directories and those targets were
included in the list of arguments passed to the libreboot script.
Diffstat (limited to 'libs/project')
-rwxr-xr-x | libs/project | 75 |
1 files changed, 73 insertions, 2 deletions
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 |