scons 帮助替代构建工具

发布于 2024-08-02 07:30:32 字数 1886 浏览 2 评论 0原文

我正在使用 TI DSP 的编译器,因此默认的 CC、LINK 和 AS 工具没有任何意义。下面是一个适合我的 SConstruct 文件,我想知道是否有人有建议让它变得更好。一些问题:

  1. 我想以某种方式告诉它我的 .obj 文件应该位于与源 .c 文件不同的目录中。 (它需要知道在哪里,以便找出链接步骤的源,以及编译/链接的依赖项)最好将其与编译器的“-fr”和“-fs”参数结合起来,但我不介意手动执行此操作。
  2. 下面的 SConstruct 文件中有一些常用的 C 文件,全部以 DSP2804x_ 前缀开头。现在 scons 无法找出这些的依赖关系,因为我猜它期望 .obj 文件位于同一目录中,而我对编译器使用的“-fr”和“-fs”意味着这些 .obj 文件最终位于与 SConstruct 文件相同的目录中。有一个更好的方法吗?我猜我可能应该有一个构建步骤,将这些参考文件复制到本地目录中:如果我更改它们,我希望这些更改传播到使用它们的所有项目。

叹....

env = Environment(
   CC = 'C:/appl/ti/ccs/3.3/C2000/cgtools/bin/cl2000',
   CCCOM = '$CC $CFLAGS $CCFLAGS $SOURCES',
   CCFLAGS = Split('-g -q -pdr -d"_DEBUG" -d"LARGE_MODEL" -ml -mt -v28'),

   LINKCOM = '$LINK $LINKFLAGS ${SOURCES.file} -o ${TARGET.base}.out',
   LINK = 'C:/appl/ti/ccs/3.3/C2000/cgtools/bin/cl2000',
   LINKFLAGS = Split('-z -q -c -ecode_start -stack0x200 -w -x'),

   ASCOM = '$CC $CFLAGS $CCFLAGS $SOURCES',
#Bizarre but true. assembly is just like compiling C.
   );


includes = {'CCFLAGS' : [
  '-i../common/headers/include',
  '-i../common/include',
  '-fr.',
  '-fs.'
  ]};
env.MergeFlags(includes);

links = {'LINKFLAGS' : [
  '-m./Debug/Example_2804xGpioToggle.map',
  '-i../common/headers/include', 
  '-iC:/appl/ti/ccs/3.3/C2000/xdais/lib',
  '-iC:/appl/ti/ccs/3.3/C2000/cgtools/lib', 
  '-lrts2800_ml.lib',
  '../common/cmd/28044_RAM_lnk.cmd',
  '../common/headers/cmd/DSP2804x_Headers_nonBIOS.cmd'
  ]};
env.MergeFlags(links);

print "CCCOM is:", env['CCCOM'], "\n", env['LINKCOM'], '\n', env['ASCOM'];

env.Program('blink_gpio', [
  'Example_2804xGpioToggle.c',
  '../common/headers/source/DSP2804x_GlobalVariableDefs.c',
  '../common/source/DSP2804x_CodeStartBranch.asm',
  '../common/source/DSP2804x_DefaultIsr.c',
  '../common/source/DSP2804x_PieCtrl.c',
  '../common/source/DSP2804x_PieVect.c',
  '../common/source/DSP2804x_SysCtrl.c'
  ]);

I'm using a compiler for TI DSPs, so the default CC and LINK and AS tools make no sense. Below is an SConstruct file that works for me, I'm wondering if anyone has suggestions to make it better. Some problems:

  1. I'd like to somehow tell it that my .obj files should go in a different directory than the source .c files. (it needs to know where, in order to figure out the SOURCES for the link step, and the dependencies for compile/linking) It would be nice to tie this in with the "-fr" and "-fs" arguments to the compiler, but I don't mind doing that manually.
  2. There are some stock C files in the SConstruct file below, all start with a prefix of DSP2804x_. Right now scons can't figure out the dependencies for these, because I guess it's expecting the .obj files to live in the same directory, whereas my use of "-fr" and "-fs" for the compiler means those .obj files end up in the same directory as the SConstruct file. Is there a better way to do this? I'm guessing I should probably have a build step that copies these reference files into a local directory: if I change them, I want the changes to propagate to all projects that use them.

sigh....

env = Environment(
   CC = 'C:/appl/ti/ccs/3.3/C2000/cgtools/bin/cl2000',
   CCCOM = '$CC $CFLAGS $CCFLAGS $SOURCES',
   CCFLAGS = Split('-g -q -pdr -d"_DEBUG" -d"LARGE_MODEL" -ml -mt -v28'),

   LINKCOM = '$LINK $LINKFLAGS ${SOURCES.file} -o ${TARGET.base}.out',
   LINK = 'C:/appl/ti/ccs/3.3/C2000/cgtools/bin/cl2000',
   LINKFLAGS = Split('-z -q -c -ecode_start -stack0x200 -w -x'),

   ASCOM = '$CC $CFLAGS $CCFLAGS $SOURCES',
#Bizarre but true. assembly is just like compiling C.
   );


includes = {'CCFLAGS' : [
  '-i../common/headers/include',
  '-i../common/include',
  '-fr.',
  '-fs.'
  ]};
env.MergeFlags(includes);

links = {'LINKFLAGS' : [
  '-m./Debug/Example_2804xGpioToggle.map',
  '-i../common/headers/include', 
  '-iC:/appl/ti/ccs/3.3/C2000/xdais/lib',
  '-iC:/appl/ti/ccs/3.3/C2000/cgtools/lib', 
  '-lrts2800_ml.lib',
  '../common/cmd/28044_RAM_lnk.cmd',
  '../common/headers/cmd/DSP2804x_Headers_nonBIOS.cmd'
  ]};
env.MergeFlags(links);

print "CCCOM is:", env['CCCOM'], "\n", env['LINKCOM'], '\n', env['ASCOM'];

env.Program('blink_gpio', [
  'Example_2804xGpioToggle.c',
  '../common/headers/source/DSP2804x_GlobalVariableDefs.c',
  '../common/source/DSP2804x_CodeStartBranch.asm',
  '../common/source/DSP2804x_DefaultIsr.c',
  '../common/source/DSP2804x_PieCtrl.c',
  '../common/source/DSP2804x_PieVect.c',
  '../common/source/DSP2804x_SysCtrl.c'
  ]);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情定在深秋 2024-08-09 07:30:32

我通过执行 分层构建 解决了这两个问题在我的编译器标志中使用 -fr=${TARGET.dir}

I solved both problems by doing a hierarchical build and using -fr=${TARGET.dir} in my compiler flags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文