Unlink symlink before re-creating

This commit is contained in:
rdb 2014-05-28 15:55:18 +00:00
parent 7785426d2c
commit 3d5118d406

View File

@ -2328,15 +2328,20 @@ def SetupBuildEnvironment(compiler):
########################################################################
def CopyFile(dstfile, srcfile):
if (dstfile[-1]=='/'):
if dstfile[-1] == '/':
dstdir = dstfile
fnl = srcfile.rfind("/")
if (fnl < 0): fn = srcfile
else: fn = srcfile[fnl+1:]
if fnl < 0:
fn = srcfile
else:
fn = srcfile[fnl+1:]
dstfile = dstdir + fn
if NeedsBuild([dstfile], [srcfile]):
if os.path.islink(srcfile):
# Preserve symlinks
if os.path.exists(dstfile):
os.unlink(dstfile)
os.symlink(os.readlink(srcfile), dstfile)
else:
WriteBinaryFile(dstfile, ReadBinaryFile(srcfile))