Develop/nn#14
Conversation
There was a problem hiding this comment.
Pull request overview
This PR standardizes header inclusion across the project by removing deep relative include paths, updates CMake include directories accordingly, and namespaces compiler/toolchain macros with an __EK_ prefix to reduce collisions with vendor/CMSIS macros.
Changes:
- Replaced many
../-style includes with plain"header.h"includes and adjusted include directories to match. - Renamed core compiler attribute/helper macros (e.g., weak/unused/static-inline) from
__WEAK/__UNUSED/__STATIC_INLINEto__EK_WEAK/__EK_UNUSED/__EK_STATIC_INLINE. - Updated third-party includes (lwprintf, letter_shell) and CMake include paths (notably lwprintf
inc).
Reviewed changes
Copilot reviewed 73 out of 73 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Test/test.h | Switch test includes to basename headers (expects include dirs configured). |
| Test/shell_symbols.c | Switch shell header include to "shell.h". |
| Test/CMakeLists.txt | Convert to target_include_directories and adjust include roots. |
| L2_Core/utils/src/ek_str.c | Include ek_str.h by basename. |
| L2_Core/utils/src/ek_stack.c | Include ek_stack.h by basename. |
| L2_Core/utils/src/ek_ringbuf.c | Include ek_ringbuf.h by basename. |
| L2_Core/utils/src/ek_mem.c | Include ek_mem.h by basename; rename weak/unused macros. |
| L2_Core/utils/src/ek_log.c | Include ek_log.h by basename; rename weak macro usage. |
| L2_Core/utils/src/ek_io.c | Include ek_io.h by basename; rename weak/unused macro usage. |
| L2_Core/utils/src/ek_export.c | Include ek_export.h by basename. |
| L2_Core/utils/src/ek_assert.c | Include headers by basename; rename unused macro usage. |
| L2_Core/utils/inc/ek_vec.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_str.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_stack.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_shell.h | Include shell.h by basename. |
| L2_Core/utils/inc/ek_ringbuf.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_mem.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_log.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_list.h | Include ek_conf.h by basename; rename inline macro to __EK_STATIC_INLINE. |
| L2_Core/utils/inc/ek_io.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_export.h | Include ek_conf.h by basename. |
| L2_Core/utils/inc/ek_def.h | Namespace compiler macros to __EK_*; remove <stdarg.h> include; change unsupported-compiler behavior. |
| L2_Core/utils/inc/ek_assert.h | Include ek_conf.h by basename. |
| L2_Core/third_party/lwprintf/lwprintf_sys_win32.c | Switch include to "lwprintf_sys.h". |
| L2_Core/third_party/lwprintf/lwprintf_sys_threadx.c | Switch include to "lwprintf_sys.h". |
| L2_Core/third_party/lwprintf/lwprintf_sys_cmsis_os.c | Switch include to "lwprintf_sys.h". |
| L2_Core/third_party/lwprintf/lwprintf.c | Switch include to "lwprintf.h". |
| L2_Core/third_party/letter_shell/shell_ext.c | Switch includes to basename headers. |
| L2_Core/third_party/letter_shell/shell.c | Switch includes to basename headers, including "lwprintf.h". |
| L2_Core/port/stm32f429zi/st_uart_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/stm32f429zi/st_tim_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/stm32f429zi/st_tick_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/stm32f429zi/st_spi_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/stm32f429zi/st_ltdc_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/stm32f429zi/st_i2c_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/stm32f429zi/st_gpio_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/stm32f429zi/st_dma2d_port.c | Switch includes to basename headers; update unused macro (weak macro still __WEAK). |
| L2_Core/port/gd32f470zgt6/gd_uart_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_tim_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_tick_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_spi_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_pwm_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_ipa_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_i2c_port.c | Switch includes to basename headers (including hal_iic.h). |
| L2_Core/port/gd32f470zgt6/gd_gpio_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_dma_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_dac_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/port/gd32f470zgt6/gd_adc_port.c | Switch HAL/utils includes to basename headers. |
| L2_Core/hal/src/ek_hal_uart.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_tim.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_tick.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_spi.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_pwm.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_ltdc.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_i2c.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_gpio.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_dma2d.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_dma.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_dac.c | Switch includes to basename headers. |
| L2_Core/hal/src/ek_hal_adc.c | Switch includes to basename headers. |
| L2_Core/hal/inc/ek_hal_uart.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_tim.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_tick.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_spi.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_pwm.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_ltdc.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_i2c.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_gpio.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_dma2d.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_dma.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_dac.h | Switch utils includes to basename headers. |
| L2_Core/hal/inc/ek_hal_adc.h | Switch utils includes to basename headers. |
| L2_Core/CMakeLists.txt | Update lwprintf include directory from include to inc. |
Comments suppressed due to low confidence (1)
L2_Core/utils/inc/ek_def.h:23
ek_def.hno longer includes<stdarg.h>. Any module that relied onek_def.hto provideva_list/va_startwill now fail to compile unless it (or a transitively included header) includes<stdarg.h>. Either restore the include here, or ensure all call sites that use variadic APIs include<stdarg.h>directly to avoid fragile transitive dependencies.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /* ========== 不支持的编译器(空定义) ========== */ | ||
| #else | ||
|
|
||
| # if 1 | ||
| # error \ | ||
| "Unsupported compiler detected. Please review and update the macro definitions in ek_def.h for this toolchain." | ||
| # endif | ||
|
|
||
| # define __WEAK | ||
| # define __PACKED | ||
| # define __PACKED_STRUCT struct | ||
| # define __ALIGNED(x) | ||
| # define __USED | ||
| # define __SECTION(x) | ||
| # define __NO_RETURN | ||
| # define __UNUSED(x) ((void)(x)) | ||
| # define __INLINE inline | ||
| # define __STATIC_INLINE static inline | ||
| # define __ALWAYS_INLINE static inline | ||
| # define __ASM asm | ||
| # define __EK_WEAK | ||
| # define __EK_PACKED | ||
| # define __EK_PACKED_STRUCT struct | ||
| # define __EK_ALIGNED(x) | ||
| # define __EK_USED | ||
| # define __EK_SECTION(x) | ||
| # define __EK_NO_RETURN | ||
| # define __EK_UNUSED(x) ((void)(x)) | ||
| # define __EK_INLINE inline | ||
| # define __EK_STATIC_INLINE static inline | ||
| # define __EK_ALWAYS_INLINE static inline | ||
| # define __EK_ASM asm | ||
| #endif |
There was a problem hiding this comment.
ek_def.h removed the hard error for unsupported compilers and now falls back to empty attribute/inline/asm macros. This can silently produce miscompiled binaries (e.g., weak/section attributes dropped) on a new toolchain. Consider keeping a failing default (e.g., #error) or adding explicit branches for each supported compiler and requiring an opt-in macro to allow the empty-definition fallback.
| __WEAK void ek_dma2d_transfer_cplt_callback(DMA2D_HandleTypeDef *hdma2d) | ||
| { | ||
| __UNUSED(hdma2d); | ||
| __EK_UNUSED(hdma2d); |
There was a problem hiding this comment.
This callback is still declared with __WEAK, but ek_def.h has migrated to __EK_WEAK and no longer defines __WEAK. Please switch this to __EK_WEAK (or include the header that defines __WEAK if you intend to depend on CMSIS) to avoid toolchain-dependent builds.
No description provided.