Skip to content

Commit 50ddabd

Browse files
committed
change 'package_folder_prefix' to a pos arg; grab examples subfolders
1 parent 18df89a commit 50ddabd

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

circuitpython_build_tools/build.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _munge_to_temp(original_path, temp_file, library_version):
100100
temp_file.write(line.encode("utf-8") + b"\r\n")
101101
temp_file.flush()
102102

103-
def library(library_path, output_directory, mpy_cross=None, example_bundle=False, pkg_folder_prefix=None):
103+
def library(library_path, output_directory, pkg_folder_prefix, mpy_cross=None, example_bundle=False):
104104
py_files = []
105105
package_files = []
106106
example_files = []
@@ -115,7 +115,10 @@ def library(library_path, output_directory, mpy_cross=None, example_bundle=False
115115
# 'walked_files' while retaining subdirectory structure
116116
walked_files = []
117117
for path in path_walk:
118-
path_tail_idx = path[0].rfind("/") + 1
118+
if filename.startswith("examples"):
119+
path_tail_idx = path[0].rfind("examples/") + 9
120+
else:
121+
path_tail_idx = path[0].rfind("/") + 1
119122
path_tail = path[0][path_tail_idx:]
120123
rel_path = ""
121124
# if this entry is the package top dir, keep it
@@ -134,11 +137,10 @@ def library(library_path, output_directory, mpy_cross=None, example_bundle=False
134137
example_files.extend(files)
135138
#print("- example files: {}".format(example_files))
136139
else:
137-
if pkg_folder_prefix:
138-
if (not example_bundle and
139-
not filename.startswith(pkg_folder_prefix)):
140-
#print("skipped path: {}".format(full_path))
141-
continue
140+
if (not example_bundle and
141+
not filename.startswith(pkg_folder_prefix)):
142+
#print("skipped path: {}".format(full_path))
143+
continue
142144
if not example_bundle:
143145
package_files.extend(files)
144146
#print("- package files: {} | {}".format(filename, package_files))

circuitpython_build_tools/scripts/build_bundles.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ def add_file(bundle, src_file, zip_name):
4848
return file_sector_size
4949

5050

51-
def build_bundle(libs, bundle_version, output_filename,
52-
build_tools_version="devel", mpy_cross=None, example_bundle=False,
53-
pkg_folder_prefix=None):
51+
def build_bundle(libs, bundle_version, output_filename, pkg_folder_prefix,
52+
build_tools_version="devel", mpy_cross=None, example_bundle=False):
5453
build_dir = "build-" + os.path.basename(output_filename)
5554
top_folder = os.path.basename(output_filename).replace(".zip", "")
5655
build_lib_dir = os.path.join(build_dir, top_folder, "lib")
@@ -70,7 +69,7 @@ def build_bundle(libs, bundle_version, output_filename,
7069
success = True
7170
for library_path in libs:
7271
try:
73-
build.library(library_path, build_lib_dir, pkg_folder_prefix=pkg_folder_prefix,
72+
build.library(library_path, build_lib_dir, pkg_folder_prefix,
7473
mpy_cross=mpy_cross, example_bundle=example_bundle)
7574
except ValueError as e:
7675
print("build.library failure:", library_path)
@@ -159,8 +158,7 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
159158
zip_filename = os.path.join(output_directory,
160159
filename_prefix + '-py-{VERSION}.zip'.format(
161160
VERSION=bundle_version))
162-
build_bundle(libs, bundle_version, zip_filename,
163-
pkg_folder_prefix=package_folder_prefix,
161+
build_bundle(libs, bundle_version, zip_filename, package_folder_prefix,
164162
build_tools_version=build_tools_version)
165163

166164
# Build .mpy bundle(s)
@@ -177,13 +175,12 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
177175
filename_prefix + '-{TAG}-mpy-{VERSION}.zip'.format(
178176
TAG=version["name"],
179177
VERSION=bundle_version))
180-
build_bundle(libs, bundle_version, zip_filename, mpy_cross=mpy_cross,
181-
build_tools_version=build_tools_version,
182-
pkg_folder_prefix=package_folder_prefix)
178+
build_bundle(libs, bundle_version, zip_filename, package_folder_prefix,
179+
mpy_cross=mpy_cross, build_tools_version=build_tools_version)
183180

184181
# Build example bundle
185182
zip_filename = os.path.join(output_directory,
186183
filename_prefix + '-examples-{VERSION}.zip'.format(
187184
VERSION=bundle_version))
188-
build_bundle(libs, bundle_version, zip_filename,
185+
build_bundle(libs, bundle_version, zip_filename, package_folder_prefix,
189186
build_tools_version=build_tools_version, example_bundle=True)

0 commit comments

Comments
 (0)