From 557e56021395bf008573ca2a22995216d31db72a Mon Sep 17 00:00:00 2001 From: zhiayang Date: Fri, 9 Feb 2024 12:07:51 -0500 Subject: [PATCH 1/9] make setup.sh prompt for board revision for boards that have revisions --- docs/src/templates/setup.sh.mustache | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/src/templates/setup.sh.mustache b/docs/src/templates/setup.sh.mustache index c711dbc5b1c..09ed8c29b87 100644 --- a/docs/src/templates/setup.sh.mustache +++ b/docs/src/templates/setup.sh.mustache @@ -122,6 +122,9 @@ if [ "$keyboard_shield" == "y" ]; then board_ids=({{#boards}}"{{id}}" {{/boards}}) boards_usb_only=({{#boards}}"{{#usb_only}}y{{/usb_only}}{{^usb_only}}n{{/usb_only}}" {{/boards}}) + boards_revisions=({{#boards}}"{{#revisions}}{{.}} {{/revisions}}" {{/boards}}) + boards_default_revision=({{#boards}}"{{{default_revision}}}" {{/boards}}) + echo "" echo "MCU Board Selection:" PS3="$prompt " @@ -151,6 +154,34 @@ if [ "$keyboard_shield" == "y" ]; then esac done + + if [ -n "${boards_revisions[$board_index]}" ]; then + read -a _valid_revisions <<< "${boards_revisions[$board_index]}" + for (( _i=0; _i<${#_valid_revisions}; _i++ )); do + if [ "${boards_default_revision[board_index]}" = "${_valid_revisions[_i]}" ]; then + _valid_revisions[_i]+=" (default)" + fi + done + + echo "" + echo "MCU Board Revision:" + select opt in "${_valid_revisions[@]}" "Quit"; do + ''|*[!0-9]*) echo "Invalid option. Try another one."; continue;; + + $(( ${#_valid_revisions[@]}+1 )) ) echo "Goodbye!"; exit 1;; + *) + if [ $REPLY -gt $(( ${#_valid_revisions[@]}+1 )) ] || [ $REPLY -lt 0 ]; then + echo "Invalid option. Try another one." + continue + fi + + _rev_index=$(( $REPLY-1 )) + board="${board_ids[$board_index]}@${_valid_revisions[_rev_index]}" + boards=( "${board}" ) + break + ;; + done + fi else board=${keyboard} boards=$keyboard_siblings From f92719dc85098a824798f479f32a03e8f90c18f6 Mon Sep 17 00:00:00 2001 From: zhiayang Date: Fri, 9 Feb 2024 11:31:44 -0500 Subject: [PATCH 2/9] update schema even though i thought i did --- schema/hardware-metadata.schema.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/schema/hardware-metadata.schema.json b/schema/hardware-metadata.schema.json index 4c2bdf3b730..9d2cbe37fcd 100644 --- a/schema/hardware-metadata.schema.json +++ b/schema/hardware-metadata.schema.json @@ -18,6 +18,15 @@ "type": "string", "pattern": "^[a-z0-9_]+$" }, + "revisions": { + "type": "array", + "items": { + "type": "string" + } + }, + "default_revision": { + "type": "string" + }, "keyboard_siblings": { "type": "array", "items": { @@ -133,6 +142,12 @@ "type": { "type": "string", "const": "interconnect" + }, + "revisions": { + "type": "#/$defs/revisions" + }, + "default_revision": { + "type": "#/$defs/default_revision" } } }, @@ -202,6 +217,12 @@ }, "exposes": { "$ref": "#/$defs/interconnects" + }, + "revisions": { + "type": "#/$defs/revisions" + }, + "default_revision": { + "type": "#/$defs/default_revision" } } }, @@ -255,6 +276,12 @@ }, "exposes": { "$ref": "#/$defs/interconnects" + }, + "revisions": { + "type": "#/$defs/revisions" + }, + "default_revision": { + "type": "#/$defs/default_revision" } } } From 2aba7f89d40732587e8b521ac398f0792d87f3a7 Mon Sep 17 00:00:00 2001 From: zhiayang Date: Fri, 9 Feb 2024 12:09:03 -0500 Subject: [PATCH 3/9] update schema --- schema/hardware-metadata.schema.json | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/schema/hardware-metadata.schema.json b/schema/hardware-metadata.schema.json index 9d2cbe37fcd..a4b3c5fbd8d 100644 --- a/schema/hardware-metadata.schema.json +++ b/schema/hardware-metadata.schema.json @@ -18,13 +18,7 @@ "type": "string", "pattern": "^[a-z0-9_]+$" }, - "revisions": { - "type": "array", - "items": { - "type": "string" - } - }, - "default_revision": { + "revision": { "type": "string" }, "keyboard_siblings": { @@ -144,10 +138,13 @@ "const": "interconnect" }, "revisions": { - "type": "#/$defs/revisions" + "type": "array", + "items": { + "$ref": "#/$defs/revision" + } }, "default_revision": { - "type": "#/$defs/default_revision" + "$ref": "#/$defs/revision" } } }, @@ -219,10 +216,13 @@ "$ref": "#/$defs/interconnects" }, "revisions": { - "type": "#/$defs/revisions" + "type": "array", + "items": { + "$ref": "#/$defs/revision" + } }, "default_revision": { - "type": "#/$defs/default_revision" + "$ref": "#/$defs/revision" } } }, @@ -278,10 +278,13 @@ "$ref": "#/$defs/interconnects" }, "revisions": { - "type": "#/$defs/revisions" + "type": "array", + "items": { + "$ref": "#/$defs/revision" + } }, "default_revision": { - "type": "#/$defs/default_revision" + "$ref": "#/$defs/revision" } } } From 46789297911ecbd79e9d9e7bec69f9b3076f4223 Mon Sep 17 00:00:00 2001 From: zhiayang Date: Fri, 9 Feb 2024 12:09:43 -0500 Subject: [PATCH 4/9] update schema again --- schema/hardware-metadata.schema.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/schema/hardware-metadata.schema.json b/schema/hardware-metadata.schema.json index a4b3c5fbd8d..b4efe86b65d 100644 --- a/schema/hardware-metadata.schema.json +++ b/schema/hardware-metadata.schema.json @@ -16,10 +16,11 @@ "$defs": { "id": { "type": "string", - "pattern": "^[a-z0-9_]+$" + "pattern": "^[a-z0-9_]+(@([A-Z]|[0-9]+|([0-9]+(\\.[0-9]+){1,2})))?$" }, "revision": { - "type": "string" + "type": "string", + "pattern": "[A-Z]|[0-9]+|([0-9]+(\\.[0-9]+){1,2})" }, "keyboard_siblings": { "type": "array", From 4fd32718e11ae783effeb3f2c0680eb78121df35 Mon Sep 17 00:00:00 2001 From: zhiayang Date: Sun, 10 Mar 2024 21:55:39 -0400 Subject: [PATCH 5/9] only boards have revisions, for now --- schema/hardware-metadata.schema.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/schema/hardware-metadata.schema.json b/schema/hardware-metadata.schema.json index b4efe86b65d..9710c792392 100644 --- a/schema/hardware-metadata.schema.json +++ b/schema/hardware-metadata.schema.json @@ -137,15 +137,6 @@ "type": { "type": "string", "const": "interconnect" - }, - "revisions": { - "type": "array", - "items": { - "$ref": "#/$defs/revision" - } - }, - "default_revision": { - "$ref": "#/$defs/revision" } } }, @@ -277,15 +268,6 @@ }, "exposes": { "$ref": "#/$defs/interconnects" - }, - "revisions": { - "type": "array", - "items": { - "$ref": "#/$defs/revision" - } - }, - "default_revision": { - "$ref": "#/$defs/revision" } } } From c6da7fea2673a0893af3a8547830e37d596ab6db Mon Sep 17 00:00:00 2001 From: zhiayang Date: Sun, 10 Mar 2024 22:25:50 -0400 Subject: [PATCH 6/9] fix shell script --- docs/src/templates/setup.sh.mustache | 30 +++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/src/templates/setup.sh.mustache b/docs/src/templates/setup.sh.mustache index 09ed8c29b87..b19c96cbc35 100644 --- a/docs/src/templates/setup.sh.mustache +++ b/docs/src/templates/setup.sh.mustache @@ -166,20 +166,22 @@ if [ "$keyboard_shield" == "y" ]; then echo "" echo "MCU Board Revision:" select opt in "${_valid_revisions[@]}" "Quit"; do - ''|*[!0-9]*) echo "Invalid option. Try another one."; continue;; - - $(( ${#_valid_revisions[@]}+1 )) ) echo "Goodbye!"; exit 1;; - *) - if [ $REPLY -gt $(( ${#_valid_revisions[@]}+1 )) ] || [ $REPLY -lt 0 ]; then - echo "Invalid option. Try another one." - continue - fi - - _rev_index=$(( $REPLY-1 )) - board="${board_ids[$board_index]}@${_valid_revisions[_rev_index]}" - boards=( "${board}" ) - break - ;; + case "$REPLY" in + ''|*[!0-9]*) echo "Invalid option. Try another one."; continue;; + + $(( ${#_valid_revisions[@]}+1 )) ) echo "Goodbye!"; exit 1;; + *) + if [ $REPLY -gt $(( ${#_valid_revisions[@]}+1 )) ] || [ $REPLY -lt 0 ]; then + echo "Invalid option. Try another one." + continue + fi + + _rev_index=$(( $REPLY-1 )) + board="${board_ids[$board_index]}@${_valid_revisions[_rev_index]}" + boards=( "${board}" ) + break + ;; + esac done fi else From 6f815b400d1bef697ab05e97e540d3266d0d2c3d Mon Sep 17 00:00:00 2001 From: zhiayang Date: Sun, 10 Mar 2024 22:56:24 -0400 Subject: [PATCH 7/9] update powershell script --- docs/src/templates/setup.ps1.mustache | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/src/templates/setup.ps1.mustache b/docs/src/templates/setup.ps1.mustache index 90f9cdcfaec..178bc2c79b9 100644 --- a/docs/src/templates/setup.ps1.mustache +++ b/docs/src/templates/setup.ps1.mustache @@ -131,6 +131,19 @@ if ($keyboard_type -eq "shield") { {{/boards}} } + $boards_revisions = [ordered]@{ + {{#boards}} + {{id}} = @({{#revisions}} + "{{.}}"{{/revisions}}); + {{/boards}} + } + + $boards_default_revision=[ordered]@{ + {{#boards}} + {{id}} = "{{{default_revision}}}"; + {{/boards}} + } + Write-Host "$title" Write-Host "" Write-Host "MCU Board Selection:" @@ -145,6 +158,20 @@ if ($keyboard_type -eq "shield") { $shields = $keyboard_siblings $board = $($($boards.keys)[$choice]) $boards = ( $board ) + + if ($($($boards_revisions.values)[$choice]).count -gt 0) { + $valid_revisions = $($($boards_revisions.values)[$choice]) + for ($i = 0; $i -lt $valid_revisions.count; $i += 1) { + if ($valid_revisions[$i] -eq $($($boards_default_revision.values)[$choice])) { + $valid_revisions[$i] += " (default)" + } + } + + $revision_choice = Get-Choice-From-Options -Options $valid_revisions -Prompt $prompt + $board = $board + "@" + $valid_revisions[$revision_choice] + $boards = ( $board ) + } + } else { $boards = ( $keyboard_siblings ) $shields = @( ) From 6703ed3b7d303e8e6194ca93914daf8d8e3f8a0c Mon Sep 17 00:00:00 2001 From: zhiayang Date: Sun, 10 Mar 2024 23:00:27 -0400 Subject: [PATCH 8/9] fix bug in powershell setup script when using default revision --- docs/src/templates/setup.ps1.mustache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/src/templates/setup.ps1.mustache b/docs/src/templates/setup.ps1.mustache index 178bc2c79b9..b8ecc2937f4 100644 --- a/docs/src/templates/setup.ps1.mustache +++ b/docs/src/templates/setup.ps1.mustache @@ -161,13 +161,15 @@ if ($keyboard_type -eq "shield") { if ($($($boards_revisions.values)[$choice]).count -gt 0) { $valid_revisions = $($($boards_revisions.values)[$choice]) + $revision_choices = @() + $valid_revisions + for ($i = 0; $i -lt $valid_revisions.count; $i += 1) { if ($valid_revisions[$i] -eq $($($boards_default_revision.values)[$choice])) { - $valid_revisions[$i] += " (default)" + $revision_choices[$i] += " (default)" } } - $revision_choice = Get-Choice-From-Options -Options $valid_revisions -Prompt $prompt + $revision_choice = Get-Choice-From-Options -Options $revision_choices -Prompt $prompt $board = $board + "@" + $valid_revisions[$revision_choice] $boards = ( $board ) } From 4c020421c977a7e0492f0b1a67eff45a581622ca Mon Sep 17 00:00:00 2001 From: zhiayang Date: Sun, 10 Mar 2024 23:02:19 -0400 Subject: [PATCH 9/9] fix the same bug in the bash script --- docs/src/templates/setup.sh.mustache | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/src/templates/setup.sh.mustache b/docs/src/templates/setup.sh.mustache index b19c96cbc35..dd7a7a2d2f2 100644 --- a/docs/src/templates/setup.sh.mustache +++ b/docs/src/templates/setup.sh.mustache @@ -157,15 +157,17 @@ if [ "$keyboard_shield" == "y" ]; then if [ -n "${boards_revisions[$board_index]}" ]; then read -a _valid_revisions <<< "${boards_revisions[$board_index]}" + + _rev_choices=("${_valid_revisions[@]}") for (( _i=0; _i<${#_valid_revisions}; _i++ )); do if [ "${boards_default_revision[board_index]}" = "${_valid_revisions[_i]}" ]; then - _valid_revisions[_i]+=" (default)" + _rev_choices[_i]+=" (default)" fi done echo "" echo "MCU Board Revision:" - select opt in "${_valid_revisions[@]}" "Quit"; do + select opt in "${_rev_choices[@]}" "Quit"; do case "$REPLY" in ''|*[!0-9]*) echo "Invalid option. Try another one."; continue;;