Skip to content

Instantly share code, notes, and snippets.

@dbach
Created December 2, 2010 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbach/725835 to your computer and use it in GitHub Desktop.
Save dbach/725835 to your computer and use it in GitHub Desktop.
sample scons source
driver_sources = [ ... ]
# original
#d = [env.Object(src, src) for src in driver_sources]
#env.Library(d)
# my comments:
# env.Object(src, src) is weird because you're using the same name
# for source and target.
# I prefer just to let scons sort out the object names:
env.Library('libdriver', driver_sources)
env_flag = env.Clone()
env_flag.Append(CPPDEFINES = ['FLAG'])
# in the new env, we can't let scons sort out the object names itself
# because that causes name conflicts
# the original solution ends up with weird object names
#d_wf = [env_flag.Object(src + '.flag', src) for src in driver_sources]
#env_flag.Library(d_wf)
# I ended up with the following:
# first generate a list of object names
flag_objects = [os.path.splitext(src)[0] + '_flag' + env['OBJSUFFIX'] for src in driver_sources]
# now tell scons how to make the objects
d_wf = [env_flag.Object(tgt, src) for tgt,src in zip(flag_objects, driver_sources)]
env_flag.Library(d_wf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment