There are 3 ways to specify the SConstruct file when using SCons, as follows:
Execute scons
from the root of the project, where there should be a SConstruct file. This is the most standard way.
From a subdirectory of the project, where there should be a SConsctruct file at the root, execute scons
with one of the following options (as seen by scons -h) to tell it to look up the directory structure for the SConstruct
-u, --up, --search-up
Search up directory tree for SConstruct, build targets at or
below current directory.
-U
Search up directory tree for SConstruct, build Default() targets
from local SConscript.
- Explicitly specify where the SConstruct file is, this is also available from
scons -h
-f FILE, --file=FILE, --makefile=FILE, --sconstruct=FILE
Read FILE as the top-level SConstruct file.
Here is an example project in the directory /home/notroot/projectDir
with the following directory structure:
SConstruct
subdir/file.hh
subdir/file.cc
Here is how to use the different options mentioned above:
Option 1:
Execute scons from the root project directory
# cd /home/notroot/projectDir
# scons
Option 2:
Execute scons from within the project directory and tell it to look up the dir hierarchy for the SConstruct
# cd /home/notroot/projectDir/subdir
# scons -u
Option 3:
Execute scons from within the project directory and specify the path of the SConstruct
# cd /home/notroot/projectDir/subdir
# scons -f /home/notroot/projectDir/SConstruct
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…