问题描述
在编译 bsp/abstract-machine 时遇到若干问题,导致编译失败或配置不正确。主要包括:
- Python 模块导入优先级问题:
sys.path.append() 导致系统路径中的同名模块优先于项目 tools/ 目录被加载,引发导入错误。
rtconfig.h 缺少 extra.h 的 include:scons 生成 rtconfig.h 后,原有的 sed 检测逻辑不够健壮,无法可靠地插入 #include "extra.h"。
init 目标的依赖链问题:init: $(RTCONFIG_H) 的 make 依赖写法在 rtconfig.h 已存在且较新时,不会重新生成它,导致 files.mk 内容可能基于过期的配置。
修改内容
1. SConstruct: 修复 sys.path 优先级
-sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
+sys.path = [os.path.join(RTT_ROOT, "tools")] + sys.path
2. Makefile: 改进 extra.h 检测逻辑
-if [ "`sed -n '3p' $@`"x = x ]; then sed -i -e '2a#include "extra.h"' $@; fi
+if ! grep -q 'extra.h' $@; then sed -i '2a#include "extra.h"' $@; fi
3. Makefile: 重构 init 目标
-init: $(RTCONFIG_H)
+init:
+ rm -f $(RTCONFIG_H)
+ $(MAKE) $(RTCONFIG_H)
scons -c
scons --verbose -n > $(FILE_TMP)
...
影响范围
bsp/abstract-machine/SConstruct
bsp/abstract-machine/Makefile
仅影响 RT-Thread 在 abstract-machine(AM)BSP 上的编译流程,不影响其他 BSP 或 RT-Thread 核心代码。
问题描述
在编译
bsp/abstract-machine时遇到若干问题,导致编译失败或配置不正确。主要包括:sys.path.append()导致系统路径中的同名模块优先于项目tools/目录被加载,引发导入错误。rtconfig.h缺少extra.h的 include:scons 生成rtconfig.h后,原有的 sed 检测逻辑不够健壮,无法可靠地插入#include "extra.h"。init目标的依赖链问题:init: $(RTCONFIG_H)的 make 依赖写法在rtconfig.h已存在且较新时,不会重新生成它,导致files.mk内容可能基于过期的配置。修改内容
1. SConstruct: 修复
sys.path优先级2. Makefile: 改进
extra.h检测逻辑3. Makefile: 重构
init目标影响范围
bsp/abstract-machine/SConstructbsp/abstract-machine/Makefile仅影响 RT-Thread 在 abstract-machine(AM)BSP 上的编译流程,不影响其他 BSP 或 RT-Thread 核心代码。