62
62
"fontio" : "CIRCUITPY_DISPLAYIO" ,
63
63
"terminalio" : "CIRCUITPY_DISPLAYIO" ,
64
64
"adafruit_bus_device" : "CIRCUITPY_BUSDEVICE" ,
65
- "adafruit_pixelbuf" : "CIRCUITPY_PIXELBUF"
65
+ "adafruit_pixelbuf" : "CIRCUITPY_PIXELBUF" ,
66
+ "usb" : "CIRCUITPY_USB_HOST" ,
66
67
}
67
68
69
+ frozen_excludes = ["examples" , "docs" , "tests" , "utils" , "conf.py" , "setup.py" ]
70
+ """Files and dirs at the root of a frozen directory that should be ignored.
71
+ This is the same list as in the preprocess_frozen_modules script."""
72
+
68
73
def get_circuitpython_root_dir ():
69
74
""" The path to the root './circuitpython' directory
70
75
"""
@@ -162,6 +167,40 @@ def get_settings_from_makefile(port_dir, board_name):
162
167
163
168
return settings
164
169
170
+ def get_repository_url (directory ):
171
+ contents = subprocess .run (
172
+ ["git" , "remote" , "get-url" , "origin" ],
173
+ encoding = "utf-8" ,
174
+ errors = "replace" ,
175
+ stdout = subprocess .PIPE ,
176
+ stderr = subprocess .PIPE ,
177
+ cwd = directory
178
+ )
179
+ return contents .stdout .strip ()
180
+
181
+ def frozen_modules_from_dirs (frozen_mpy_dirs ):
182
+ """
183
+ Go through the list of frozen directories and extract the python modules.
184
+ Paths are of the type:
185
+ $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
186
+ $(TOP)/frozen/circuitpython-stage/meowbit
187
+ Python modules are at the root of the path, and are python files or directories
188
+ containing python files. Except the ones in the frozen_excludes list.
189
+ """
190
+ frozen_modules = []
191
+ for frozen_path in filter (lambda x : x , frozen_mpy_dirs .split (" " )):
192
+ source_dir = get_circuitpython_root_dir () / frozen_path [7 :]
193
+ url_repository = get_repository_url (source_dir )
194
+ for sub in source_dir .glob ("*" ):
195
+ if sub .name in frozen_excludes :
196
+ continue
197
+ if sub .name .endswith (".py" ):
198
+ frozen_modules .append ((sub .name [:- 3 ], url_repository ))
199
+ continue
200
+ if next (sub .glob ("**/*.py" ), None ): # tests if not empty
201
+ frozen_modules .append ((sub .name , url_repository ))
202
+ return frozen_modules
203
+
165
204
def lookup_setting (settings , key , default = '' ):
166
205
while True :
167
206
value = settings .get (key , default )
@@ -207,16 +246,22 @@ def support_matrix(arg):
207
246
board_modules .append (base [module ]['name' ])
208
247
board_modules .sort ()
209
248
249
+ frozen_modules = []
250
+ if "FROZEN_MPY_DIRS" in settings :
251
+ frozen_modules = frozen_modules_from_dirs (settings ["FROZEN_MPY_DIRS" ])
252
+ if frozen_modules :
253
+ frozen_modules .sort ()
254
+
210
255
# generate alias boards too
211
- board_matrix = [(board_name , board_modules )]
256
+ board_matrix = [(board_name , ( board_modules , frozen_modules ) )]
212
257
if entry .name in aliases_by_board :
213
258
for alias in aliases_by_board [entry .name ]:
214
259
if use_branded_name :
215
260
if alias in aliases_brand_names :
216
261
alias = aliases_brand_names [alias ]
217
262
else :
218
263
alias = alias .replace ("_" ," " ).title ()
219
- board_matrix .append ( (alias , board_modules ) )
264
+ board_matrix .append ( (alias , ( board_modules , frozen_modules ) ) )
220
265
221
266
return board_matrix # this is now a list of (board,modules)
222
267
@@ -225,7 +270,6 @@ def support_matrix(arg):
225
270
# flatmap with comprehensions
226
271
boards = dict (sorted ([board for matrix in mapped_exec for board in matrix ]))
227
272
228
- # print(json.dumps(boards, indent=2))
229
273
return boards
230
274
231
275
if __name__ == '__main__' :
0 commit comments