sconsti-dsp

scons help for alternate build tools


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'
  ]);

Solution

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