From 42ba4d71b6396894fe6ff6aeb2136b7ed869cfba Mon Sep 17 00:00:00 2001 From: Manna Harbour <51143715+manna-harbour@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:01:37 +1100 Subject: [PATCH] Add modules - Add modules workflow option - Add extra and tap as additional options - Move clipboard to additional options - Add outboard_modules to outboards - Replace zmk with outboard_branches in outboards --- .github/workflows/build-inputs.yml | 20 ++-- .github/workflows/main.yml | 110 +++++++++++++++---- .github/workflows/outboards/boards/adv360 | 2 +- .github/workflows/outboards/boards/tipper_tf | 2 +- .github/workflows/test-all-configs.yml | 24 ++++ .github/workflows/test-inputs.yml | 14 +-- .github/workflows/zmk | 4 - readme.org | 41 +++++-- 8 files changed, 161 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/zmk diff --git a/.github/workflows/build-inputs.yml b/.github/workflows/build-inputs.yml index 57c3eb8..c62fe1f 100644 --- a/.github/workflows/build-inputs.yml +++ b/.github/workflows/build-inputs.yml @@ -37,16 +37,6 @@ on: - "default" - "invertedT" - "vi" - clipboard: - description: 'clipboard' - required: false - default: 'default' - type: choice - options: - - "default" - - "fun" - - "Mac" - - "Win" layers: description: 'layers' required: false @@ -71,6 +61,10 @@ on: description: 'branches' required: false default: 'default' + modules: + description: 'modules' + required: false + default: 'default' jobs: process-inputs: runs-on: ubuntu-latest @@ -79,12 +73,12 @@ jobs: shield: ${{ steps.process-inputs.outputs.shield }} alphas: ${{ steps.process-inputs.outputs.alphas }} nav: ${{ steps.process-inputs.outputs.nav }} - clipboard: ${{ steps.process-inputs.outputs.clipboard }} layers: ${{ steps.process-inputs.outputs.layers }} mapping: ${{ steps.process-inputs.outputs.mapping }} custom_config: ${{ steps.process-inputs.outputs.custom_config }} kconfig: ${{ steps.process-inputs.outputs.kconfig }} branches: ${{ steps.process-inputs.outputs.branches }} + modules: ${{ steps.process-inputs.outputs.modules }} steps: - name: Process inputs id: process-inputs @@ -98,12 +92,12 @@ jobs: set-output "shield" "${{ github.event.inputs.shield }}" set-output "alphas" "${{ github.event.inputs.alphas }}" set-output "nav" "${{ github.event.inputs.nav }}" - set-output "clipboard" "${{ github.event.inputs.clipboard }}" set-output "layers" "${{ github.event.inputs.layers }}" set-output "mapping" "${{ github.event.inputs.mapping }}" set-output "custom_config" "${{ github.event.inputs.custom_config }}" set-output "kconfig" "${{ github.event.inputs.kconfig }}" set-output "branches" "${{ github.event.inputs.branches }}" + set-output "modules" "${{ github.event.inputs.modules }}" build: uses: ./.github/workflows/main.yml secrets: inherit @@ -113,9 +107,9 @@ jobs: shield: ${{ needs.process-inputs.outputs.shield }} alphas: ${{ needs.process-inputs.outputs.alphas }} nav: ${{ needs.process-inputs.outputs.nav }} - clipboard: ${{ needs.process-inputs.outputs.clipboard }} layers: ${{ needs.process-inputs.outputs.layers }} mapping: ${{ needs.process-inputs.outputs.mapping }} custom_config: ${{ needs.process-inputs.outputs.custom_config }} kconfig: ${{ needs.process-inputs.outputs.kconfig }} branches: ${{ needs.process-inputs.outputs.branches }} + modules: ${{ needs.process-inputs.outputs.modules }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 53e1060..960b877 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,12 @@ on: alphas: type: string default: '["default"]' + extra: + type: string + default: '["default"]' + tap: + type: string + default: '["default"]' nav: type: string default: '["default"]' @@ -35,6 +41,10 @@ on: branches: type: string default: '["default"]' + modules: + type: string + default: '["default"]' + jobs: main: @@ -47,6 +57,8 @@ jobs: board: ${{ fromJSON(inputs.board) }} shield: ${{ fromJSON(inputs.shield) }} alphas: ${{ fromJSON(inputs.alphas) }} + extra: ${{ fromJSON(inputs.extra) }} + tap: ${{ fromJSON(inputs.tap) }} nav: ${{ fromJSON(inputs.nav) }} clipboard: ${{ fromJSON(inputs.clipboard) }} layers: ${{ fromJSON(inputs.layers) }} @@ -54,6 +66,7 @@ jobs: custom_config: ${{ fromJSON(inputs.custom_config) }} kconfig: ${{ fromJSON(inputs.kconfig) }} branches: ${{ fromJSON(inputs.branches) }} + modules: ${{ fromJSON(inputs.modules) }} env: MIRYOKU_DEBUG: ${{ secrets.MIRYOKU_DEBUG }} steps: @@ -104,7 +117,7 @@ jobs: artifact_build_name="$artifact_build_name config_"`echo "${{ matrix.custom_config }}" | md5sum | head -c "$hash_length"` fi - for option in "alphas_${{ matrix.alphas }}" "nav_${{ matrix.nav }}" "clipboard_${{ matrix.clipboard }}" "layers_${{ matrix.layers }}" "mapping_${{ matrix.mapping }}" + for option in "alphas_${{ matrix.alphas }}" "extra_${{ matrix.extra }}" "tap_${{ matrix.tap }}" "nav_${{ matrix.nav }}" "clipboard_${{ matrix.clipboard }}" "layers_${{ matrix.layers }}" "mapping_${{ matrix.mapping }}" do case "$option" in *_ ) ;; @@ -130,7 +143,21 @@ jobs: fi test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' && test -f "$kconfig_file" && cp "$kconfig_file" "$artifact_dir" - . "${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/zmk" + if [ -n "${{ matrix.branches }}" -a "${{ matrix.branches }}" != 'default' ] + then + artifact_build_name="$artifact_build_name branches_"`echo "${{ matrix.branches }}" | md5sum | head -c "$hash_length"` + branches="${{ matrix.branches }}" + fi + if [ -n "${{ matrix.modules }}" -a "${{ matrix.modules }}" != 'default' ] + then + artifact_build_name="$artifact_build_name modules_"`echo "${{ matrix.modules }}" | md5sum | head -c "$hash_length"` + modules="${{ matrix.modules }}" + fi + + artifact_build_name=`echo $artifact_build_name | tr ' ' '-'` + echo "artifact_build_name=$artifact_build_name" >> $GITHUB_OUTPUT + artifact_generic_name=`echo "$artifact_build_name" | sed 's/_\(left\|right\)//'` + echo "artifact_generic_name=$artifact_generic_name" >> $GITHUB_OUTPUT echo "::endgroup::" @@ -143,47 +170,57 @@ jobs: fi for outboard in $outboards do + outboard_repository='' + outboard_ref='' + outboard_from='' + outboard_to='' + outboard_branches='' + outboard_modules='' outboard_file="${GITHUB_WORKSPACE}/miryoku_zmk/.github/workflows/outboards/$outboard" if [ -f "$outboard_file" ] then test "$MIRYOKU_DEBUG" = 'MIRYOKU_DEBUG_TRUE' && cp "$outboard_file" "$artifact_dir" . "$outboard_file" - outboard_dir="${GITHUB_WORKSPACE}/outboards/$outboard" - if [ -n "$outboard_repository" -a -n "$outboard_ref" ] + outboard_dir="${GITHUB_WORKSPACE}/$outboard" + if [ -n "$outboard_repository" -a -n "$outboard_ref" -a -n "$outboard_from" -a -n "$outboard_to" ] then if ! echo "$outboard_repository" | grep -q 'https:\/\/' then outboard_repository="https://github.com/$outboard_repository.git" fi git clone -b "$outboard_ref" --depth 1 "$outboard_repository" "$outboard_dir" - if [ -n "$outboard_from" -a -n "$outboard_to" ] + to="${GITHUB_WORKSPACE}/miryoku_zmk/config/$outboard_to" + mkdir -p `dirname "$to"` + ln -sr "$outboard_dir/$outboard_from" "$to" + fi + if [ -n "$outboard_branches" ] + then + if [ -n "$branches" ] then - to="${GITHUB_WORKSPACE}/miryoku_zmk/config/$outboard_to" - mkdir -p `dirname "$to"` - ln -sr "$outboard_dir/$outboard_from" "$to" + branches="$braches $outboard_branches" + else + branches="$outboard_branches" + fi + fi + if [ -n "$outboard_modules" ] + then + if [ -n "$modules" ] + then + modules="$modules $outboard_modules" + else + modules="$outboard_modules" fi fi - outboard_repository='' - outboard_ref='' - outboard_from='' - outboard_to='' fi done echo "::endgroup::" echo "::group::zmk" - if [ -n "${{ matrix.branches }}" -a "${{ matrix.branches }}" != 'default' ] + zmk=`echo "$branches" | cut -d ' ' -f 1` + if [ -z "$zmk" ] then - artifact_build_name="$artifact_build_name branches_"`echo "${{ matrix.branches }}" | md5sum | head -c "$hash_length"` - zmk=`echo "${{ matrix.branches }}" | cut -d ' ' -f 1` - merges=`echo "${{ matrix.branches }}" | cut -d ' ' -f 2- -s` + zmk='zmkfirmware/zmk/main' fi - - artifact_build_name=`echo $artifact_build_name | tr ' ' '-'` - echo "artifact_build_name=$artifact_build_name" >> $GITHUB_OUTPUT - artifact_generic_name=`echo "$artifact_build_name" | sed 's/_\(left\|right\)//'` - echo "artifact_generic_name=$artifact_generic_name" >> $GITHUB_OUTPUT - user=`echo "$zmk" | cut -f 1 -d '/'` repo=`echo "$zmk" | cut -f 2 -d '/'` branch=`echo "$zmk" | cut -f 3- -d '/'` @@ -191,6 +228,7 @@ jobs: echo "::endgroup::" echo "::group::merge" + merges=`echo "$branches" | cut -d ' ' -f 2- -s` if [ -n "$merges" ] then cd "${GITHUB_WORKSPACE}/zmk" @@ -211,6 +249,32 @@ jobs: done fi echo "::endgroup::" + + echo "::group::modules" + + for module in $modules + do + user=`echo "$module" | cut -f 1 -d '/'` + repo=`echo "$module" | cut -f 2 -d '/'` + branch=`echo "$module" | cut -f 3- -d '/'` + module_dir="${GITHUB_WORKSPACE}/modules/$user-$repo-"`echo "$branch" | tr '/' '_'` + if [ ! -d "$module_dir" ] + then + git clone -b "$branch" --depth 1 "https://github.com/$user/$repo.git" "$module_dir" + if [ -z "$module_dirs" ] + then + module_dirs="$module_dir;" + else + module_dirs="$module_dirs;$module_dir;" + fi + fi + done + if [ -n "$module_dirs" ] + then + modules_arg="-DZMK_EXTRA_MODULES=\"$module_dirs\"" + echo "modules_arg=${modules_arg}" >> $GITHUB_OUTPUT + fi + echo "::endgroup::" - name: cache if: true uses: actions/cache@v3 @@ -244,7 +308,7 @@ jobs: EX_DATAERR='65' cd "${GITHUB_WORKSPACE}/zmk/app" { - west $west_debug build -b ${{ matrix.board }} $west_build_debug -- ${{ steps.main.outputs.shield_arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/miryoku_zmk/config" || + west $west_debug build -b ${{ matrix.board }} $west_build_debug -- ${{ steps.main.outputs.shield_arg }} ${{ steps.main.outputs.modules_arg }} -DZMK_CONFIG="${GITHUB_WORKSPACE}/miryoku_zmk/config" || echo "$build_failed_message $?." ; } 2>&1 | tee "$log" if grep -q 'Invalid BOARD; see above.' "$log" diff --git a/.github/workflows/outboards/boards/adv360 b/.github/workflows/outboards/boards/adv360 index c5d9d31..d9d31d1 100644 --- a/.github/workflows/outboards/boards/adv360 +++ b/.github/workflows/outboards/boards/adv360 @@ -5,4 +5,4 @@ outboard_repository=KinesisCorporation/Adv360-Pro-ZMK outboard_ref=V2.0 outboard_from=config/boards/arm/adv360 outboard_to=boards/arm/adv360 -zmk=refil/zmk/adv360-z3 +outboard_branches=refil/zmk/adv360-z3 diff --git a/.github/workflows/outboards/boards/tipper_tf b/.github/workflows/outboards/boards/tipper_tf index aa44499..ec0170a 100644 --- a/.github/workflows/outboards/boards/tipper_tf +++ b/.github/workflows/outboards/boards/tipper_tf @@ -5,4 +5,4 @@ outboard_repository=weteor/Tipper_TF-Config outboard_ref=master outboard_from=boards/arm/tipper_tf outboard_to=boards/arm/tipper_tf -zmk=weteor/zmk/Tipper_TF_rev2 +outboard_branches=weteor/zmk/Tipper_TF_rev2 diff --git a/.github/workflows/test-all-configs.yml b/.github/workflows/test-all-configs.yml index a7b68ab..7fccd8c 100644 --- a/.github/workflows/test-all-configs.yml +++ b/.github/workflows/test-all-configs.yml @@ -23,6 +23,30 @@ jobs: "qwertz", "workman" ]' + extra: '[ + "default", + "azerty", + "beakl15", + "colemak", + "colemakdhk", + "dvorak", + "halmak", + "qwerty", + "qwertz", + "workman" + ]' + tap: '[ + "default", + "azerty", + "beakl15", + "colemak", + "colemakdhk", + "dvorak", + "halmak", + "qwerty", + "qwertz", + "workman" + ]' nav: '[ "default", "invertedt", diff --git a/.github/workflows/test-inputs.yml b/.github/workflows/test-inputs.yml index d220d11..629dd10 100644 --- a/.github/workflows/test-inputs.yml +++ b/.github/workflows/test-inputs.yml @@ -20,10 +20,6 @@ on: description: 'nav' required: false default: 'default' - clipboard: - description: 'clipboard' - required: false - default: 'default' layers: description: 'layers' required: false @@ -44,6 +40,10 @@ on: description: 'branches' required: false default: 'default' + modules: + description: 'modules' + required: false + default: 'default' jobs: process-inputs: runs-on: ubuntu-latest @@ -52,12 +52,12 @@ jobs: shield: ${{ steps.process-inputs.outputs.shield }} alphas: ${{ steps.process-inputs.outputs.alphas }} nav: ${{ steps.process-inputs.outputs.nav }} - clipboard: ${{ steps.process-inputs.outputs.clipboard }} layers: ${{ steps.process-inputs.outputs.layers }} mapping: ${{ steps.process-inputs.outputs.mapping }} custom_config: ${{ steps.process-inputs.outputs.custom_config }} kconfig: ${{ steps.process-inputs.outputs.kconfig }} branches: ${{ steps.process-inputs.outputs.branches }} + modules: ${{ steps.process-inputs.outputs.modules }} steps: - name: Process inputs id: process-inputs @@ -71,12 +71,12 @@ jobs: set-output "shield" "${{ github.event.inputs.shield }}" set-output "alphas" "${{ github.event.inputs.alphas }}" set-output "nav" "${{ github.event.inputs.nav }}" - set-output "clipboard" "${{ github.event.inputs.clipboard }}" set-output "layers" "${{ github.event.inputs.layers }}" set-output "mapping" "${{ github.event.inputs.mapping }}" set-output "custom_config" "${{ github.event.inputs.custom_config }}" set-output "kconfig" "${{ github.event.inputs.kconfig }}" set-output "branches" "${{ github.event.inputs.branches }}" + set-output "modules" "${{ github.event.inputs.modules }}" build: uses: ./.github/workflows/main.yml secrets: inherit @@ -86,9 +86,9 @@ jobs: shield: ${{ needs.process-inputs.outputs.shield }} alphas: ${{ needs.process-inputs.outputs.alphas }} nav: ${{ needs.process-inputs.outputs.nav }} - clipboard: ${{ needs.process-inputs.outputs.clipboard }} layers: ${{ needs.process-inputs.outputs.layers }} mapping: ${{ needs.process-inputs.outputs.mapping }} custom_config: ${{ needs.process-inputs.outputs.custom_config }} kconfig: ${{ needs.process-inputs.outputs.kconfig }} branches: ${{ needs.process-inputs.outputs.branches }} + modules: ${{ needs.process-inputs.outputs.modules }} diff --git a/.github/workflows/zmk b/.github/workflows/zmk deleted file mode 100644 index c4d8765..0000000 --- a/.github/workflows/zmk +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright 2022 Manna Harbour -# https://github.com/manna-harbour/miryoku - -zmk=zmkfirmware/zmk/main diff --git a/readme.org b/readme.org index aa34bb3..a207a6e 100644 --- a/readme.org +++ b/readme.org @@ -120,7 +120,7 @@ Also use to specify optional non-keyboard shields, e.g. ~nice_view~. To combine ***** Miryoku Alternative Layout and Mapping Options -The ~alphas~, ~nav~, ~clipboard~, and ~layers~ options correspond to the Miryoku alternative layout options. See the [[https://github.com/manna-harbour/miryoku/tree/master/docs/reference#layers][default layers]] and [[https://github.com/manna-harbour/miryoku/tree/master/docs/reference#alternative-layouts][alternative layouts]] documentation for details. See the [[.github/workflows/test-all-configs.yml][Test All Configs]] workflow file for a list of all supported values. +The ~alphas~, ~extra~, ~tap~, ~nav~, ~clipboard~, and ~layers~ options correspond to the Miryoku alternative layout options. See the [[https://github.com/manna-harbour/miryoku/tree/master/docs/reference#layers][default layers]] and [[https://github.com/manna-harbour/miryoku/tree/master/docs/reference#alternative-layouts][alternative layouts]] documentation for details. See the [[.github/workflows/test-all-configs.yml][Test All Configs]] workflow file for a list of all supported values. The ~mapping~ option corresponds to the alternative [[#mapping-macros][mapping]] options. @@ -137,11 +137,6 @@ Select an alternative alphas layout, e.g. ~colemak~, ~dvorak~, ~halmak~, ~qwerty Select an alternative Nav layout, e.g. ~invertedt~, ~vi~. For home position line nav, leave as ~default~. -****** clipboard - -Select an alternative clipboard type, e.g. ~mac~, ~win~. For CUA bindings, leave as ~default~. - - ****** layers Select an alternative layers layout, e.g. ~flip~. For right hand Nav, leave as ~default~. @@ -154,7 +149,27 @@ Select an alternative mapping, e.g. ~extended_thumbs~, ~pinkie_stagger~. For th ***** custom_config -Appends to the [[#config-file][config]] file, e.g. ~#define MIRYOKU_TAP_QWERTY~. Join multiple lines with ~\n~, e.g. ~#define MIRYOKU_TAP_QWERTY\n#define MIRYOKU_EXTRA_COLEMAKDH~. For no additional config, leave as ~default~. +Appends to the [[#config-file][config]] file, e.g. ~#define MIRYOKU_CLIPBOARD_WIN~. Join multiple lines with ~\n~, e.g. ~#define MIRYOKU_EXTRA_DVORAK\n#define MIRYOKU_TAP_QWERTY\n#define MIRYOKU_CLIPBOARD_WIN~. For no additional config, leave as ~default~. + + +***** Additional Options + +These options are not available in the [[#build-inputs][Build Inputs]] workflow due to platform limitations. Use the [[#custom_config][custom_config]] option instead. + + +****** extra + +Select an alternative alphas layout for the Extra layer, e.g. ~colemak~, ~dvorak~, ~halmak~, ~qwerty~. For QWERTY, leave as ~default~. + + +****** tap + +Select an alternative alphas layout for the Tap layer, e.g. ~colemak~, ~dvorak~, ~halmak~, ~qwerty~. For Colemak Mod-DH, leave as ~default~. + + +****** clipboard + +Select an alternative clipboard type, e.g. ~mac~, ~win~. For CUA bindings, leave as ~default~. ***** ZMK Options @@ -176,6 +191,18 @@ Multiple space separated branches can be specified. The first branch specified For no changes, leave as ~default~. +***** modules + +Used to build with external modlues. + +Modules are specified in the form ~//~. + +Multiple space separated modules can be specified. + +For no changes, leave as ~default~. + + + ** Supported Keyboards In-tree keyboards are maintained as part of ZMK. See the [[https://zmk.dev/docs/hardware/][ZMK Supported Hardware]] documentation for details.