MCPcopy Create free account
hub / github.com/OpenIPC/firmware / build_report

Function build_report

general/scripts/size_report.py:206–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

204
205
206def build_report() -> dict:
207 target_dir = Path(env("TARGET_DIR"))
208 br_output = Path(env("BR2_OUTPUT_DIR"))
209 images_dir = Path(env("IMAGES_DIR"))
210 soc_model = env("OPENIPC_SOC_MODEL")
211 variant = env("OPENIPC_VARIANT")
212 flash_mb = env("BR2_OPENIPC_FLASH_SIZE", required=False, default="")
213 vendor = env("BR2_OPENIPC_SOC_VENDOR", required=False, default="")
214 overlay_dir = Path(
215 env(
216 "BR2_OVERLAY_PATH",
217 required=False,
218 default=str(br_output.parent / "general" / "overlay"),
219 )
220 )
221
222 pfl = br_output / "build" / "packages-file-list.txt"
223 if not pfl.exists():
224 sys.exit(f"size_report: packages-file-list.txt not found at {pfl}")
225
226 path_to_pkg = parse_packages_file_list(pfl)
227 entries, rootfs_uncompressed = walk_target(target_dir)
228
229 per_pkg_bytes: dict[str, int] = defaultdict(int)
230 per_pkg_count: dict[str, int] = defaultdict(int)
231 per_pkg_top: dict[str, list[tuple[int, str]]] = defaultdict(list)
232 on_disk_paths: set[str] = set()
233
234 for rel, size in entries:
235 on_disk_paths.add(rel)
236 pkg = path_to_pkg.get(rel, OVERLAY_BUCKET)
237 per_pkg_bytes[pkg] += size
238 per_pkg_count[pkg] += 1
239 per_pkg_top[pkg].append((size, rel))
240
241 removed: list[dict] = []
242 for rel, pkg in path_to_pkg.items():
243 if rel in on_disk_paths:
244 continue
245 if is_buildroot_strip(rel):
246 continue
247 src_bytes = 0
248 per_pkg_target = br_output / "per-package" / pkg / "target" / rel
249 if per_pkg_target.exists():
250 try:
251 src_bytes = per_pkg_target.lstat().st_size
252 except OSError:
253 pass
254 removed.append({"path": "/" + rel, "package": pkg, "source_bytes": src_bytes})
255
256 has_squashfs = (
257 env("BR2_TARGET_ROOTFS_SQUASHFS", required=False, default="") == "y"
258 )
259 has_ubi = env("BR2_TARGET_ROOTFS_UBI", required=False, default="") == "y"
260
261 rootfs_img = (
262 find_image(images_dir, "rootfs.squashfs", soc_model) if has_squashfs else None
263 )

Callers 1

mainFunction · 0.70

Calls 10

parse_packages_file_listFunction · 0.85
walk_targetFunction · 0.85
is_buildroot_stripFunction · 0.85
find_imageFunction · 0.85
squashfs_metadataFunction · 0.85
parse_builtinFunction · 0.85
parse_autoloadFunction · 0.85
find_vmlinuxFunction · 0.85
kernel_capsFunction · 0.85
envFunction · 0.70

Tested by

no test coverage detected