How to create 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"

My SConstruct file has the following:

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"

It seems that I ended up with "-DOEM = FOO BAR" on the command line that is being generated. Can someone point me in the right direction? Thank.

+3
source share
1 answer

CPPDEFINES can be a dictionary (user manual scons example ). I couldn't figure out how to get rid of the surrounding quotes, so I had to double the escape quotes around the line:

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

Source: https://habr.com/ru/post/1743075/


All Articles