[tools][keil] Preserve include path order - #11741
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
|
v5.3.0 |
| IncludePath.text = ';'.join([_make_path_relative(project_path, os.path.normpath(i)) for i in set(CPPPATH)]) | ||
| # Keep the same include path precedence as the SCons build environment. | ||
| paths = [_make_path_relative(project_path, os.path.normpath(i)) for i in CPPPATH] | ||
| IncludePath.text = ';'.join(dict.fromkeys(paths)) |
There was a problem hiding this comment.
dict.fromkeys(paths) 在 Python 2.7 中不保证插入顺序,因此在标准 Env 环境下,board/ 仍可能被排到 BSP 根目录之后,重新触发 Keil 编译失败。Python 官方文档也说明 Python 2.7 普通字典的遍历顺序不确定。
There was a problem hiding this comment.
现在用的python版本应该是3.11,从3.7之后就保证这个是顺序的吧
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
MDK5 工程生成器使用无序集合对头文件搜索路径去重,导致生成工程的 IncludePath 顺序不稳定。对于 bsp/renesas/ra8p1-titan-board/m85,错误顺序会优先选择 BSP 根目录下的 bsp_linker_info.h,而不是 board/bsp_linker_info.h,最终使 R_BSP_SecondaryCoreStart 声明缺失并导致 Keil 编译失败。
你的解决方案是什么 (what is your solution)
修改 tools/targets/keil.py,以 SCons 构建环境中的 CPPPATH 作为生成工程的基础路径,保留 SConstruct 明确配置的搜索优先级。路径转换为相对路径后使用有序方式去重,保证 MDK 工程的头文件搜索顺序与 SCons 构建环境一致且生成结果稳定。
请提供验证的bsp和config (provide the config and bsp)
BSP: bsp/renesas/ra8p1-titan-board/m85
.config: 未修改,使用仓库当前配置
action: 未单独触发 GitHub Action;已完成本地 Env、SCons 和 Keil 构建验证
本地验证:
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up