0

My main goal is to add support of -isystem include paths in scons, like this is proposed here : https://stackoverflow.com/a/2547261/4042960

The solution of creating new variables works fine: I do that:

#### Add support for system headers
env['SYSTEMINCPREFIX'] = '-isystem '
env['SYSTEMINCSUFFIX'] = ''
env['_CPPSYSTEMINCFLAGS'] = '$( ${_concat(SYSTEMINCPREFIX, CPPSYSTEMPATH, SYSTEMINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
env['_CCCOMCOM'] += ' $_CPPSYSTEMINCFLAGS'

I use it by adding for instance:

env.Append(CPPSYSTEMPATH = ['/my/include/path'])

My problem is that now, the path /my/include/path is not scanned by the C (or C++) dependency scanner. After many search, I failed to find how to add my variable "CPPSYSTEMPATH" to be treated like "CPPPATH" by the dependency scanner.

Does anyone know how I could add the search path contained in "CPPSYSTEMPATH" to the existing C scanner ?

I hope that my problem is clear enough, else do not hesitate to tell me.

Community
  • 1
  • 1
merovingien
  • 319
  • 2
  • 9

1 Answers1

0

Here's a basic recipe for replacing the FindPath method of the default C scanner, but be warned it's an ugly hack:

# Create environment
env = Environment()
# Define your new env variable as combination of both paths
env['MYCPPPATHS'] = ['$CPPPATH','$CPPSYSTEMPATH']

# Replace the path_function of the standard C scanner by:
import SCons.Tool
import SCons.Scanner
setattr(SCons.Tool.CScanner,'path_function',SCons.Scanner.FindPathDirs('MYCPPPATHS'))

# Do your build stuff...
env['CPPSYSTEMPATH'] = 'myinclude'
env.Program('main','main.cpp')

By the way, why not ask these kind of questions on our user mailing list scons-users@scons.org? ;)

dirkbaechle
  • 3,984
  • 14
  • 17
  • You're welcome. By the way, would you be able and willing to contribute your Tool/Builder back to the SCons project? There seems to be an increasing interest in support for "-isystem", and maybe we could get this into the core together. Thanks a lot in advance for taking this into consideration... – dirkbaechle Sep 28 '14 at 08:43
  • Thank you for this proposition, I would be please to bring my little contribution to the SCons project. I never participate to a community project so I do not know the good entry point, but I am ready to learn. I will really appreciate all the help you will be able to give me to add this feature in SCons. – merovingien Oct 07 '14 at 08:12
  • Sure, a good entry point would be to write (and subscribe to) our user mailing list at scons-users@scons.org ( links to the different MLs can be found on our website http://www.scons.org ). Just say "Hi" and make it clear that you have a contribution to make, and then we'll take it from there. I'm looking forward to hearing from you... – dirkbaechle Oct 08 '14 at 07:08