summaryrefslogtreecommitdiff
path: root/build-aux/measurestack/__init__.py
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-01 16:58:41 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-01 16:58:41 -0600
commit7a71f8ca21aea7e554e66ddd08eaed073db9c400 (patch)
treeb40e992f4b39669ebdc24fa53874dc2bda607312 /build-aux/measurestack/__init__.py
parenta30e879a82b06df850698e6bd30068dc0893a845 (diff)
parent8e3d2a904fe046910ee831e6fd9d2316aafc260a (diff)
Merge branch 'lukeshu/stack-gen-improvements'
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,
+ )