From 6f7846b4f3dcea6cdc3752643d5bb8726d301fc5 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Mon, 21 Jan 2019 21:14:32 -0500 Subject: 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. --- libs/common | 1 + 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 +# Copyright (C) 2018 Andrew Robbins # # 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 . -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 -- cgit v1.2.3-70-g09d2