NYXGFX/tools/shaders.bash

54 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
clear
# --- GET ARGS ---
while getopts "i:o:" opt; do
case $opt in
i)
input="$OPTARG"
;;
o)
output="$OPTARG"
;;
*)
echo "[USAGE] $0 -i <input_path> -o <output_path>"
exit 1
;;
esac
done
# --- CHECK INPUT ---
if [[ -z "$input" ]]; then
echo -e "\x1b[31m[ERROR]\x1b[0m input path is required."
echo -e "\x1b[33m[USAGE]\x1b[0m $0 -i <input_path> -o <output_path>"
exit 1
fi
# --- CHECK OUTPUT ---
if [[ -z "$output" ]]; then
echo -e "\x1b[31m[ERROR]\x1b[0m output path is required."
echo -e "\x1b[33m[USAGE]\x1b[0m $0 -i <input_path> -o <output_path>"
exit 1
fi
# --- ENSURE OUTPUT PATH ---
mkdir -p "$output"
# --- COMPILE EACH FILE IN INPUT ---
for file in "$input"/*; do
if [[ ! -f "$file" ]]; then
continue
fi
filename=$(basename "$file")
output_file="$output/$filename.spv"
if [[ ! -f "$output_file" || "$file" -nt "$output_file" ]]; then
echo -e "\x1b[32m[COMPILING]\x1b[0m $filename"
glslc "$file" -o "$output_file"
else
echo -e "\x1b[90m[SKIPPING]\x1b[0m $filename"
fi
done