Skip to content

修复 bsp/abstract-machine 编译问题 #8

Description

@ClockworkBoat

问题描述

在编译 bsp/abstract-machine 时遇到若干问题,导致编译失败或配置不正确。主要包括:

  1. Python 模块导入优先级问题sys.path.append() 导致系统路径中的同名模块优先于项目 tools/ 目录被加载,引发导入错误。
  2. rtconfig.h 缺少 extra.h 的 include:scons 生成 rtconfig.h 后,原有的 sed 检测逻辑不够健壮,无法可靠地插入 #include "extra.h"
  3. 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 核心代码。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions