Skip to content

Commit 1fa9182

Browse files
committed
Add an "--only" flag to quickly build just one kind of artifact
Most often I find that I want to check just one kind of artifact (e.g., mpy files) and this is a quicker syntax than excluding the other 3 types with 3 --ignores.
1 parent 5de7f05 commit 1fa9182

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

circuitpython_build_tools/scripts/build_bundles.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,17 @@ def _find_libraries(current_path, depth):
231231
subdirectories.extend(_find_libraries(path, depth - 1))
232232
return subdirectories
233233

234+
all_modules = ["py", "mpy", "example", "json"]
234235
@click.command()
235236
@click.option('--filename_prefix', required=True, help="Filename prefix for the output zip files.")
236237
@click.option('--output_directory', default="bundles", help="Output location for the zip files.")
237238
@click.option('--library_location', required=True, help="Location of libraries to bundle.")
238239
@click.option('--library_depth', default=0, help="Depth of library folders. This is useful when multiple libraries are bundled together but are initially in separate subfolders.")
239240
@click.option('--package_folder_prefix', default="adafruit_", help="Prefix string used to determine package folders to bundle.")
240241
@click.option('--remote_name', default="origin", help="Git remote name to use during building")
241-
@click.option('--ignore', "-i", multiple=True, type=click.Choice(["py", "mpy", "example", "json"]), help="Bundles to ignore building")
242-
def build_bundles(filename_prefix, output_directory, library_location, library_depth, package_folder_prefix, remote_name, ignore):
242+
@click.option('--ignore', "-i", multiple=True, type=click.Choice(all_modules), help="Bundles to ignore building")
243+
@click.option('--only', "-o", multiple=True, type=click.Choice(all_modules), help="Bundles to build building")
244+
def build_bundles(filename_prefix, output_directory, library_location, library_depth, package_folder_prefix, remote_name, ignore, only):
243245
os.makedirs(output_directory, exist_ok=True)
244246

245247
package_folder_prefix = package_folder_prefix.split(", ")
@@ -259,6 +261,11 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
259261
with open(build_tools_fn, "w") as f:
260262
f.write(build_tools_version)
261263

264+
if ignore and only:
265+
raise SystemExit("Only specify one of --ignore / --only")
266+
if only:
267+
ignore = set(all_modules) - set(only)
268+
262269
# Build raw source .py bundle
263270
if "py" not in ignore:
264271
zip_filename = os.path.join(output_directory,

0 commit comments

Comments
 (0)