util/glsl2spirv: simplify subprocess handling
Since we're not doing anything fancy, we can just use `subprocess.run`. I've also removed the custom error class, we're not going to catch it, so just printing and exiting is fine. v2: - Print stdout as well as stderr in case of a glslang failure Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449>
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import typing as T
|
import typing as T
|
||||||
|
|
||||||
@@ -39,9 +40,6 @@ if T.TYPE_CHECKING:
|
|||||||
vn: str
|
vn: str
|
||||||
stage: str
|
stage: str
|
||||||
|
|
||||||
class ShaderCompileError(RuntimeError):
|
|
||||||
def __init__(self, *args):
|
|
||||||
super(ShaderCompileError, self).__init__(*args)
|
|
||||||
|
|
||||||
def get_args() -> Arguments:
|
def get_args() -> Arguments:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
@@ -164,17 +162,11 @@ def process_file(args: Arguments) -> None:
|
|||||||
|
|
||||||
cmd_list.append(copy_file)
|
cmd_list.append(copy_file)
|
||||||
|
|
||||||
with subprocess.Popen(" ".join(cmd_list),
|
ret = subprocess.run(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30)
|
||||||
shell = True,
|
if ret.returncode != 0:
|
||||||
stdout = subprocess.PIPE,
|
print(ret.stdout)
|
||||||
stderr = subprocess.PIPE,
|
print(ret.stderr, file=sys.stderr)
|
||||||
stdin = subprocess.PIPE) as proc:
|
sys.exit(1)
|
||||||
|
|
||||||
out, err = proc.communicate(timeout=30)
|
|
||||||
|
|
||||||
if proc.returncode != 0:
|
|
||||||
message = out.decode('utf-8') + '\n' + err.decode('utf-8')
|
|
||||||
raise ShaderCompileError(message.strip())
|
|
||||||
|
|
||||||
if args.vn is not None:
|
if args.vn is not None:
|
||||||
postprocess_file(args)
|
postprocess_file(args)
|
||||||
|
Reference in New Issue
Block a user