scons: improve parsing CUSTOM_LDFLAGS
With the help of SCons.Environment.ParseFlags, split user-supplied CUSTOM_LDFLAGS into appropriate option lists: LIBPATH, LIBS, etc. Known non-linker options (like -Dx -I.) will be reported and ignored, unrecognized options will be appended to LINKFLAGS.
This commit is contained in:
parent
3dee9b634f
commit
6f4c15d077
1 changed files with 18 additions and 1 deletions
19
SConstruct
19
SConstruct
|
@ -495,6 +495,7 @@ pickle_store = [# Scons internal variables
|
||||||
'LIBPATH',
|
'LIBPATH',
|
||||||
'LIBS',
|
'LIBS',
|
||||||
'LINKFLAGS',
|
'LINKFLAGS',
|
||||||
|
'RPATH',
|
||||||
'CUSTOM_LDFLAGS', # user submitted
|
'CUSTOM_LDFLAGS', # user submitted
|
||||||
'CUSTOM_DEFINES', # user submitted
|
'CUSTOM_DEFINES', # user submitted
|
||||||
'CUSTOM_CXXFLAGS', # user submitted
|
'CUSTOM_CXXFLAGS', # user submitted
|
||||||
|
@ -1420,7 +1421,23 @@ if not preconfigured:
|
||||||
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
|
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
|
||||||
env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
|
env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
|
||||||
env.Append(LINKFLAGS = DEFAULT_CXX14_LINKFLAGS)
|
env.Append(LINKFLAGS = DEFAULT_CXX14_LINKFLAGS)
|
||||||
env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS'])
|
|
||||||
|
custom_ldflags = env.ParseFlags(env['CUSTOM_LDFLAGS'])
|
||||||
|
# ParseFlags puts everything it does not recognize into CCFLAGS,
|
||||||
|
# but let's assume the user knows better, put those in LINKFLAGS
|
||||||
|
env.Append(LINKFLAGS = custom_ldflags.pop('CCFLAGS'))
|
||||||
|
env.Append(LINKFLAGS = custom_ldflags.pop('LINKFLAGS'),
|
||||||
|
LIBS = custom_ldflags.pop('LIBS'))
|
||||||
|
env.AppendUnique(FRAMEWORKS = custom_ldflags.pop('FRAMEWORKS'),
|
||||||
|
LIBPATH = custom_ldflags.pop('LIBPATH'),
|
||||||
|
RPATH = custom_ldflags.pop('RPATH'))
|
||||||
|
|
||||||
|
invalid_ldflags = {k:v for k,v in custom_ldflags.items() if v}
|
||||||
|
if invalid_ldflags:
|
||||||
|
color_print(3, 'Warning: CUSTOM_LDFLAGS contained some flags that SCons recognized as not for linker.')
|
||||||
|
color_print(3, 'The following flags will be ignored:')
|
||||||
|
for key, value in invalid_ldflags.items():
|
||||||
|
color_print(3, '\t%s = %r' % (key, value))
|
||||||
|
|
||||||
### platform specific bits
|
### platform specific bits
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue