1
0
forked from 0ad/0ad

Add support for vendored spirv-reflect to compile.py

The script build-archive.sh sets a variable SPIRV_REFLECT, even respects
it if it's set in env but without support from the compile.py script for
it there isn't much point.

This commit adds support SPIRV_REFLECT in compile.py and and adds a
fallback to use vendored spirv-reflect for when the envvar is unset and
the tool can't be found in PATH

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2024-09-16 20:06:09 +02:00
parent f6ec490a42
commit 663982e503
Signed by: sera
SSH Key Fingerprint: SHA256:peL4nxsVEHY8tOsBHev85LILY2TqpfHeutw4LUbOFPQ

View File

@ -25,10 +25,12 @@ import hashlib
import itertools
import json
import os
import shutil
import subprocess
import sys
import xml.etree.ElementTree as ET
from enum import Enum
from pathlib import Path
import yaml
@ -132,7 +134,17 @@ def compile_and_reflect(input_mod_path, dependencies, stage, path, out_path, def
)
execute(command[:-2] + ["-g", "-E", "-o", preprocessor_output_path])
raise ValueError(err)
ret, out, err = execute(["spirv-reflect", "-y", "-v", "1", output_path])
spirv_reflect = os.getenv("SPIRV_REFLECT", "spirv-reflect")
if shutil.which(spirv_reflect) is None:
spirv_reflect = (
Path(__file__).resolve().parent.parent.parent.parent
/ "libraries"
/ "source"
/ "spirv-reflect"
/ "bin"
/ "spirv-reflect"
)
ret, out, err = execute([spirv_reflect, "-y", "-v", "1", output_path])
if ret:
sys.stderr.write(
"Command returned {}:\nCommand: {}\nInput path: {}\nOutput path: {}\n"