架构更新#4
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the build architecture by changing most layers from STATIC libraries to OBJECT libraries. Previously, all layers (L0-L5) were compiled as static libraries. Now, only third-party middleware (L3) remains as static libraries, while application and framework layers (L0, L1, L2, L4, L5) are compiled as OBJECT libraries whose object files directly participate in final linking.
Changes:
- Modified CMakeLists.txt files across L0-L5 layers to use OBJECT libraries instead of STATIC libraries
- Simplified L1_MCU build by removing intermediate cubemx_hal library
- Added build scripts for GCC and STARM toolchains
- Enabled LVGL examples and added extensive LVGL example source files
- Updated documentation to explain OBJECT library architecture
Reviewed changes
Copilot reviewed 211 out of 253 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| L0_Assets/CMakeLists.txt | Changed from STATIC to OBJECT library |
| L1_MCU/CMakeLists.txt | Changed to OBJECT library and added dependency links |
| L1_MCU/STM32F4*/CMakeLists.txt | Removed cubemx_hal intermediate library, sources added directly to l1_mcu |
| L2_Core/CMakeLists.txt | Changed from STATIC to OBJECT library |
| L3_Middlewares/CMakeLists.txt | Enabled LVGL examples, added circular dependency issue |
| L4_Components/CMakeLists.txt | Changed to OBJECT library, switched to GLOB_RECURSE |
| L5_App/CMakeLists.txt | Changed to OBJECT library, removed trailing whitespace |
| Script/*.sh | New build scripts for GCC and STARM toolchains |
| L3_Middlewares/LVGL/examples/* | Added extensive LVGL example files |
| */readme.md | Added OBJECT library architecture documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| LV_CONF_BUILD_DISABLE_DEMOS=1 | ||
| ) |
There was a problem hiding this comment.
The LVGL configuration change removes LV_CONF_BUILD_DISABLE_EXAMPLES=1 which will cause LVGL examples to be compiled. However, the examples are added to the link in L3_Middlewares/CMakeLists.txt line 41 with lvgl::examples, but this may not be correctly defined. LVGL typically uses lvgl as the main target and examples are usually optional. This could cause build failures if the LVGL examples target doesn't exist or isn't properly configured.
| LV_CONF_BUILD_DISABLE_EXAMPLES=1 | ||
| LV_CONF_BUILD_DISABLE_DEMOS=1 | ||
| ) | ||
| target_link_libraries(lvgl PUBLIC l1_mcu) |
There was a problem hiding this comment.
Adding target_link_libraries(lvgl PUBLIC l1_mcu) creates a circular dependency. The dependency hierarchy should be: l1_mcu -> l2_core -> l3_middlewares (which includes lvgl). Making lvgl depend on l1_mcu reverses this hierarchy and will cause CMake configuration errors or unexpected linking behavior.
| target_link_libraries(lvgl PUBLIC l1_mcu) |
| @@ -1,8 +1,10 @@ | |||
| file(GLOB L4_SRCS "src/*.c") | |||
| file(GLOB_RECURSE L4_SRCS "src/*.c") | |||
There was a problem hiding this comment.
Changed from file(GLOB ...) to file(GLOB_RECURSE ...) which will now recursively search all subdirectories. While this matches the intent to support subdirectories, it may unintentionally include files from backup directories, build artifacts, or other unwanted subdirectories if they exist under L4_Components/src/. Consider being more explicit about which subdirectories should be included.
修改原来将所有层级都链接为静态库的问题,现在只有第三方中间件会链接成静态库,其他都是.o库