From 42518c1ab4f52e31efed14c732344dec21b5d716 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 8 Oct 2021 15:59:24 -0600 Subject: flash_ec: update zephyr support to support flat projects Identify valid Zephyr projects by finding the zmake.yaml file. This correctly finds Zephyr projects, regardless of the directory layout under zephyr/projects. BUG=none BRANCH=none TEST="./util/flash_ec --board guybrush --dry_run --zephyr" identifies the EC binary as "build/zephyr/projects/guybrush/output/zephyr.bin" TEST="./util/flash_ec --board volteer --dry_run --zephyr" identifies the EC binary as "build/zephyr/projects/volteer/volteer/output/zephyr.bin" Signed-off-by: Keith Short Change-Id: Ib43aa718f41e4c73f2ad574f7a260f7a94c23dcf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3212779 Reviewed-by: Jack Rosenthal Reviewed-by: Diana Z Commit-Queue: Diana Z --- util/flash_ec | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/util/flash_ec b/util/flash_ec index 8fcde8d14b..a297d84a20 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -273,9 +273,16 @@ function dut_control_get_or_die { : ${BOARD:=${FLAGS_board}} # Find the Zephyr project directory for the specified board. Zephyr projects -# organized under ./zephyr/projects as / directory. -: ${ZEPHYR_DIR:=$(find zephyr/projects -mindepth 2 -maxdepth 2 \ - -type d -name "${BOARD}")} +# organized under ./zephyr/projects and always contain the file zmake.yaml +mapfile -t zephyr_projects < <(find zephyr/projects/ -type f -name "zmake.yaml") +for i in "${zephyr_projects[@]}"; do + zephyr_project_dir=$(dirname "${i}") + zephyr_project_name=$(basename "${zephyr_project_dir}") + if [[ "${BOARD}" = "${zephyr_project_name}" ]]; then + ZEPHYR_DIR="${zephyr_project_dir}" + break + fi +done in_array() { local n=$# -- cgit v1.2.1