Updated stc
This commit is contained in:
@@ -157,13 +157,16 @@ def compile():
|
|||||||
print(f"Output directory: {output_directory}")
|
print(f"Output directory: {output_directory}")
|
||||||
|
|
||||||
last_file = ""
|
last_file = ""
|
||||||
|
last_dir = ""
|
||||||
|
|
||||||
# Ensure output directory exists
|
# Ensure output directory exists
|
||||||
os.makedirs(output_directory, exist_ok=True)
|
os.makedirs(output_directory, exist_ok=True)
|
||||||
|
|
||||||
try:
|
|
||||||
# Iterate over all .frag files in the source directory
|
# Iterate over all .frag files in the source directory
|
||||||
for root, dirs, files in os.walk(source_directory):
|
for root, dirs, files in os.walk(source_directory):
|
||||||
|
try:
|
||||||
|
last_dir = root
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith('.frag') and not file == 'Common.frag':
|
if file.endswith('.frag') and not file == 'Common.frag':
|
||||||
last_file = file
|
last_file = file
|
||||||
@@ -212,16 +215,21 @@ def compile():
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# If the command failed, do not delete the source file
|
# If the command failed, do not delete the source file
|
||||||
print(f"Compiling failed for: {last_file}")
|
print(f"Compiling failed for: {last_file}")
|
||||||
sys.exit(1)
|
print(f"Deleting: {last_dir}")
|
||||||
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f"Error: Directory '{args.input}' not found")
|
print(f"Error: Directory '{args.input}' not found")
|
||||||
sys.exit(1)
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
print(f"Error: Permission denied: '{args.input}'")
|
print(f"Error: Permission denied: '{args.input}'")
|
||||||
sys.exit(1)
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
sys.exit(1)
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
|
|
||||||
# 1) Process the Common.frag file, if it exists
|
# 1) Process the Common.frag file, if it exists
|
||||||
# 2) Read in the source file (.frag)
|
# 2) Read in the source file (.frag)
|
||||||
@@ -247,9 +255,12 @@ def process():
|
|||||||
print(f"--Output directory: {temp_directory}")
|
print(f"--Output directory: {temp_directory}")
|
||||||
|
|
||||||
last_file = ""
|
last_file = ""
|
||||||
|
last_dir = ""
|
||||||
|
|
||||||
try:
|
|
||||||
for root, dirs, files in os.walk(source_directory):
|
for root, dirs, files in os.walk(source_directory):
|
||||||
|
try:
|
||||||
|
|
||||||
|
last_dir = root
|
||||||
|
|
||||||
# Grab the Common shader file, if it exists
|
# Grab the Common shader file, if it exists
|
||||||
common_file_path = os.path.join(root, 'Common.frag')
|
common_file_path = os.path.join(root, 'Common.frag')
|
||||||
@@ -342,16 +353,20 @@ def process():
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# If the command failed, do not delete the source file
|
# If the command failed, do not delete the source file
|
||||||
print(f"Compiling failed for: {last_file}")
|
print(f"Compiling failed for: {last_file}")
|
||||||
sys.exit(1)
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f"Error: Directory '{args.input}' not found")
|
print(f"Error: Directory '{args.input}' not found")
|
||||||
sys.exit(1)
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
print(f"Error: Permission denied: '{args.input}'")
|
print(f"Error: Permission denied: '{args.input}'")
|
||||||
sys.exit(1)
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
sys.exit(1)
|
shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
# 7) Prepare `Name.frag` by adding ubuff struct and version info
|
# 7) Prepare `Name.frag` by adding ubuff struct and version info
|
||||||
@@ -367,8 +382,11 @@ def prepare():
|
|||||||
print(f"Preparing: {temp_directory}")
|
print(f"Preparing: {temp_directory}")
|
||||||
|
|
||||||
last_file = ""
|
last_file = ""
|
||||||
try:
|
last_dir = "" # track for deleting
|
||||||
|
|
||||||
for root, dirs, files in os.walk(temp_directory):
|
for root, dirs, files in os.walk(temp_directory):
|
||||||
|
try:
|
||||||
|
last_file = root
|
||||||
for file in files:
|
for file in files:
|
||||||
|
|
||||||
# Stage for compiling, if a shader
|
# Stage for compiling, if a shader
|
||||||
@@ -403,16 +421,20 @@ def prepare():
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# If the command failed, do not delete the source file
|
# If the command failed, do not delete the source file
|
||||||
print(f"Compiling failed for: {last_file}")
|
print(f"Compiling failed for: {last_file}")
|
||||||
sys.exit(1)
|
# shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f"Error: Directory '{args.input}' not found")
|
print(f"Error: Directory '{args.input}' not found")
|
||||||
sys.exit(1)
|
# shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
print(f"Error: Permission denied: '{args.input}'")
|
print(f"Error: Permission denied: '{args.input}'")
|
||||||
sys.exit(1)
|
# shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
sys.exit(1)
|
# shutil.rmtree(last_dir)
|
||||||
|
# sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user