From e97c46e96cdefea95425975ccce5e6300448a9b8 Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Fri, 21 Nov 2025 11:36:51 -0500 Subject: [PATCH] shaders-compile.sh supports file list arguments --- Bin/dev/shaders-compile.sh | 63 ++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/Bin/dev/shaders-compile.sh b/Bin/dev/shaders-compile.sh index b9f76a80..dee4a7f8 100755 --- a/Bin/dev/shaders-compile.sh +++ b/Bin/dev/shaders-compile.sh @@ -15,22 +15,59 @@ fi # Create the destination directory if it doesn't exist. mkdir -p "$DEST_DIR" -# Loop through all files in the source directory ending with .frag -for shader in "$SOURCE_DIR"*.frag; do - # Check if a file was found (to handle the case of no .frag files). - if [ -f "$shader" ]; then - # Get the base name of the file (e.g., wp_fade). - shader_name=$(basename "$shader" .frag) +# Array to hold the list of full paths to the shaders. +SHADERS_TO_COMPILE=() - # Construct the output path for the compiled shader. - output_path="$DEST_DIR$shader_name.frag.qsb" +# Specific files mode. +if [ "$#" -gt 0 ]; then - # Construct and run the qsb command. - qsb --qt6 -o "$output_path" "$shader" + # Loop through all command-line arguments ($@ holds all arguments). + for SINGLE_FILE in "$@"; do - # Print a message to confirm compilation. - echo "Compiled $shader to $output_path" + # Construct the full path to the source file. + FULL_PATH="$SOURCE_DIR$SINGLE_FILE" + + # Check if the specified file exists in the SOURCE_DIR. + if [ ! -f "$FULL_PATH" ]; then + echo "Error: Specified file '$SINGLE_FILE' not found in $SOURCE_DIR! Skipping." + continue + fi + + # Add the valid file to the compilation list. + SHADERS_TO_COMPILE+=("$FULL_PATH") + done + + # Check if any valid files were found to compile. + if [ ${#SHADERS_TO_COMPILE[@]} -eq 0 ]; then + echo "No valid shaders found to compile." + exit 1 fi + +# Whole directory mode (no argument provided). +else + # Use find to generate the list of files and assign it to the array. + while IFS= read -r shader_path; do + if [ -n "$shader_path" ]; then + SHADERS_TO_COMPILE+=("$shader_path") + fi + done < <(find "$SOURCE_DIR" -maxdepth 1 -name "*.frag") + +fi + +# Loop through the list of shaders to compile. +for shader in "${SHADERS_TO_COMPILE[@]}"; do + + # Get the base name of the file (e.g., wp_fade). + shader_name=$(basename "$shader" .frag) + + # Construct the output path for the compiled shader. + output_path="$DEST_DIR$shader_name.frag.qsb" + + # Construct and run the qsb command. + qsb --qt6 -o "$output_path" "$shader" + + # Print a message to confirm compilation. + echo "Compiled $(basename "$shader") to $output_path" done -echo "Shader compilation complete." \ No newline at end of file +echo "Shader compilation complete."