util/glsl2spirv: Fix build with Python 3.6

ChromeOS still uses Python 3.6, but the glsl2spirv script uses module
'__future__.annotations', introduced in Python 3.7. Fix the build by
removing module, but otherwise preserve the type annotations.

Fixes: 949c3b55db ("util/glsl2spirv: add type annotations")
Acked-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20237>
This commit is contained in:
Chad Versace
2022-12-08 10:53:51 -08:00
committed by Marge Bot
parent e5e64e5c51
commit bca22a6578
+4 -6
View File
@@ -21,7 +21,6 @@
# Converts GLSL shader to SPIR-V library
from __future__ import annotations
import argparse
import subprocess
import sys
@@ -29,7 +28,6 @@ import os
import typing as T
if T.TYPE_CHECKING:
class Arguments(T.Protocol):
input: str
output: str
@@ -42,7 +40,7 @@ if T.TYPE_CHECKING:
stage: str
def get_args() -> Arguments:
def get_args() -> 'Arguments':
parser = argparse.ArgumentParser()
parser.add_argument('input', help="Name of input file.")
parser.add_argument('output', help="Name of output file.")
@@ -111,7 +109,7 @@ def override_version(lines: T.List[str], glsl_version: str) -> T.List[str]:
raise RuntimeError('Did not find #version directive, this is unexpected')
def postprocess_file(args: Arguments) -> None:
def postprocess_file(args: 'Arguments') -> None:
with open(args.output, "r") as r:
lines = r.readlines()
@@ -125,7 +123,7 @@ def postprocess_file(args: Arguments) -> None:
w.writelines(lines)
def preprocess_file(args: Arguments, origin_file: T.TextIO, directory: os.PathLike) -> str:
def preprocess_file(args: 'Arguments', origin_file: T.TextIO, directory: os.PathLike) -> str:
with open(os.path.join(directory, os.path.basename(origin_file.name)), "w") as copy_file:
lines = origin_file.readlines()
@@ -140,7 +138,7 @@ def preprocess_file(args: Arguments, origin_file: T.TextIO, directory: os.PathLi
return copy_file.name
def process_file(args: Arguments) -> None:
def process_file(args: 'Arguments') -> None:
with open(args.input, "r") as infile:
copy_file = preprocess_file(args, infile,
os.path.dirname(args.output))