“ TypeError:试图将Dir'...'作为文件查找。”在scons variant_dir构建中

时间:2019-06-18 11:46:06

标签: scons

我正在使用scons进行分层的多变量构建。对于名为“ lib”的库,通用源在src/lib下,而特定于变量的源在src/lib/variant下。 (例如,在Linux计算机上,src/lib/linux。)如果没有特定变体的特定于变体的代码,则该目录可能不存在。当我的设置使用Progress()函数进行打印时,因为每个文件都被scons评估,它会引发TypeError告诉我TypeError: Tried to lookup Dir 'src/lib/subdir_1' as a File.

我在Ubuntu上有scons版本3.0.1-1。我的默认python是2.7.16。

我无法弄清楚到底是什么原因导致scons为不存在的目录src/lib/subdir_1创建一个File节点,但是要重现错误,我确实需要包含$TARGETProgress()调用中。从环境中删除src_subdirs可以消除错误,就像只构建一个变体一样。此外,似乎也需要Glob()函数才能使错误再现。

我的复制案例有三个文件(在这个最小的示例中没有实际来源,只有scons文件和包含它们的目录):

SConstruct:

base_env = Environment()
Progress('Evaluating $TARGET\n')

env = base_env.Clone(src_subdirs = ['subdir_1'])
Export('env')
SConscript('src/SConscript', variant_dir = 'build/variant_1', duplicate = 0)

env = base_env.Clone(src_subdirs = ['subdir_2'])
Export('env')
SConscript('src/SConscript', variant_dir = 'build/variant_2', duplicate = 0)

src / SConscript:

SConscript(Glob('*/SConscript'))

src / lib / SConscript:

Import('env')

src = []
src_subdirs = env['src_subdirs']
for s in src_subdirs:
    src += env.Glob(s + '/*.c')

完整的错误消息:

$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
Evaluating SConstruct
Evaluating src/SConscript
Evaluating src/lib/SConscript
Evaluating build/variant_1/lib/subdir_1
Evaluating build/variant_1/lib
Evaluating build/variant_1
Evaluating src/SConscript
Evaluating src/lib/SConscript
scons: done building targets.
TypeError: Tried to lookup Dir 'src/lib/subdir_1' as a File.:
  File "/usr/lib/scons/SCons/Script/Main.py", line 1376:
    _exec_main(parser, values)
  File "/usr/lib/scons/SCons/Script/Main.py", line 1339:
    _main(parser)
  File "/usr/lib/scons/SCons/Script/Main.py", line 1103:
    nodes = _build_targets(fs, options, targets, target_top)
  File "/usr/lib/scons/SCons/Script/Main.py", line 1313:
    jobs.run(postfunc = jobs_postfunc)
  File "/usr/lib/scons/SCons/Job.py", line 111:
    self.job.start()
  File "/usr/lib/scons/SCons/Job.py", line 227:
    task.failed()
  File "/usr/lib/scons/SCons/Script/Main.py", line 271:
    nodename = ', '.join(map(str, node))
  File "/usr/lib/scons/SCons/Node/FS.py", line 639:
    return self._save_str()
  File "/usr/lib/scons/SCons/Node/FS.py", line 652:
    result = SCons.Util.silent_intern(self._get_str())
  File "/usr/lib/scons/SCons/Node/FS.py", line 660:
    srcnode = self.srcnode()
  File "/usr/lib/scons/SCons/Node/FS.py", line 742:
    srcnode.must_be_same(self.__class__)
  File "/usr/lib/scons/SCons/Node/FS.py", line 602:
    (self.__class__.__name__, self.get_internal_path(), klass.__name__))

如您所见,它在错误发生时已经完成了对我的代码的解析。大概是在SConscript解析过程中出现了一些问题,但是由于它没有指向我的代码,因此我很难猜测如何解决它。

0 个答案:

没有答案