-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC][PoC] Zephyr PreProcessor (ZPP) framework #82990
base: main
Are you sure you want to change the base?
Changes from all commits
73d5e74
ac30696
a61711e
1de5270
5fb2e12
067eb43
6c410db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2024 Basalte bv | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Generate compile_commands.json in the output directory | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE CACHE BOOL | ||
"Export CMake compile commands. Used by zpp.py script" | ||
FORCE | ||
) | ||
|
||
set(annotations_json "${CMAKE_BINARY_DIR}/zephyr/annotations.json") | ||
|
||
add_custom_command( | ||
OUTPUT ${annotations_json} | ||
COMMAND | ||
${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/zpp.py | ||
-j ${CMAKE_BUILD_PARALLEL_LEVEL} | ||
-o ${annotations_json} | ||
-d ${annotations_json}.d | ||
${CMAKE_BINARY_DIR}/compile_commands.json | ||
DEPENDS | ||
${ZEPHYR_BASE}/scripts/zpp.py | ||
${CMAKE_BINARY_DIR}/compile_commands.json | ||
DEPFILE ${annotations_json}.d | ||
) | ||
|
||
add_custom_target(zpp DEPENDS ${annotations_json}) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,16 @@ | |
#define EXTERN_C extern | ||
#endif | ||
|
||
/* | ||
* Use C23 attributes with our own prefix to make sure the C preprocessor | ||
* has content for the annotations. | ||
*/ | ||
#ifdef __ZPP__ | ||
#define __zpp(x) [[zephyr::x]] | ||
#else | ||
#define __zpp(...) | ||
#endif | ||
|
||
/* Use TASK_ENTRY_CPP to tag task entry points defined in C++ files. */ | ||
|
||
#ifdef __cplusplus | ||
|
@@ -147,9 +157,14 @@ | |
* not used). | ||
*/ | ||
#ifndef ZTEST_UNITTEST | ||
#ifndef __ZPP__ | ||
#define __syscall static inline | ||
#define __syscall_always_inline static inline __attribute__((always_inline)) | ||
#else | ||
#define __syscall __zpp(func("syscall", __FILE__, __LINE__)) | ||
#define __syscall_always_inline __zpp(func("syscall", __FILE__, __LINE__)) | ||
Comment on lines
+160
to
+165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: both expand to the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The But I think the current syscall parsing also behaves the same, they end up different when compiling only. |
||
#endif | ||
#else | ||
#define __syscall | ||
#define __syscall_always_inline | ||
#endif /* ZTEST_UNITTEST */ | ||
|
@@ -160,10 +175,16 @@ | |
*/ | ||
|
||
/* Indicates this is a driver subsystem */ | ||
#define __subsystem | ||
#define __subsystem __zpp(struct("__subsystem", "iterable", "ROM")) | ||
|
||
/* Indicates this is a network socket object */ | ||
#define __net_socket | ||
#define __net_socket __zpp(struct("__net_socket")) | ||
|
||
/* Indicates a struct iterable section should be added in ROM */ | ||
#define __iterable_section_rom __zpp(struct("iterable", "ROM")) | ||
|
||
/* Indicates a struct iterable section should be added in RAM */ | ||
#define __iterable_section_ram __zpp(struct("iterable", "RAM")) | ||
|
||
#ifndef BUILD_ASSERT | ||
/* Compile-time assertion that makes the build to fail. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already set in
cmake/modules/kernel.cmake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied it from there, it should be merged somewhere indeed, but for the PoC it was easier to have it here with less chance of getting conflicts.