Ryan Haining
Ryan Haining

Reputation: 36782

scons check for available file without caching result

I'm trying to use scons functions to detect if a specific header file is available. Given a file main.cpp with a #include "fns.h". I've created this:

env = Environment(CXXFLAGS='-I.')
conf = Configure(env)
if not conf.CheckCXXHeader('fns.h'):
    print 'please get fns.h'
    Exit(1)

env.Program('main.cpp')

The first time I run it, it actually checks for the header, but after that it always uses the cached result

$ scons
scons: Reading SConscript files ...
Checking for C++ header file fns.h... no
please get fns.h

$ touch fns.h
$ scons
scons: Reading SConscript files ...
Checking for C++ header file fns.h... yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -I. main.cpp
g++ -o main main.o
scons: done building targets.

$ rm fns.h # delete it
$ scons # should check again here, but doesn't
scons: Reading SConscript files ...
Checking for C++ header file fns.h... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -I. main.cpp
main.cpp:1:17: fatal error: fns.h: No such file or directory
 #include "fns.h"

Upvotes: 0

Views: 141

Answers (1)

dirkbaechle
dirkbaechle

Reputation: 4052

Please check the SCons manual (man scons), the command-line option you're looking for is "--config=force". You can also make it the default behavior for your build by setting the config option in an SConscript file:

SetOption('config', 'force')

Upvotes: 1

Related Questions