Implement skip for coarse mesh build process

This commit is contained in:
kaetemi 2014-02-08 21:02:24 +01:00
parent a13574ec88
commit 260811ae2a
2 changed files with 107 additions and 36 deletions

View file

@ -327,15 +327,60 @@ def needUpdateDirNoSubdirFile(log, dir_source, file_dest):
else: else:
return 0 return 0
def needUpdateDirNoSubdirMultiFile(log, dir_source, root_file, files_dest):
for file_dest in files_dest:
if needUpdateDirNoSubdirFile(log, dir_source, root_file + "/" + file_dest):
return 1
return 0
def needUpdateDirNoSubdirMultiFileExt(log, dir_source, root_file, files_dest, file_ext):
for file_dest in files_dest:
if needUpdateDirNoSubdirFile(log, dir_source, root_file + "/" + file_dest + file_ext):
return 1
return 0
def needUpdateMultiDirNoSubdirFile(log, root_dir, dirs_source, file_dest): def needUpdateMultiDirNoSubdirFile(log, root_dir, dirs_source, file_dest):
for dir_source in dirs_source: for dir_source in dirs_source:
if needUpdateDirNoSubdirFile(log, root_dir + "/" + dir_source, file_dest): if needUpdateDirNoSubdirFile(log, root_dir + "/" + dir_source, file_dest):
return 1 return 1
return 0 return 0
def needUpdateMultiDirNoSubdirMultiFileExt(log, root_dir, dirs_source, root_file, files_dest, file_ext):
for file_dest in files_dest:
if needUpdateMultiDirNoSubdirFile(log, root_dir, dirs_source, root_file + "/" + file_dest + file_ext):
return 1
return 0
def needUpdateMultiDirNoSubdir(log, root_dir, dirs_source, dir_dest):
for dir_source in dirs_source:
if needUpdateDirNoSubdir(log, root_dir + "/" + dir_source, dir_dest):
return 1
return 0
def needUpdateDirNoSubdirExtFile(log, dir_source, dir_ext, file_dest):
if not os.path.isfile(file_dest):
return 1
destTime = os.stat(file_dest).st_mtime
sourceFiles = os.listdir(dir_source)
for file in sourceFiles:
if file.endswith(dir_ext):
filePath = dir_source + "/" + file
if os.path.isfile(filePath):
fileTime = os.stat(filePath).st_mtime
if fileTime > destTime:
return 1
else:
return 0
def needUpdateDirNoSubdirExtMultiFileExt(log, dir_source, dir_ext, root_file, files_dest, file_ext):
for file_dest in files_dest:
if needUpdateDirNoSubdirExtFile(log, dir_source, dir_ext, root_file + "/" + file_dest + file_ext):
return 1
return 0
def needUpdateDirNoSubdir(log, dir_source, dir_dest): def needUpdateDirNoSubdir(log, dir_source, dir_dest):
latestSourceFile = 0 latestSourceFile = 0
latestDestFile = 0 oldestDestFile = 0
sourceFiles = os.listdir(dir_source) sourceFiles = os.listdir(dir_source)
destFiles = os.listdir(dir_dest) destFiles = os.listdir(dir_dest)
for file in sourceFiles: for file in sourceFiles:
@ -348,9 +393,9 @@ def needUpdateDirNoSubdir(log, dir_source, dir_dest):
filePath = dir_dest + "/" + file filePath = dir_dest + "/" + file
if os.path.isfile(filePath): if os.path.isfile(filePath):
fileTime = os.stat(filePath).st_mtime fileTime = os.stat(filePath).st_mtime
if (fileTime > latestDestFile): if oldestDestFile == 0 or fileTime < oldestDestFile:
latestDestFile = fileTime oldestDestFile = fileTime
if latestSourceFile > latestDestFile: if latestSourceFile > oldestDestFile:
return 1 return 1
else: else:
return 0 return 0

View file

@ -120,39 +120,65 @@ if len(CoarseMeshTextureNames) > 0:
mkPath(log, shapeWithCoarseMesh) mkPath(log, shapeWithCoarseMesh)
shapeWithCoarseMeshBuilded = ExportBuildDirectory + "/" + ShapeWithCoarseMeshBuildDirectory shapeWithCoarseMeshBuilded = ExportBuildDirectory + "/" + ShapeWithCoarseMeshBuildDirectory
mkPath(log, shapeWithCoarseMeshBuilded) mkPath(log, shapeWithCoarseMeshBuilded)
cf = open("config_generated.cfg", "w") # This builds from shapeWithCoarseMesh .shape to shapeWithCoarseMesh .tga
cf.write("texture_mul_size = " + TextureMulSizeValue + ";\n") # And from shapeWithCoarseMesh .shape to shapeWithCoarseMeshBuilded .shape
cf.write("\n") # Then builds from shapeWithCoarseMesh .tga to shapeWithCoarseMeshBuilded .tga
cf.write("search_path = \n") # Depends on MapLookupDirectories
cf.write("{\n") needUpdateMaps = needUpdateMultiDirNoSubdirMultiFileExt(log, ExportBuildDirectory, MapLookupDirectories, shapeWithCoarseMesh, CoarseMeshTextureNames, ".tga") or needUpdateMultiDirNoSubdir(log, ExportBuildDirectory, MapLookupDirectories, shapeWithCoarseMeshBuilded)
cf.write("\t\"" + shapeWithCoarseMesh + "\", \n") if needUpdateMaps:
for dir in MapLookupDirectories: printLog(log, "DETECT UPDATE Maps->*")
cf.write("\t\"" + ExportBuildDirectory + "/" + dir + "\", \n") else:
cf.write("};\n") printLog(log, "DETECT SKIP Maps->*")
cf.write("\n") needUpdateShapeShape = needUpdateDirByTagLog(log, shapeWithCoarseMesh, ".shape", shapeWithCoarseMeshBuilded, ".shape")
cf.write("list_mesh = \n") if needUpdateShapeShape:
cf.write("{\n") printLog(log, "DETECT UPDATE Shape->Shape")
# For each shape with coarse mesh else:
files = findFiles(log, shapeWithCoarseMesh, "", ".shape") printLog(log, "DETECT SKIP Shape->Shape")
for file in files: needUpdateShapeCoarse = needUpdateDirNoSubdirExtMultiFileExt(log, shapeWithCoarseMesh, ".shape", shapeWithCoarseMesh, CoarseMeshTextureNames, ".tga")
sourceFile = shapeWithCoarseMesh + "/" + file if needUpdateShapeCoarse:
if os.path.isfile(sourceFile): printLog(log, "DETECT UPDATE Shape->Coarse")
destFile = shapeWithCoarseMeshBuilded + "/" + file else:
cf.write("\t\"" + file + "\", \"" + destFile + "\", \n") printLog(log, "DETECT SKIP Shape->Coarse")
cf.write("};\n") if needUpdateMaps or needUpdateShapeShape or needUpdateShapeCoarse:
cf.write("\n") cf = open("config_generated.cfg", "w")
cf.write("output_textures = \n") cf.write("texture_mul_size = " + TextureMulSizeValue + ";\n")
cf.write("{\n") cf.write("\n")
# For each shape with coarse mesh cf.write("search_path = \n")
for tn in CoarseMeshTextureNames: cf.write("{\n")
cf.write("\t\"" + shapeWithCoarseMesh + "/" + tn + ".tga\", \n") cf.write("\t\"" + shapeWithCoarseMesh + "\", \n")
cf.write("};\n") for dir in MapLookupDirectories:
cf.close() cf.write("\t\"" + ExportBuildDirectory + "/" + dir + "\", \n")
subprocess.call([ BuildCoarseMesh, "config_generated.cfg" ]) cf.write("};\n")
os.remove("config_generated.cfg") cf.write("\n")
cf.write("list_mesh = \n")
cf.write("{\n")
# For each shape with coarse mesh
files = findFiles(log, shapeWithCoarseMesh, "", ".shape")
for file in files:
sourceFile = shapeWithCoarseMesh + "/" + file
if os.path.isfile(sourceFile):
destFile = shapeWithCoarseMeshBuilded + "/" + file
cf.write("\t\"" + file + "\", \"" + destFile + "\", \n")
cf.write("};\n")
cf.write("\n")
cf.write("output_textures = \n")
cf.write("{\n")
# For each shape with coarse mesh
for tn in CoarseMeshTextureNames:
cf.write("\t\"" + shapeWithCoarseMesh + "/" + tn + ".tga\", \n")
cf.write("};\n")
cf.close()
subprocess.call([ BuildCoarseMesh, "config_generated.cfg" ])
os.remove("config_generated.cfg")
needUpdateCoarse = needUpdateDirNoSubdirExtMultiFileExt(log, shapeWithCoarseMesh, ".tga", shapeWithCoarseMeshBuilded, CoarseMeshTextureNames, ".dds")
if needUpdateCoarse:
printLog(log, "DETECT UPDATE Coarse->DDS")
else:
printLog(log, "DETECT SKIP Coarse->DDS")
# Convert the coarse texture to dds # Convert the coarse texture to dds
for tn in CoarseMeshTextureNames: if needUpdateCoarse:
subprocess.call([ TgaToDds, shapeWithCoarseMesh + "/" + tn + ".tga", "-o", shapeWithCoarseMeshBuilded + "/" + tn + ".dds", "-a", "5" ]) for tn in CoarseMeshTextureNames:
subprocess.call([ TgaToDds, shapeWithCoarseMesh + "/" + tn + ".tga", "-o", shapeWithCoarseMeshBuilded + "/" + tn + ".dds", "-a", "5" ])
else: else:
printLog(log, ">>> No coarse meshes <<<") printLog(log, ">>> No coarse meshes <<<")