| 1 |
|
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
if __name__ != "__main__": |
| 6 |
raise ImportError(f"{__name__} should not be used as a module.") |
| 7 |
|
| 8 |
import os |
| 9 |
import sys |
| 10 |
from typing import Any, Callable |
| 11 |
|
| 12 |
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../")) |
| 13 |
|
| 14 |
from gles3_builders import build_gles3_header |
| 15 |
from glsl_builders import build_raw_header, build_rd_header |
| 16 |
|
| 17 |
FUNC_PATH_KWARGS: list[tuple[Callable[..., None], str, dict[str, Any]]] = [ |
| 18 |
( |
| 19 |
build_gles3_header, |
| 20 |
"tests/python_build/fixtures/gles3/vertex_fragment.out", |
| 21 |
{"shader": "tests/python_build/fixtures/gles3/vertex_fragment.glsl"}, |
| 22 |
), |
| 23 |
( |
| 24 |
build_raw_header, |
| 25 |
"tests/python_build/fixtures/glsl/compute.out", |
| 26 |
{"shader": "tests/python_build/fixtures/glsl/compute.glsl"}, |
| 27 |
), |
| 28 |
( |
| 29 |
build_raw_header, |
| 30 |
"tests/python_build/fixtures/glsl/vertex_fragment.out", |
| 31 |
{"shader": "tests/python_build/fixtures/glsl/vertex_fragment.glsl"}, |
| 32 |
), |
| 33 |
( |
| 34 |
build_rd_header, |
| 35 |
"tests/python_build/fixtures/rd_glsl/compute.out", |
| 36 |
{"shader": "tests/python_build/fixtures/rd_glsl/compute.glsl"}, |
| 37 |
), |
| 38 |
( |
| 39 |
build_rd_header, |
| 40 |
"tests/python_build/fixtures/rd_glsl/vertex_fragment.out", |
| 41 |
{"shader": "tests/python_build/fixtures/rd_glsl/vertex_fragment.glsl"}, |
| 42 |
), |
| 43 |
] |
| 44 |
|
| 45 |
|
| 46 |
def main() -> int: |
| 47 |
ret = 0 |
| 48 |
|
| 49 |
for func, path, kwargs in FUNC_PATH_KWARGS: |
| 50 |
if os.path.exists(out_path := os.path.abspath(path)): |
| 51 |
with open(out_path, "rb") as file: |
| 52 |
raw = file.read() |
| 53 |
func(path, **kwargs) |
| 54 |
with open(out_path, "rb") as file: |
| 55 |
if raw != file.read(): |
| 56 |
ret += 1 |
| 57 |
else: |
| 58 |
func(path, **kwargs) |
| 59 |
ret += 1 |
| 60 |
|
| 61 |
return ret |
| 62 |
|
| 63 |
|
| 64 |
sys.exit(main()) |