Skip to content

Commit b803b26

Browse files
committed
allow for multiple entries for the 'package_folder_prefix" argument
1 parent 83ecd95 commit b803b26

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

circuitpython_build_tools/build.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# The MIT License (MIT)
44
#
55
# Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
6+
# 2018, 2019 Michael Schroeder
67
#
78
# Permission is hereby granted, free of charge, to any person obtaining a copy
89
# of this software and associated documentation files (the "Software"), to deal
@@ -116,12 +117,16 @@ def library(library_path, output_directory, package_folder_prefix,
116117
glob_search.extend(list(lib_path.rglob(pattern)))
117118

118119
for file in glob_search:
119-
#print(file_tree, ":", parent_idx)
120120
if file.parts[parent_idx] == "examples":
121121
example_files.append(file)
122122
else:
123123
if not example_bundle:
124-
if file.parts[parent_idx].startswith(package_folder_prefix):
124+
is_package = False
125+
for prefix in package_folder_prefix:
126+
if file.parts[parent_idx].startswith(prefix):
127+
is_package = True
128+
129+
if is_package:
125130
package_files.append(file)
126131
else:
127132
if file.name in IGNORE_PY:
@@ -131,8 +136,8 @@ def library(library_path, output_directory, package_folder_prefix,
131136
py_files.append(file)
132137

133138
if len(py_files) > 1:
134-
raise ValueError("Multiple top level py files not allowed. Please put them in a package "
135-
"or combine them into a single file.")
139+
raise ValueError("Multiple top level py files not allowed. Please put "
140+
"them in a package or combine them into a single file.")
136141

137142
for fn in example_files:
138143
base_dir = os.path.join(output_directory.replace("/lib", "/"),
@@ -142,7 +147,8 @@ def library(library_path, output_directory, package_folder_prefix,
142147
total_size += 512
143148

144149
for fn in package_files:
145-
base_dir = os.path.join(output_directory, fn.relative_to(library_path).parent)
150+
base_dir = os.path.join(output_directory,
151+
fn.relative_to(library_path).parent)
146152
if not os.path.isdir(base_dir):
147153
os.makedirs(base_dir)
148154
total_size += 512

circuitpython_build_tools/scripts/build_bundles.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def _find_libraries(current_path, depth):
139139
def build_bundles(filename_prefix, output_directory, library_location, library_depth, package_folder_prefix):
140140
os.makedirs(output_directory, exist_ok=True)
141141

142+
package_folder_prefix = package_folder_prefix.split(", ")
143+
142144
bundle_version = build.version_string()
143145

144146
libs = _find_libraries(os.path.abspath(library_location), library_depth)

0 commit comments

Comments
 (0)