开发者

How to generate a specific CPPDEFINE such as -DOEM="FOO BAR" using Scons

My intention is to end up with a compiler command line including -DOEM="FOO BAR"

I have the following in my SConstruct file:

opts = Options( 'overrides.py', ARGUMENTS )
opts.Add( 'OEM_NAME', 'Any string can be used here', 'UNDEFINED' )
.
.
.
if (env.Dictionary('OEM_NAME') != 'UNDEFINED'):  
    OEM_DEFINE = 'OEM=' + str(env.Dictionary('OEM_NAME'))
    env.Append( CPPDEFINES=[ OEM_DEFINE ] )

Then I put the following in the "overrides.py" file:

OEM_NAME = "FOO BAR"

I seem to end up with "-DOEM=FOO BAR" in the command line that gets generated. Can so开发者_StackOverflow社区meone point me in the right direction? Thanks.


CPPDEFINES can be a dictionary (the scons user guide has an example). I couldn't figure out a way to get rid of the surrounding quotes, so I had to double escape quotes around the string:

env = Environment(CPPDEFINES = {'OEM': '\\"FOO BAR\\"'})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜