32
32
33
33
SUPPORTED_PORTS = ['atmel-samd' , 'cxd56' , 'esp32s2' , 'litex' , 'mimxrt10xx' , 'nrf' , 'raspberrypi' , 'stm' ]
34
34
35
+ aliases_by_board = {
36
+ "circuitplayground_express" : [
37
+ "circuitplayground_express_4h" ,
38
+ "circuitplayground_express_digikey_pycon2019" ,
39
+ ],
40
+ "pybadge" : ["edgebadge" ],
41
+ "pyportal" : ["pyportal_pynt" ],
42
+ "gemma_m0" : ["gemma_m0_pycon2018" ],
43
+ "pewpew10" : ["pewpew13" ],
44
+ }
45
+
46
+ aliases_brand_names = {
47
+ "circuitplayground_express_4h" :
48
+ "Adafruit Circuit Playground Express 4-H" ,
49
+ "circuitplayground_express_digikey_pycon2019" :
50
+ "Circuit Playground Express Digi-Key PyCon 2019" ,
51
+ "edgebadge" :
52
+ "Adafruit EdgeBadge" ,
53
+ "pyportal_pynt" :
54
+ "Adafruit PyPortal Pynt" ,
55
+ "gemma_m0_pycon2018" :
56
+ "Adafruit Gemma M0 PyCon 2018" ,
57
+ "pewpew13" :
58
+ "PewPew 13" ,
59
+ }
60
+
61
+ additional_modules = {
62
+ "fontio" : "CIRCUITPY_DISPLAYIO" ,
63
+ "terminalio" : "CIRCUITPY_DISPLAYIO" ,
64
+ # "socket": "CIRCUITPY_NETWORK",
65
+ "adafruit_bus_device" : "CIRCUITPY_BUSDEVICE" ,
66
+ }
67
+
35
68
def get_circuitpython_root_dir ():
36
69
""" The path to the root './circuitpython' directory
37
70
"""
@@ -71,8 +104,11 @@ def build_module_map():
71
104
full_build = False
72
105
for module in modules :
73
106
full_name = module
74
- search_name = module .lstrip ("_" )
75
- re_pattern = "CIRCUITPY_{}\s*\??=\s*(.+)" .format (search_name .upper ())
107
+ if module in additional_modules :
108
+ search_identifier = additional_modules [module ]
109
+ else :
110
+ search_identifier = 'CIRCUITPY_' + module .lstrip ("_" ).upper ()
111
+ re_pattern = f"{ re .escape (search_identifier )} \s*\??=\s*(.+)"
76
112
find_config = re .findall (re_pattern , configs )
77
113
if not find_config :
78
114
continue
@@ -84,11 +120,12 @@ def build_module_map():
84
120
else :
85
121
default_val = "None"
86
122
87
- base [search_name ] = {
123
+ base [module ] = {
88
124
"name" : full_name ,
89
125
"full_build" : str (full_build ),
90
126
"default_value" : default_val ,
91
- "excluded" : {}
127
+ "excluded" : {},
128
+ "key" : search_identifier ,
92
129
}
93
130
94
131
return base
@@ -164,14 +201,28 @@ def support_matrix(arg):
164
201
165
202
board_modules = []
166
203
for module in base :
167
- key = f'CIRCUITPY_ { module . upper () } '
204
+ key = base [ module ][ 'key' ]
168
205
if int (lookup_setting (settings , key , '0' )):
169
206
board_modules .append (base [module ]['name' ])
207
+ board_modules .sort ()
208
+
209
+ # generate alias boards too
210
+ board_matrix = [(board_name , board_modules )]
211
+ if entry .name in aliases_by_board :
212
+ for alias in aliases_by_board [entry .name ]:
213
+ if use_branded_name :
214
+ if alias in aliases_brand_names :
215
+ alias = aliases_brand_names [alias ]
216
+ else :
217
+ alias = alias .replace ("_" ," " ).title ()
218
+ board_matrix .append ( (alias , board_modules ) )
170
219
171
- return ( board_name , sorted ( board_modules ) )
220
+ return board_matrix # this is now a list of (board,modules )
172
221
173
222
executor = ThreadPoolExecutor (max_workers = os .cpu_count ())
174
- boards = dict (sorted (executor .map (support_matrix , all_ports_all_boards ())))
223
+ mapped_exec = executor .map (support_matrix , all_ports_all_boards ())
224
+ # flatmap with comprehensions
225
+ boards = dict (sorted ([board for matrix in mapped_exec for board in matrix ]))
175
226
176
227
#print(json.dumps(boards, indent=2))
177
228
return boards
0 commit comments