summaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authortmas <tmas@tgaragemedia.com>2022-01-23 06:13:26 -0500
committerGitHub <noreply@github.com>2022-01-23 13:13:26 +0200
commit57fa544822e830933dcc4d23024522b0e8ace9be (patch)
treec37d920b70ad08f7ede831a6185c6bf044493d1a /lib/python
parent40aff498a21a18d17f6ae7032abad87fa8d51cb2 (diff)
[CI] Add quick build workflow, add whitelist/blacklist support in build_all.py (#206)
* Add argparse, add arguments for whitelist, blacklist, and debug mode * When in debug mode, print a message * Parse whitelist/blacklist, output filenames and contents if debug enabled * Add should_include function to determine if a line should be included, apply whitelist/blacklist if enabled * Add quick build workflow and empty file to hold quickbuild list * Use blacklist for quick build * Remove unnecessary parentheses * Use lowercase filename * Whitelist is probably better than blacklist for quick build * Add common testing keyboards to whitelist * Fix indents * Still had some messed up indents! * More formatting fixes * Change delimiters to semicolon to hopefully appease the py linter * Delimiter is semicolon, no need to escape slash * Update build_all.py Co-authored-by: dexter93 <d3xter93@gmail.com>
Diffstat (limited to 'lib/python')
-rwxr-xr-xlib/python/build_all.py76
1 files changed, 65 insertions, 11 deletions
diff --git a/lib/python/build_all.py b/lib/python/build_all.py
index 652ff2994..df4592e2d 100755
--- a/lib/python/build_all.py
+++ b/lib/python/build_all.py
@@ -2,27 +2,81 @@ import subprocess
import os
import sys
import re
+import argparse
+
+# Parse arguments
+parser = argparse.ArgumentParser(description="Build QMK for Sonix keyboards")
+parser.add_argument("--whitelist", help="enables the whitelist (specify a filename)")
+parser.add_argument("--blacklist", help="enables the blacklist (specify a filename)")
+parser.add_argument("--debug", help="displays which keyboards are being excluded based on whitelist/blacklist", action="store_true")
+args = parser.parse_args()
+
KEYBOARDS = []
# Search the repository for Sonix SN32F2 keyboard directories
-command = "grep -rl 'MCU = SN32F2' | sed -e 's/keyboards\///g' -e 's/\/rules.mk//g'| sort"
+command = "grep -rl 'MCU = SN32F2' | sed -e 's;keyboards/;;g' -e 's;/rules.mk;;g'| sort"
ret = subprocess.run(command, capture_output=True, shell=True)
BOARDS = ret.stdout.decode().split('\n')
+
+if args.debug:
+ print("using debug mode")
+
+if args.whitelist:
+ # Grab the list of whitelisted keyboards
+ whitelisted_kb_command = "cat " + args.whitelist + " | tr -d '\r'"
+ whitelisted_kb_ret = subprocess.run(whitelisted_kb_command, capture_output=True, shell=True)
+ WHITELISTED_BOARDS = whitelisted_kb_ret.stdout.decode().split('\n')
+ if args.debug:
+ print("using whitelist: ", args.whitelist)
+ print("whitelist contents: ", WHITELISTED_BOARDS)
+
+if args.blacklist:
+ # Grab the list of blacklisted keyboards
+ blacklisted_kb_command = "cat " + args.blacklist + " | tr -d '\r'"
+ blacklisted_kb_ret = subprocess.run(blacklisted_kb_command, capture_output=True, shell=True)
+ BLACKLISTED_BOARDS = blacklisted_kb_ret.stdout.decode().split('\n')
+ if args.debug:
+ print("using blacklist: ", args.blacklist)
+ print("blacklist contents: ", BLACKLISTED_BOARDS)
+
+
def main():
for line in BOARDS:
# We need to manipulate some non-standard directories
- if line.strip() != "" and line.strip() != "lib/python/build_all.py":
- if re.match("^(gmmk)",line.strip()):
- KEYBOARDS.append(line.strip()+"/rev2")
- KEYBOARDS.append(line.strip()+"/rev3")
- if re.match("^(keychron/k)",line.strip()):
+ if should_include(line):
+ if re.match("^(gmmk)", line.strip()):
+ KEYBOARDS.append(line.strip() + "/rev2")
+ KEYBOARDS.append(line.strip() + "/rev3")
+ if re.match("^(keychron/k)", line.strip()):
KEYBOARDS.append(line.strip())
# keychron K series white don't have yet via/optical support
- if re.match("(?!.*white)",line.strip()):
- KEYBOARDS.append(line.strip()+"/via")
- KEYBOARDS.append(line.strip()+"/optical")
- KEYBOARDS.append(line.strip()+"/optical_via")
- else: KEYBOARDS.append(line.strip())
+ if re.match("(?!.*white)", line.strip()):
+ KEYBOARDS.append(line.strip() + "/via")
+ KEYBOARDS.append(line.strip() + "/optical")
+ KEYBOARDS.append(line.strip() + "/optical_via")
+ else:
+ KEYBOARDS.append(line.strip())
+ if args.debug:
+ print('Filtered and processed boards: ', KEYBOARDS)
+
+
+def should_include(keyboard):
+ if keyboard.strip() == "":
+ return False
+ if keyboard.strip() == "lib/python/build_all.py":
+ return False
+ if args.blacklist:
+ if keyboard.strip() in BLACKLISTED_BOARDS:
+ if args.debug:
+ print("Skipping blacklisted keyboard: ", keyboard.strip())
+ return False
+ if args.whitelist:
+ if keyboard.strip() not in WHITELISTED_BOARDS:
+ if args.debug:
+ print("Skipping non-whitelisted keyboard: ", keyboard.strip())
+ return False
+ return True
+
if __name__ == '__main__':
main()