I m trying to put together a debug build of a particularly difficult project layout. One of the things I need to do is to copy recently built DLLs over existing DLLs that are under Source Safe s control, and are therefore read-only. I was hoping to use Scons to manage this, but Scons errors out if your target is read-only. Part of my command is to set it to readable, but my command never executes because scons errors out first. Is there anyway to override this behavior?
Here s a demonstration. As you can see, my "turn off the read-only bit" command never gets run if the read-only bit is set:
C:scsdev est>type Sconstruct
env = Environment()
env.Command(
"b.txt", "a.txt",
[
r"if exist $TARGET c:windowssystem32attrib -r $TARGET",
Copy("$TARGET", "$SOURCE")
]
)
C:scsdev est>echo "test" > a.txt
C:scsdev est>scons -Q b.txt
if exist b.txt c:windowssystem32attrib -r b.txt
Copy("b.txt", "a.txt")
C:scsdev est>echo "test2" > a.txt
C:scsdev est>attrib +r b.txt
C:scsdev est>scons -Q b.txt
scons: *** [b.txt] C:scsdev est.txt: Access is denied
Update
OK - I ve figured this out by stepping though Scons as it was running. Looks like Scons deletes targets before building them (see _rmv_existing
in FS.py, also this page in the scons documentation page). If you encounter this problem, you can mark the target as "Precious", but you ll still have trouble if you use "-c".
No real good solution here. Oh well.