[RFC][PoC] Zephyr PreProcessor (ZPP) framework #82990
Draft
+1,649
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This is a proof-of-concept, namely the Zephyr Pre-Processor (ZPP) framework, an alternative to the
syscall
parsing for gathering function and struct information.Problem description
The https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/build/parse_syscalls.py script has a few drawbacks that this PR tries to improve upon.
__subsystem
and__net_socket
"tags" but this is a hidden implementation detailProposed change
Run the C pre-processor, in the pre-build stage, on files that are part of the build and have the
-DZPP
compile definition (opt-in), and parse the output for annotated functions or structs.Gather the information in a formatted (json) file that can be fed into other build steps.
Detailed RFC
In the aforementioned C pre-processor run, the compile definition
-D__ZPP__
is added which enables the C23 annotations (not part of the regular build), for example:The newly introduced
scripts/zpp.py
scans for these annotations and can output the structured data needed for the next build steps.Proposed change (Detailed)
__subsystem
tags with ZPP (part of the PR already)__net_socket
tags with ZPP__syscall
tags with ZPP__section_iterable
tags for structs to allow creating linker sections from source files, without the need for additional linker scripts (cleanup allcommon-rom.ld
andcommon-rom.cmake
files)Dependencies
Affects downstream usage of the
syscall
mechanism.Concerns and Unresolved Questions
Alternatives
Don't do this