Removing the old preprocessed resource, if any

If during an earlier build a resource was symlinked in the build
directory (because it wasn't modified by preprocessing) and later
changes are made to the resource that result in its preprocessing no
longer being a no-op, then the preprocessing is performed (in place) on
the original resource directly (via the symlink). Therefore any symlinks
must be removed before preprocessing a resource.
This commit is contained in:
Veloman Yunkan 2022-02-27 20:25:41 +04:00
parent c016dfd2ce
commit 707df3d10b
1 changed files with 2 additions and 0 deletions

View File

@ -88,6 +88,8 @@ def preprocess_resource(srcdir, resource_path, outdir):
os.makedirs(os.path.join(outdir, resource_dir), exist_ok=True) os.makedirs(os.path.join(outdir, resource_dir), exist_ok=True)
srcpath = os.path.join(srcdir, resource_path) srcpath = os.path.join(srcdir, resource_path)
outpath = os.path.join(outdir, resource_path) outpath = os.path.join(outdir, resource_path)
if os.path.exists(outpath):
os.remove(outpath)
preprocessed_content, modified_line_count = get_preprocessed_resource(srcpath) preprocessed_content, modified_line_count = get_preprocessed_resource(srcpath)
if modified_line_count == 0: if modified_line_count == 0:
symlink_resource(srcpath, outpath) symlink_resource(srcpath, outpath)