[Scons-users] Possible Bug in cleaning Aliases

Mark Ribau mribau at realtaentertainment.com
Fri Nov 9 22:19:26 EST 2012


Joined the mailing list just to get help with this possible bug. Hopefully
this list is the correct one to post in for this.

Steps to Reproduce:
Have Aliases that each have multiple targets attached to it.
Some of these individual targets are marked Precious and NoClean.
Build the Aliases
Clean the Aliases

Result:
Cleaning the Alias deletes all the targets, including the targets that are
marked NoClean.
Additionally, some Aliases' targets would NEVER be cleaned AT ALL, even
though they were NOT marked Precious NOR NoClean.

Expected Result:
Cleaning the Alias correctly deletes the targets NOT marked as NoClean.

I changed some code in SCons/Script/Main.py that appears to fix it though:

Diff:
346,348c346,347
< target = self.targets[0]
< if (target.has_builder() or target.side_effect) and not
target.noclean:
< for t in self.targets:
---

> for t in self.targets:

> if (t.has_builder() or t.side_effect) and not t.noclean:

361,364c360,363
< if target in SCons.Environment.CleanTargets:
< files = SCons.Environment.CleanTargets[target]
< for f in files:
< self.fs_delete(f.abspath, str(f))
---

> if t in SCons.Environment.CleanTargets:

> files = SCons.Environment.CleanTargets[t]

> for f in files:

> self.fs_delete(f.abspath, str(f))



Including all the code to make it easier:

Old Version:
def remove(self):
target = self.targets[0]
if (target.has_builder() or target.side_effect) and not
target.noclean:
for t in self.targets:
try:
removed = t.remove()
except OSError, e:
# An OSError may indicate something like a permissions
# issue, an IOError would indicate something like
# the file not existing. In either case, print a
# message and keep going to try to remove as many
# targets aa possible.
print "scons: Could not remove '%s':" % str(t),
e.strerror
else:
if removed:
display("Removed " + str(t))
if target in SCons.Environment.CleanTargets:
files = SCons.Environment.CleanTargets[target]
for f in files:
self.fs_delete(f.abspath, str(f))

New Version:
def remove(self):
for t in self.targets:
if (t.has_builder() or t.side_effect) and not t.noclean:
try:
removed = t.remove()
except OSError, e:
# An OSError may indicate something like a permissions
# issue, an IOError would indicate something like
# the file not existing. In either case, print a
# message and keep going to try to remove as many
# targets aa possible.
print "scons: Could not remove '%s':" % str(t),
e.strerror
else:
if removed:
display("Removed " + str(t))
if t in SCons.Environment.CleanTargets:
files = SCons.Environment.CleanTargets[t]
for f in files:
self.fs_delete(f.abspath, str(f))

*
*
*
*
----
*mark ribau*
*software engineer
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20121109/e8498582/attachment.htm>


More information about the Scons-users mailing list