tags:

views:

86

answers:

1

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:\scs\dev\test>type Sconstruct
env = Environment()

env.Command(
    "b.txt", "a.txt",
        [
        r"if exist $TARGET c:\windows\system32\attrib -r $TARGET",
        Copy("$TARGET", "$SOURCE")
        ]
    )

C:\scs\dev\test>echo "test" > a.txt

C:\scs\dev\test>scons -Q b.txt
if exist b.txt c:\windows\system32\attrib -r b.txt
Copy("b.txt", "a.txt")

C:\scs\dev\test>echo "test2" > a.txt

C:\scs\dev\test>attrib +r b.txt

C:\scs\dev\test>scons -Q b.txt
scons: *** [b.txt] C:\scs\dev\test\b.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.

+1  A: 

use NoClean(target) to disable deleting of generated files while running scons -c.

bialix