summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsommersoft <sommersoft@gmail.com>2019-07-04 01:18:16 -0500
committersommersoft <sommersoft@gmail.com>2019-07-04 01:18:16 -0500
commitf1256c0b35d8ff3e1893bd345a6ff29c2ee2e752 (patch)
treec0aa10a252ea604ff6221a2b937d5a68fe8665b9
parentf0a112ef5d04fc17a49ad8e2d74e5e23f3c40dd5 (diff)
add script to gather module support matrix info; add initial json file
-rw-r--r--docs/shared_bindings_matrix.py130
-rw-r--r--shared-bindings/support_matrix.json441
2 files changed, 571 insertions, 0 deletions
diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py
new file mode 100644
index 000000000..ebcadb7ad
--- /dev/null
+++ b/docs/shared_bindings_matrix.py
@@ -0,0 +1,130 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2019 Michael Schroeder
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+import json
+import os
+import re
+
+
+SUPPORTED_PORTS = ["atmel-samd", "nrf"]
+
+
+def get_shared_bindings():
+ """ Get a list of modules in shared-bindings based on folder names
+ """
+ return [item for item in os.listdir("./shared-bindings")]
+
+
+def read_mpconfig():
+ """ Open 'circuitpy_mpconfig.mk' and return the contents.
+ """
+ configs = []
+ with open("py/circuitpy_mpconfig.mk") as mpconfig:
+ configs = mpconfig.read()
+
+ return configs
+
+
+def build_json(modules, configs):
+ """ Establish the base of the JSON file, based on the contents from
+ `configs`. Base will contain module names, if they're part of
+ the `FULL_BUILD`, or their default value (0 | 1).
+
+ """
+ base_json = dict()
+ full_build = False
+ for module in modules:
+ full_name = module
+ search_name = module.lstrip("_")
+ re_pattern = "CIRCUITPY_{}\s=\s(.+)".format(search_name.upper())
+ find_config = re.search(re_pattern, configs)
+ #print(module, "|", find_config)
+ if not find_config:
+ continue
+ full_build = int("FULL_BUILD" in find_config[0])
+ #print(find_config[1])
+ if not full_build:
+ default_val = find_config[1]
+ else:
+ default_val = "None"
+ base_json[search_name] = {
+ "name": full_name,
+ "full_build": str(full_build),
+ "default_value": default_val,
+ "excluded": []
+ }
+
+ return get_excluded_boards(base_json)
+
+
+def get_excluded_boards(base_json):
+ """ Cycles through each board's `mpconfigboard.mk` file to determine
+ if each module is included or not. Boards are selected by existence
+ in a port listed in `SUPPORTED_PORTS` (e.g. `/port/nrf/feather_52840`)
+ """
+ modules = list(base_json.keys())
+ for port in SUPPORTED_PORTS:
+ port_dir = "ports/{}/boards".format(port)
+ with os.scandir(port_dir) as boards:
+ for entry in boards:
+ if not entry.is_dir():
+ continue
+ contents = ""
+ board_dir = os.path.join(entry.path, "mpconfigboard.mk")
+ #print(board_dir)
+ with open(board_dir) as board:
+ contents = board.read()
+ for module in modules:
+ # check if board uses `SMALL_BUILD`. if yes, and current
+ # module is marked as `FULL_BUILD`, board is excluded
+ small_build = re.search("CIRCUITPY_SMALL_BUILD = 1", contents)
+ if small_build and base_json[module]["full_build"] == "1":
+ base_json[module]["excluded"].append(entry.name)
+ continue
+
+ # check if module is specifically disabled for this board
+ re_pattern = "CIRCUITPY_{}\s=\s(\w)".format(module.upper())
+ find_module = re.search(re_pattern, contents)
+ if not find_module:
+ continue
+ if (find_module[1] == "0" and
+ find_module[1] != base_json[module]["default_value"]):
+ base_json[module]["excluded"].append(entry.name)
+
+ return base_json
+
+if __name__ == "__main__":
+ modules = get_shared_bindings()
+ configs = read_mpconfig()
+ base = build_json(sorted(modules), configs)
+
+ final_json = json.dumps(base, indent=2)
+
+ shared_bindings_json = 'support_matrix.json'
+ if 'TRAVIS' in os.environ:
+ shared_bindings_json = os.path.join('$HOME', shared_bindings_json)
+ else:
+ print(final_json)
+ shared_bindings_json = os.path.join('shared-bindings', shared_bindings_json)
+ with open(shared_bindings_json, "w") as matrix:
+ json.dump(base, matrix, indent=2)
diff --git a/shared-bindings/support_matrix.json b/shared-bindings/support_matrix.json
new file mode 100644
index 000000000..2d2a7d1ed
--- /dev/null
+++ b/shared-bindings/support_matrix.json
@@ -0,0 +1,441 @@
+{
+ "pew": {
+ "name": "_pew",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ },
+ "pixelbuf": {
+ "name": "_pixelbuf",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "circuitplayground_express_crickit",
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "ugame10",
+ "pewpew10",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "feather_m0_basic",
+ "gemma_m0",
+ "arduino_mkrzero",
+ "meowmeow",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "stage": {
+ "name": "_stage",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ },
+ "analogio": {
+ "name": "analogio",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "pirkey_m0"
+ ]
+ },
+ "audiobusio": {
+ "name": "audiobusio",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "kicksat-sprite",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "ugame10",
+ "pewpew10",
+ "mini_sam_m4",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "sparkfun_lumidrive",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "capablerobot_usbhub",
+ "feather_m0_basic",
+ "gemma_m0",
+ "hallowing_m0_express",
+ "arduino_mkrzero",
+ "trellis_m4_express",
+ "feather_radiofruit_zigbee",
+ "itsybitsy_m4_express",
+ "meowmeow",
+ "cp32-m4",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "audioio": {
+ "name": "audioio",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "pewpew10",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "sparkfun_lumidrive",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "feather_m0_basic",
+ "gemma_m0",
+ "arduino_mkrzero",
+ "feather_radiofruit_zigbee",
+ "meowmeow",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "bitbangio": {
+ "name": "bitbangio",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "pewpew10",
+ "feather_m0_express_crickit",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "feather_m0_basic",
+ "gemma_m0",
+ "arduino_mkrzero",
+ "meowmeow",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "bleio": {
+ "name": "bleio",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ },
+ "board": {
+ "name": "board",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "busio": {
+ "name": "busio",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "digitalio": {
+ "name": "digitalio",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "displayio": {
+ "name": "displayio",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "circuitplayground_express_crickit",
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "kicksat-sprite",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "circuitplayground_express",
+ "pewpew10",
+ "feather_m0_express_crickit",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "robohatmm1",
+ "feather_m0_basic",
+ "gemma_m0",
+ "arduino_mkrzero",
+ "meowmeow",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "frequencyio": {
+ "name": "frequencyio",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "circuitplayground_express_crickit",
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "ugame10",
+ "circuitplayground_express",
+ "pewpew10",
+ "feather_m0_express_crickit",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "robohatmm1",
+ "feather_m0_basic",
+ "gemma_m0",
+ "hallowing_m0_express",
+ "arduino_mkrzero",
+ "meowmeow",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "gamepad": {
+ "name": "gamepad",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "pewpew10",
+ "feather_m0_express_crickit",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "feather_m0_basic",
+ "gemma_m0",
+ "arduino_mkrzero",
+ "meowmeow",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "gamepadshift": {
+ "name": "gamepadshift",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ },
+ "i2cslave": {
+ "name": "i2cslave",
+ "full_build": "1",
+ "default_value": "None",
+ "excluded": [
+ "circuitplayground_express_crickit",
+ "feather_m0_rfm69",
+ "arduino_mkr1300",
+ "bast_pro_mini_m0",
+ "feather_m0_adalogger",
+ "ugame10",
+ "circuitplayground_express",
+ "pewpew10",
+ "feather_m0_express_crickit",
+ "trinket_m0",
+ "catwan_usbstick",
+ "pirkey_m0",
+ "feather_m0_rfm9x",
+ "sparkfun_samd21_mini",
+ "feather_m0_basic",
+ "gemma_m0",
+ "hallowing_m0_express",
+ "arduino_mkrzero",
+ "meowmeow",
+ "escornabot_makech",
+ "sparkfun_samd21_dev",
+ "arduino_zero",
+ "uchip"
+ ]
+ },
+ "math": {
+ "name": "math",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "pirkey_m0"
+ ]
+ },
+ "microcontroller": {
+ "name": "microcontroller",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "neopixel_write": {
+ "name": "neopixel_write",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "ugame10",
+ "pirkey_m0"
+ ]
+ },
+ "network": {
+ "name": "network",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ },
+ "nvm": {
+ "name": "nvm",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "os": {
+ "name": "os",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "ps2io": {
+ "name": "ps2io",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ },
+ "pulseio": {
+ "name": "pulseio",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "random": {
+ "name": "random",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "rotaryio": {
+ "name": "rotaryio",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "pewpew10",
+ "pirkey_m0"
+ ]
+ },
+ "rtc": {
+ "name": "rtc",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "ugame10",
+ "pewpew10",
+ "pirkey_m0"
+ ]
+ },
+ "storage": {
+ "name": "storage",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "struct": {
+ "name": "struct",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "supervisor": {
+ "name": "supervisor",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "time": {
+ "name": "time",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": []
+ },
+ "touchio": {
+ "name": "touchio",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "kicksat-sprite",
+ "ugame10",
+ "datalore_ip_m4",
+ "pybadge",
+ "pyportal",
+ "sam32",
+ "mini_sam_m4",
+ "grandcentral_m4_express",
+ "feather_m4_express",
+ "pirkey_m0",
+ "pygamer",
+ "capablerobot_usbhub",
+ "metro_m4_airlift_lite",
+ "trellis_m4_express",
+ "itsybitsy_m4_express",
+ "pygamer_advance",
+ "metro_m4_express",
+ "cp32-m4",
+ "pybadge_airlift"
+ ]
+ },
+ "uheap": {
+ "name": "uheap",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ },
+ "usb_hid": {
+ "name": "usb_hid",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "ugame10"
+ ]
+ },
+ "usb_midi": {
+ "name": "usb_midi",
+ "full_build": "0",
+ "default_value": "1",
+ "excluded": [
+ "ugame10",
+ "pewpew10"
+ ]
+ },
+ "ustack": {
+ "name": "ustack",
+ "full_build": "0",
+ "default_value": "0",
+ "excluded": []
+ }
+} \ No newline at end of file