Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add yaml_build_options target #10533

Merged
merged 2 commits into from
Aug 5, 2021
Merged

Conversation

mtei
Copy link
Contributor

@mtei mtei commented Oct 4, 2020

Description

Added yaml_build_options to the make target. It outputs the same information as show_all_features in a machine-readable format (YAML format).

It was inspired by the #10420.

Example of usage:

First collect all keymap information for all keyboards.
(This takes time. On my MacBook Pro, it took 20 minutes)

make all:all:yaml_build_options > /tmp/allkeyboard.yaml

Have two simple scripts like the one below.
(I'm not familiar with python, so I'll give an example with ruby for the time being.)

  • ruby script kb_select.rb

    require 'yaml'
    
    KEY = ARGV[0]
    VAL = ARGV[1]
    
    # Read YAML data and omit lines other than YAML format.
    strdata = $stdin.readlines.map {|line| /^[- ][ ]*[a-zA-Z_]+[ ]*: / =~ line ? line : "#" }.join("\n")
    arraydata = YAML.load(strdata)
    
    selectdata = arraydata.select{ |kb| kb[KEY] == VAL }
    
    YAML.dump(selectdata, $stdout)
  • ruby script kb_build_command.rb

    require 'yaml'
    
    # Read YAML data and omit lines other than YAML format.
    strdata = $stdin.readlines.map {|line| /^[- ][ ]*[a-zA-Z_]+[ ]*: / =~ line ? line : "#" }.join("\n")
    arraydata = YAML.load(strdata)
    
    arraydata.each { |kb|
        puts("make #{kb["KEYBOARD"]}:#{kb["KEYMAP"]}") 
    }

Find out what MCU is used as follows.

$ grep MCU /tmp/allkeyboard.yaml | sort | uniq
  MCU : "at90usb1286"
  MCU : "at90usb646"
  MCU : "atmega16u2"
  MCU : "atmega328p"
  MCU : "atmega32a"
  MCU : "atmega32u2"
  MCU : "atmega32u4"
  MCU : "attiny85"
  MCU : "cortex-m0"
  MCU : "cortex-m0plus"
  MCU : "cortex-m3"
  MCU : "cortex-m4"
  MCU_SERIES : ""
  MCU_SERIES : "K20x"
  MCU_SERIES : "KL2x"
  MCU_SERIES : "STM32F0xx"
  MCU_SERIES : "STM32F1xx"
  MCU_SERIES : "STM32F3xx"
  MCU_SERIES : "STM32F4xx"

To find a keyboard using STM32F4xx and count only the default keymap:

$ ruby util/kb_select.rb KEYMAP default < /tmp/allkeyboard.yaml| ruby util/kb_select.rb MCU_SERIES STM32F4xx | ruby util/kb_build_command.rb | wc
      9      18     290

To find a keyboard using STM32F4xx and build only the default keymap, do the following:

$ ruby util/kb_select.rb KEYMAP default < /tmp/allkeyboard.yaml| ruby util/kb_select.rb MCU_SERIES STM32F4xx | ruby util/kb_build_command.rb > /tmp/kbcmd.sh
$ cat /tmp/kbcmd.sh
make handwired/onekey/blackpill_f401:default
make handwired/onekey/blackpill_f411:default
make handwired/riblee_f401:default
make matrix/m20add:default
make matrix/noah:default
make phoenix:default
make tkw/stoutgat/v2/f411:default
make zvecr/zv48/f401:default
make zvecr/zv48/f411:default
$ sh -x /tmp/kbcmd.sh

You can also select a keymap that uses a particular DEBOUNCE_TYPE in a similar way.

$ grep DEBOUNCE_TYPE /tmp/allkeyboard.yaml| sort |uniq
  DEBOUNCE_TYPE : "custom"
  DEBOUNCE_TYPE : "sym_defer_g"
  DEBOUNCE_TYPE : "sym_eager_pk"
  DEBOUNCE_TYPE : "sym_eager_pr"
$ ruby util/kb_select.rb DEBOUNCE_TYPE sym_eager_pk < /tmp/allkeyboard.yaml | ruby util/kb_build_command.rb > /tmp/kbcmd.sh
$ wc kbcmd.sh
       9      18     318

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@mtei mtei added the core label Oct 4, 2020
@mtei mtei requested review from tzarc and a team October 4, 2020 13:30
@mtei mtei changed the base branch from master to develop October 5, 2020 12:55
@mtei mtei marked this pull request as ready for review October 25, 2020 08:10
@github-actions github-actions bot removed the core label Oct 25, 2020
@noroadsleft noroadsleft deleted the branch qmk:develop November 28, 2020 20:02
@tzarc tzarc reopened this Nov 28, 2020
@github-actions github-actions bot added the core label Nov 28, 2020
@stale
Copy link

stale bot commented Jan 15, 2021

Thank you for your contribution!
This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready.
For maintainers: Please label with awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@stale stale bot removed the awaiting changes label Jan 15, 2021
@tzarc tzarc closed this Feb 27, 2021
@tzarc tzarc deleted the branch qmk:develop February 27, 2021 20:27
@tzarc
Copy link
Member

tzarc commented Feb 27, 2021

Sorry about that, GitHub decided to delete the develop branch from upstream when we merged it, despite being told otherwise. Reopened.

@tzarc tzarc reopened this Feb 27, 2021
@tzarc tzarc merged commit 3396756 into qmk:develop Aug 5, 2021
@mtei mtei deleted the add_yaml_build_options branch August 27, 2021 12:22
nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
Co-authored-by: Nick Brassel <nick@tzarc.org>
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
Co-authored-by: Nick Brassel <nick@tzarc.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants