refactor: split header-only drivers into source + header files#2368
Open
xunwen-art wants to merge 10 commits intocommaai:masterfrom
Open
refactor: split header-only drivers into source + header files#2368xunwen-art wants to merge 10 commits intocommaai:masterfrom
xunwen-art wants to merge 10 commits intocommaai:masterfrom
Conversation
added 5 commits
March 5, 2026 01:36
Split all header-only driver files into separate .c and .h files: - bootkick, can_common, clock_source, fake_siren, fan, fdcan - gpio, harness, interrupts, led, pwm, registers - simple_watchdog, spi, timers, uart, usb Changes: - Move function implementations to .c files - Keep function declarations and #define in .h files - Add proper include guards to all header files - Add necessary #include directives Addresses commaai#2171
- Move fan_state_t struct and extern fan_state to fan.h - Move REGISTER_INTERRUPT macro and interrupt struct to interrupts.h - This fixes compilation errors where llfan.h and llusb.h couldn't find these definitions
- Move REGISTER_INTERRUPT macro to interrupts.h - Add extern declarations for uart_ring buffers in uart.h - Remove duplicate interrupt definitions from drivers.h
…larations - Add driver_sources list to SConscript for both bootstub and main builds - Add harness_t struct and extern harness to harness.h - Add SPI_IRQ_RATE, SPI_BUF_SIZE and extern declarations to spi.h
Author
|
这个重构比预期更复杂,需要更多时间来修复构建系统问题。原始代码使用 header-only 模式,所有 driver 代码在编译时通过 bootstub.c 或 main.c 直接 include。改为 source + header 模式需要修改 SConscript 来正确编译 .c 文件,并处理 scons 的对象文件命名冲突。 我会继续研究这个问题,并在准备好后重新提交。 |
added 5 commits
March 5, 2026 15:33
SCons was complaining about 'Two environments with different actions' because bootstub and main both compile driver sources with different flags (-DBOOTSTUB vs no flag). Now bootstub uses a separate output directory for its driver object files.
Now these headers include drivers.h which contains the struct definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Refactor all header-only driver files into separate source (.c) and header (.h) files.
Changes
Split 17 driver files:
Benefits
Testing
Fixes #2171