Python SCons- *** 未找到 SConstruct 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17182799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SCons- *** No SConstruct file found
提问by user2439278
Installed SCons using # cd scons-2.3.0 # python setup.py install
使用 # cd scons-2.3.0 # python setup.py install 安装 SCons
After Installation, when i try to run scons , got the below error.
安装后,当我尝试运行 scons 时,出现以下错误。
scons: *No SConstruct file found. File "/usr/local/lib/scons-2.3.0/SCons/Script/Main.py", line 905, in _main
scons: * 未找到 SConstruct 文件。文件“/usr/local/lib/scons-2.3.0/SCons/Script/Main.py”,第 905 行,在 _main
How to overcome this ???
如何克服这个???
回答by Brady
There are 3 ways to specify the SConstruct file when using SCons, as follows:
使用SCons时有3种方式指定SConstruct文件,如下:
Execute
sconsfrom 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
sconswith one of the following options (as seen by scons -h) to tell it to look up the directory structure for the SConstruct
scons从项目的根目录执行,这里应该有一个 SConstruct 文件。这是最标准的方式。从项目的子目录中,在根目录下应该有一个 SConsctruct 文件,
scons使用以下选项之一(如 scons -h 所见)执行以告诉它查找 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.
-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
- 显式指定 SConstruct 文件的位置,这也可以从
scons -h
-f FILE, --file=FILE, --makefile=FILE, --sconstruct=FILE Read FILE as the top-level SConstruct file.
-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/projectDirwith the following directory structure:
这是目录中的示例项目,其/home/notroot/projectDir目录结构如下:
SConstruct
subdir/file.hh
subdir/file.cc
Here is how to use the different options mentioned above:
以下是如何使用上述不同选项:
Option 1:
选项1:
Execute scons from the root project directory
从项目根目录执行 scons
# cd /home/notroot/projectDir
# scons
Option 2:
选项 2:
Execute scons from within the project directory and tell it to look up the dir hierarchy for the SConstruct
从项目目录中执行 scons 并告诉它查找 SConstruct 的目录层次结构
# cd /home/notroot/projectDir/subdir
# scons -u
Option 3:
选项 3:
Execute scons from within the project directory and specify the path of the SConstruct
从项目目录中执行 scons 并指定 SConstruct 的路径
# cd /home/notroot/projectDir/subdir
# scons -f /home/notroot/projectDir/SConstruct

