在eclipse中通过shellscript定义一个编译器符号(stm32 workbench)
Define a compiler symbol via shellscript in eclipse (stm32 workbench)
长期以来,我为 stm32f4
处理器的嵌入式系统编写软件。
到目前为止,我使用自己的工具链和自己的 makefile 来构建二进制文件。为了发挥 IDE 的优势,我决定将项目集成到 Eclipse 中(stm32 workbench: eclipse for the stm32 controller)。为了停止拥有自己的工具链,我现在使用集成的 AC6 工具链。
我必须做的大部分事情都运行良好。
我的问题
在我自己的 makefile 中,我有以下条目:
SVNREPREV := $(shell ./svnversion.sh ./inc/ ./Drivers/ ./libs/ ./linkerscripts/ ./makefsdata/ ./src/)
XCFLAGS += -DSVNREPOVERSION=\"$(SVNREPREV)\"
(shell 脚本 returns 类似的值 -> 1234:1234M 它将被转换为字符串)
我可以像这样在我的 C 代码中使用这个值:
const char svnRepoRevision[] = SVNREPOVERSION;
我的问题
如何使用 AC6 工具链和创建的 makefile 在 Eclipse/stm32 workbench 中实现类似的行为?
我的尝试
在项目 -> 属性 -> C/C++ 构建 -> 设置 -> 构建步骤 -> 符号下添加符号
SVNREPREV=$(shell ../svnversion.sh ../inc/ ../Drivers/ ../libs/ ../linkerscripts/ ../makefsdata/ ../src/)
SVNREPOVERSION="SVNREPREV"
构建结束时出现以下错误:
arm-none-eabi-gcc: error: ../src/): No such file or directory
我尝试了不同版本的set the "",但是没有效果,一直报错。
如有任何帮助,我们将不胜感激。
手动
Link 到使用的文档:here
感谢 unwind 给我看这个 link
Solution/Answer
- 在项目根文件夹中创建空 makefile.defs 文件
Right-Click on projectroot folder -> New -> File
- 在 makefile.defs
中写入 svn 修订版所需的命令
SVNREV:='"$(shell ../svnversion.sh ../inc/ ../src/)"'
- 打开c/c++构建设置,符号
Project -> Properties -> C/C++ Build -> Settings -> Build Steps -> MCU GCC Compiler -> Symbols
- 添加代码中使用的符号
Add value SVNREPOVERSION="$(SVNREV)" as Symbol
- 保存项目设置并构建
构建现在工作正常,我收到了我的 svn 修订号。
makefile.defs 被执行一次。这将从使用的文件夹中读取所需的 svnrevisions。该值将写入我在代码中使用的 SVNREPOVERSION。
长期以来,我为 stm32f4
处理器的嵌入式系统编写软件。
到目前为止,我使用自己的工具链和自己的 makefile 来构建二进制文件。为了发挥 IDE 的优势,我决定将项目集成到 Eclipse 中(stm32 workbench: eclipse for the stm32 controller)。为了停止拥有自己的工具链,我现在使用集成的 AC6 工具链。
我必须做的大部分事情都运行良好。
我的问题
在我自己的 makefile 中,我有以下条目:
SVNREPREV := $(shell ./svnversion.sh ./inc/ ./Drivers/ ./libs/ ./linkerscripts/ ./makefsdata/ ./src/)
XCFLAGS += -DSVNREPOVERSION=\"$(SVNREPREV)\"
(shell 脚本 returns 类似的值 -> 1234:1234M 它将被转换为字符串)
我可以像这样在我的 C 代码中使用这个值:
const char svnRepoRevision[] = SVNREPOVERSION;
我的问题
如何使用 AC6 工具链和创建的 makefile 在 Eclipse/stm32 workbench 中实现类似的行为?
我的尝试
在项目 -> 属性 -> C/C++ 构建 -> 设置 -> 构建步骤 -> 符号下添加符号
SVNREPREV=$(shell ../svnversion.sh ../inc/ ../Drivers/ ../libs/ ../linkerscripts/ ../makefsdata/ ../src/)
SVNREPOVERSION="SVNREPREV"
构建结束时出现以下错误:
arm-none-eabi-gcc: error: ../src/): No such file or directory
我尝试了不同版本的set the "",但是没有效果,一直报错。
如有任何帮助,我们将不胜感激。
手动
Link 到使用的文档:here
感谢 unwind 给我看这个 link
Solution/Answer
- 在项目根文件夹中创建空 makefile.defs 文件
Right-Click on projectroot folder -> New -> File
- 在 makefile.defs 中写入 svn 修订版所需的命令
SVNREV:='"$(shell ../svnversion.sh ../inc/ ../src/)"'
- 打开c/c++构建设置,符号
Project -> Properties -> C/C++ Build -> Settings -> Build Steps -> MCU GCC Compiler -> Symbols
- 添加代码中使用的符号
Add value SVNREPOVERSION="$(SVNREV)" as Symbol
- 保存项目设置并构建
构建现在工作正常,我收到了我的 svn 修订号。 makefile.defs 被执行一次。这将从使用的文件夹中读取所需的 svnrevisions。该值将写入我在代码中使用的 SVNREPOVERSION。