Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-09-12 20:56:11 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-09-12 20:56:37 +0400
commitbd671f10055b86a6a2a114f8e323414823ce18d2 (patch)
treedae25b5b87f9c75a9ceaa9540ffe0f159b46134d /SConstruct
parentd939341b65b073b8bfdc73b55d2893b77b93fc62 (diff)
Fix scons leaving partially generated files when aborting
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct62
1 files changed, 36 insertions, 26 deletions
diff --git a/SConstruct b/SConstruct
index d1d0db909ad..1ff984ab7e1 100644
--- a/SConstruct
+++ b/SConstruct
@@ -627,31 +627,36 @@ def data_to_c(FILE_FROM, FILE_TO, VAR_NAME):
FILE_FROM = FILE_FROM.replace("/", "\\")
FILE_TO = FILE_TO.replace("/", "\\")
- # first check if we need to bother.
- if os.path.exists(FILE_TO):
- if os.path.getmtime(FILE_FROM) < os.path.getmtime(FILE_TO):
- return
-
- print(B.bc.HEADER + "Generating: " + B.bc.ENDC + "%r" % os.path.basename(FILE_TO))
- fpin = open(FILE_FROM, "rb")
- fpin.seek(0, os.SEEK_END)
- size = fpin.tell()
- fpin.seek(0)
-
- fpout = open(FILE_TO, "w")
- fpout.write("int %s_size = %d;\n" % (VAR_NAME, size))
- fpout.write("char %s[] = {\n" % VAR_NAME)
-
- while size > 0:
- size -= 1
- if size % 32 == 31:
- fpout.write("\n")
-
- fpout.write("%3d," % ord(fpin.read(1)))
- fpout.write("\n 0};\n\n")
-
- fpin.close()
- fpout.close()
+ try:
+ # first check if we need to bother.
+ if os.path.exists(FILE_TO):
+ if os.path.getmtime(FILE_FROM) < os.path.getmtime(FILE_TO):
+ return
+
+ print(B.bc.HEADER + "Generating: " + B.bc.ENDC + "%r" % os.path.basename(FILE_TO))
+ fpin = open(FILE_FROM, "rb")
+ fpin.seek(0, os.SEEK_END)
+ size = fpin.tell()
+ fpin.seek(0)
+
+ fpout = open(FILE_TO, "w")
+ fpout.write("int %s_size = %d;\n" % (VAR_NAME, size))
+ fpout.write("char %s[] = {\n" % VAR_NAME)
+
+ while size > 0:
+ size -= 1
+ if size % 32 == 31:
+ fpout.write("\n")
+
+ fpout.write("%3d," % ord(fpin.read(1)))
+ fpout.write("\n 0};\n\n")
+
+ fpin.close()
+ fpout.close()
+ except KeyboardInterrupt:
+ if os.path.exists(FILE_TO):
+ os.remove(FILE_TO)
+ raise KeyboardInterrupt
def data_to_c_simple(FILE_FROM):
filename_only = os.path.basename(FILE_FROM)
@@ -676,7 +681,12 @@ def data_to_c_simple_icon(PATH_FROM):
FILE_TO_PNG = os.path.join(env['DATA_SOURCES'], filename_only + ".png")
FILE_TO = FILE_TO_PNG + ".c"
argv = [PATH_FROM, FILE_TO_PNG]
- datatoc_icon.main_ex(argv)
+ try:
+ datatoc_icon.main_ex(argv)
+ except KeyboardInterrupt:
+ if os.path.exists(FILE_TO_PNG):
+ os.remove(FILE_TO_PNG)
+ raise KeyboardInterrupt
# then the png to a c file
data_to_c_simple(FILE_TO_PNG)