From 313af03783b87b3908abbdde5e797d24c17dd390 Mon Sep 17 00:00:00 2001 From: paradajz <2544094+paradajz@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:22:51 +0200 Subject: [PATCH] build: use named arguments for gen_mcu.sh script --- scripts/gen/gen_mcu.sh | 23 ++++++++++++++++++----- scripts/gen/gen_target.sh | 5 ++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/scripts/gen/gen_mcu.sh b/scripts/gen/gen_mcu.sh index 5cb5d8167..8e44f8cee 100755 --- a/scripts/gen/gen_mcu.sh +++ b/scripts/gen/gen_mcu.sh @@ -4,15 +4,28 @@ # This script is used to provide additional project-specific # configuration on top of base configuration if required. +for arg in "$@"; do + case "$arg" in + --mcu=*) + mcu=${arg#--mcu=} + ;; + + --gen-dir=*) + gen_dir=${arg#--gen-dir=} + ;; + + --extClockMhz=*) + extClockMhz=${arg#--extClockMhz=} + ;; + esac +done + script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) -mcu=$1 -core_yaml_file=$(make --no-print-directory -C "$script_dir"/../../modules/core MCU="$mcu" print-MCU_YML_FILE) -project_yaml_file=${script_dir}/../../config/mcu/$mcu.yml -gen_dir=$2 -extClockMhz=$3 yaml_parser="dasel -n -p yaml --plain -f" +core_yaml_file=$(make --no-print-directory -C "$script_dir"/../../modules/core MCU="$mcu" print-MCU_YML_FILE) out_header="$gen_dir"/MCU.h out_cmakelists="$gen_dir"/CMakeLists.txt +project_yaml_file=${script_dir}/../../config/mcu/$mcu.yml cmake_mcu_defines_var=PROJECT_MCU_DEFINES cmake_usb_defines_var=PROJECT_USB_DEFINES diff --git a/scripts/gen/gen_target.sh b/scripts/gen/gen_target.sh index 16cc8bec7..31e0d6cd0 100755 --- a/scripts/gen/gen_target.sh +++ b/scripts/gen/gen_target.sh @@ -45,7 +45,10 @@ cmake_defines_var=PROJECT_TARGET_DEFINES if [[ ! -d $mcu_gen_dir ]] then - if ! "$script_dir"/gen_mcu.sh "$mcu" "$mcu_gen_dir" "$extClockMhz" + if ! "$script_dir"/gen_mcu.sh \ + --mcu="$mcu" \ + --gen-dir="$mcu_gen_dir" \ + --extClockMhz="$extClockMhz" then exit 1 fi