diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2023-12-17 13:56:03 +0100 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2023-12-17 13:56:03 +0100 |
commit | 23290f9f425fd7645513f25940a6cb8047d9cf09 (patch) | |
tree | 72ecb8ae0f8944336ca8229b640bdf74f90c606c | |
parent | b868d243cf0a038095f6622dfd509ea9c3167b50 (diff) | |
download | zmk-config-23290f9f425fd7645513f25940a6cb8047d9cf09.tar.gz zmk-config-23290f9f425fd7645513f25940a6cb8047d9cf09.zip |
Fix build script to work for shields
-rwxr-xr-x | bin/build.sh | 59 | ||||
-rw-r--r-- | config/bt60_v2.keymap | 4 | ||||
-rw-r--r-- | config/corne.keymap | 18 |
3 files changed, 55 insertions, 26 deletions
diff --git a/bin/build.sh b/bin/build.sh index b0314d8..04a671c 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -1,6 +1,17 @@ #!/usr/bin/env bash # Pulled from https://github.com/urob/zmk-config/, with some minor modifications +if ! command -v yq &> /dev/null; then + echo "Did not find 'yq', it is required for this script to function." + exit 1 +fi + +if ! command -v jq &> /dev/null; then + echo "Did not find 'jq', it is required for this script to function." + exit 1 +fi + + # Parse input arguments while [[ $# -gt 0 ]]; do case $1 in @@ -20,8 +31,13 @@ while [[ $# -gt 0 ]]; do # comma or space separated list of boards (use quotes if space separated) # if ommitted, will compile list of boards in build.yaml -b|--board) - BOARDS="$2" shift + IFS=',' read -ra BOARDS <<< "$1" + ;; + + -s|--shield) + shift + IFS=',' read -ra SHIELDS <<< "$1" ;; -v|--version) @@ -85,13 +101,24 @@ done [[ -z $DOCKER_ZMK_DIR ]] && DOCKER_ZMK_DIR="/workspace/zmk" [[ -z $DOCKER_CONFIG_DIR ]] && DOCKER_CONFIG_DIR="/workspace/zmk-config" -[[ -z $BOARDS ]] && BOARDS="$(grep '^[[:space:]]*\-[[:space:]]*board:' $HOST_CONFIG_DIR/build.yaml | sed 's/^.*: *//')" - [[ -z $CLEAR_CACHE ]] && CLEAR_CACHE="false" DOCKER_IMG="zmkfirmware/zmk-dev-arm:$ZEPHYR_VERSION" DOCKER_BIN="docker" +query=".include[]" +if [ ${#BOARDS[@]} -gt 0 ]; then + board_filters=$(printf "\"%s\"," "${BOARDS[@]}") + board_filters=${board_filters%,} # Remove the trailing comma + query+=" | select(.board | IN($board_filters))" +fi +if [ ${#SHIELDS[@]} -gt 0 ]; then + shield_filters=$(printf "\"%s\"," "${SHIELDS[@]}") + shield_filters=${shield_filters%,} # Remove the trailing comma + query+=" | select(.shield? | IN($shield_filters))" +fi +to_build=$(yq -e "$query" "$HOST_CONFIG_DIR/build.yaml") + # +--------------------+ # | BUILD THE FIRMWARE | # +--------------------+ @@ -128,12 +155,16 @@ CONFIG_DIR="$DOCKER_CONFIG_DIR/config" # usage: compile_board board compile_board () { - BUILD_DIR="${1}_$SUFFIX" - LOGFILE="$LOG_DIR/zmk_build_$1.log" + board=$(echo "$1" | jq -r '.board') + shield=$(echo "$1" | jq -r '.shield // ""') + [[ -z $shield ]] && shield="" || shield="-DSHIELD=${shield}" + + BUILD_DIR="${board}_${shield}_$SUFFIX" + LOGFILE="$LOG_DIR/zmk_build_$board_$shield.log" [[ $MULTITHREAD = "true" ]] || echo -en "\n$(tput setaf 2)Building $1... $(tput sgr0)" [[ $MULTITHREAD = "true" ]] && echo -e "$(tput setaf 2)Building $1... $(tput sgr0)" - $DOCKER_PREFIX west build -d "build/$BUILD_DIR" -b $1 $WEST_OPTS \ - -- -DZMK_CONFIG="$CONFIG_DIR" -Wno-dev > "$LOGFILE" 2>&1 + $DOCKER_PREFIX west build -d "build/$BUILD_DIR" -b $board $WEST_OPTS \ + -- -DZMK_CONFIG="$CONFIG_DIR" $shield -Wno-dev > "$LOGFILE" 2>&1 if [[ $? -eq 0 ]] then [[ $MULTITHREAD = "true" ]] || echo "$(tput setaf 2)done$(tput sgr0)" @@ -144,7 +175,7 @@ compile_board () { else TYPE="bin" fi - OUTPUT="$OUTPUT_DIR/$1-zmk.$TYPE" + OUTPUT="$OUTPUT_DIR/$board-$shield-zmk.$TYPE" [[ -f $OUTPUT ]] && [[ ! -L $OUTPUT ]] && mv "$OUTPUT" "$OUTPUT.bak" cp "$HOST_ZMK_DIR/app/build/$BUILD_DIR/zephyr/zmk.$TYPE" "$OUTPUT" else @@ -157,11 +188,10 @@ compile_board () { cd "$HOST_ZMK_DIR/app" if [[ $MULTITHREAD = "true" ]]; then i=1 - for board in $(echo $BOARDS | sed 's/,/ /g') - do - compile_board $board & + echo "$to_build" | jq -c '.' | while read -r line; do + compile_board $line & eval "T${i}=\${!}" - eval "B${i}=\$board" # Store the board name in a corresponding variable + eval "B${i}=\$line" # Store the board name in a corresponding variable ((i++)) done @@ -174,8 +204,7 @@ if [[ $MULTITHREAD = "true" ]]; then echo -e "$(tput setaf 3)Thread $x with PID ${!pid} has finished: ${!board}$(tput sgr0)" done else - for board in $(echo $BOARDS | sed 's/,/ /g') - do - compile_board $board + echo "$to_build" | jq -c '.' | while read -r line; do + compile_board $line done fi diff --git a/config/bt60_v2.keymap b/config/bt60_v2.keymap index 23f5e4f..f7e079d 100644 --- a/config/bt60_v2.keymap +++ b/config/bt60_v2.keymap @@ -127,8 +127,8 @@ COMBO(mwn_ao_comb, 54 25, MAC_U, &mwn_no_ao) gaming { bindings = < &kp ESC ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ - ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ - &kp LCTRL ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + ___ ___ &kp W ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + &kp LCTRL &kp A &kp S &kp D &kp F ___ ___ &kp J &kp K &kp L &kp SEMI ___ ___ ___ &kp LSHIFT ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ &kp LCTRL ___ ___ ___ ___ ___ ___ ___ >; diff --git a/config/corne.keymap b/config/corne.keymap index 1d36509..fc2175d 100644 --- a/config/corne.keymap +++ b/config/corne.keymap @@ -17,13 +17,13 @@ // | TAB | Q | W | E | R | T | | Y | U | I | O | P | BKSP | // | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | // | SHFT | Z | X | C | V | B | | N | M | , | . | / | ESC | -// | GUI | LWR | SPC | | ENT | RSE | ALT | +// | SHFT| LWR | ENT | | SPC | RSE | ALT | label = "Base"; bindings = < - &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC - &kp LCTRL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT - &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp ESC - &kp LGUI &mo 1 &kp SPACE &kp RET &mo 2 &kp RALT + &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC + &mt LCTRL ESC &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT + &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp ESC + &kp LSHIFT &mo 2 &kp RET &kp SPACE &mo 1 &kp RALT >; }; lower_layer { @@ -31,13 +31,13 @@ // | TAB | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | // | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | | // | SHFT | | | | | | | | | | | | | -// | GUI | | SPC | | ENT | | ALT | +// | SHFT| | ENT | | SPC | | ALT | label = "Lower"; bindings = < &kp TAB &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp BSPC &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LEFT &kp DOWN &kp UP &kp RIGHT &trans &trans &kp LSHFT &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans - &kp LGUI &trans &kp SPACE &kp RET &trans &kp RALT + &kp LSHFT &trans &kp RET &kp SPACE &trans &kp RALT >; }; @@ -46,13 +46,13 @@ // | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP | // | CTRL | | | | | | | - | = | [ | ] | \ | ` | // | SHFT | | | | | | | _ | + | { | } | "|" | ~ | -// | GUI | | SPC | | ENT | | ALT | +// | GUI | | ENT | | SPC | | ALT | label = "Raise"; bindings = < &kp TAB &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp KP_MULTIPLY &kp LPAR &kp RPAR &kp BSPC &kp LCTRL &trans &trans &trans &trans &trans &kp MINUS &kp EQUAL &kp LBKT &kp RBKT &kp BSLH &kp GRAVE &kp LSHFT &trans &trans &trans &trans &trans &kp UNDER &kp PLUS &kp LBRC &kp RBRC &kp PIPE &kp TILDE - &kp LGUI &trans &kp SPACE &kp RET &trans &kp RALT + &kp LGUI &trans &kp RET &kp SPACE &trans &kp RALT >; }; }; |