scons: overriding build options for one file

Posted by Jason S on Stack Overflow See other posts from Stack Overflow or by Jason S
Published on 2010-01-06T14:41:15Z Indexed on 2011/01/11 9:53 UTC
Read the original article Hit count: 204

Filed under:

Easy question but I don't know the answer.

Let's say I have a scons build where my CCFLAGS includes -O1. I have one file needsOptimization.cpp where I would like to override the -O1 with -O2 instead. How could I do this in scons?


update: this is what I ended up doing based on bialix's answer:

in my SConscript file:

Import('env');

env2 = env.Clone();
env2.Append(CCFLAGS=Split('-O2 --asm_listing'));

sourceFiles = ['main.cpp','pwm3phase.cpp'];
sourceFiles2 = ['serialencoder.cpp','uartTestObject.cpp'];
objectFiles = [];
objectFiles.append(env.Object(sourceFiles));
objectFiles.append(env2.Object(sourceFiles2));
   ...

previously this file was:

Import('env');

sourceFiles = ['main.cpp','pwm3phase.cpp','serialencoder.cpp','uartTestObject.cpp'];
objectFiles = env.Object(sourceFiles);
   ...

© Stack Overflow or respective owner

Related posts about scons