[Scons-dev] Bug in env.Glob() - how do I report?
Dirk Bächle
tshortik at gmx.de
Wed Dec 17 08:06:02 EST 2014
Vasily,
On 15.12.2014 20:35, Vasily wrote:
> Hi Dirk,
>
> Thanks for the reply!
>
> I get this running the SConstruct I attached:
>
> $> scons .
> scons: Reading SConscript files ...
> TypeError: Tried to lookup Dir 'some_entry' as a File.:
> File "C:\Vass\Work\Temp\scons_glob_bug\SConstruct", line 22:
> d2[0].srcnode()
> File "C:\Python27\scons-2.1.0\SCons\Node\FS.py", line 743:
> srcnode.must_be_same(self.__class__)
> File "C:\Python27\scons-2.1.0\SCons\Node\FS.py", line 626:
> (self.__class__.__name__, self.path, klass.__name__))
>
> Note: I've checked it agains SCons 2.1.0 (pretty old, but that's what we use internally right now, maybe it's already fixed?..)
>
I had another look and I tested your example with the latest SCons 2.3.4 and 2.1.0 as well. Both times I get the cyclic dependency
error...
This seems to be logical to me, because of the following line:
d1 = variant_exec(env1, 'var1', env1.Command, 'some_entry', 'some_entry', Mkdir("$TARGET"))
, where you specify "some_entry" as target *and* source for the Mkdir().
You don't need to do this, setting the source to [] (empty list) should work fine.
After this change I was finally able to reproduce your error output: the problem is not so much in the Glob itself, but in the fact
that you're trying to handle directories but aren't telling SCons so. As a default, SCons assumes that simple strings (like the ones
returned from the Glob call) refer to file type entries. So, if a folder "some_entry" exists, but the Glob() returns a "some_entry"
these two collide. For resolving this you have to explicitly convert the list of globbed strings to Dir nodes...find an example
SConstruct attached.
I hope this explains things and helps you further.
Regards,
Dirk
-------------- next part --------------
def variant_exec(env, variant_dir, func, *args, **kw):
oldwd = env.fs.getcwd()
env.VariantDir(variant_dir, '.', duplicate=0)
env.fs.chdir(env1.Dir(variant_dir))
try:
return func(*args, **kw)
finally:
env.fs.chdir(oldwd)
env1 = DefaultEnvironment()
env2 = env1.Clone()
d1 = variant_exec(env1, 'var1', env1.Command, env1.Dir('some_entry'), [], Mkdir("$TARGET"))
d1[0].srcnode()
def DirGlob(env, pattern):
return env.Dir(env.Glob(pattern))
d2 = variant_exec(env2, 'var2', DirGlob, env2, '*_entry')
d1[0].disambiguate()
d1[0].srcnode()
d2[0].disambiguate()
d2[0].srcnode()
More information about the Scons-dev
mailing list