summaryrefslogtreecommitdiff
path: root/build-aux/measurestack/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/measurestack/__init__.py')
-rw-r--r--build-aux/measurestack/__init__.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/build-aux/measurestack/__init__.py b/build-aux/measurestack/__init__.py
new file mode 100644
index 0000000..c1b9d7f
--- /dev/null
+++ b/build-aux/measurestack/__init__.py
@@ -0,0 +1,38 @@
+# build-aux/measurestack/__init__.py - Analyze stack sizes for compiled objects
+#
+# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+import re
+import sys
+
+from . import app_main
+
+# pylint: disable=unused-variable
+__all__ = [
+ "main",
+]
+
+
+re_c_obj_suffix = re.compile(r"\.c\.(?:o|obj)$")
+
+
+def main() -> None:
+ pico_platform = sys.argv[1]
+ base_dir = sys.argv[2]
+ obj_fnames = set(sys.argv[3:])
+
+ c_fnames: set[str] = set()
+ ci_fnames: set[str] = set()
+ for obj_fname in obj_fnames:
+ if re_c_obj_suffix.search(obj_fname):
+ ci_fnames.add(re_c_obj_suffix.sub(".c.ci", obj_fname))
+ with open(obj_fname + ".d", "r", encoding="utf-8") as fh:
+ c_fnames.update(fh.read().replace("\\\n", " ").split(":")[-1].split())
+
+ app_main.main(
+ arg_pico_platform=pico_platform,
+ arg_base_dir=base_dir,
+ arg_ci_fnames=ci_fnames,
+ arg_c_fnames=c_fnames,
+ )