skia2/gn/compile_sksl_tests.py
John Stiles b8f05d6f63 Revert "[skslc] Generate .hlsl test output files"
This reverts commit a97a6769b5.

Reason for revert: breaking bot Housekeeper-PerCommit-CheckGeneratedFiles -- see http://screen/5FN75fF9tvcQFKR

Based on the diff, I think this just needs to be synced up to latest code and a rebuild should fix it.


Original change's description:
> [skslc] Generate .hlsl test output files
>
> - The build now generates HLSL output when `skia_compile_sksl_tests` is
> enabled.
> - The "blend" and "shared" tests have been enabled for HLSL with the
> exception of 6 tests that exercise intrinsic inverse hyperbolic
> functions, which don't have HLSL equivalents.
>
> Bug: skia:12691, skia:12352
> Change-Id: Ia970f878f75ff58e8e3d47249c2dc2f756c165b4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/482778
> Reviewed-by: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Auto-Submit: Arman Uguray <armansito@google.com>
> Commit-Queue: Arman Uguray <armansito@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

Bug: skia:12691, skia:12352
Change-Id: Iaad607d48edd136eee2b60e48c0643b6e90179e9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/499216
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-01-25 04:57:15 +00:00

111 lines
3.4 KiB
Python
Executable File

#!/usr/bin/env python
#
# Copyright 2020 Google LLC
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import shlex
import subprocess
import sys
import tempfile
batchCompile = True
skslc = sys.argv[1]
lang = sys.argv[2]
settings = sys.argv[3]
with open(sys.argv[4], 'r') as reader:
inputs = shlex.split(reader.read())
def pairwise(iterable):
# Iterate over an array pairwise (two elements at a time).
a = iter(iterable)
return zip(a, a)
def executeWorklist(input, worklist):
# Invoke skslc, passing in the worklist.
worklist.close()
try:
output = subprocess.check_output([
skslc, worklist.name], stderr=subprocess.STDOUT).decode('utf-8')
except subprocess.CalledProcessError as err:
if err.returncode != 1:
print("### " + input + " skslc error:\n")
print("\n".join(err.output.decode('utf-8').splitlines()))
sys.exit(err.returncode)
pass # Compile errors (exit code 1) are expected and normal in test code
# Delete the worklist file now that execution is complete.
os.remove(worklist.name)
def makeEmptyFile(path):
try:
open(path, 'wb').close()
except OSError:
pass
def extensionForSpirvAsm(ext):
return ext if (ext == '.frag' or ext == '.vert') else '.frag'
if settings != "--settings" and settings != "--nosettings":
sys.exit("### Expected --settings or --nosettings, got " + settings)
targets = []
worklist = tempfile.NamedTemporaryFile(suffix='.worklist', delete=False, mode='w')
# The `inputs` array pairs off input files with their matching output directory, e.g.:
# //skia/tests/sksl/shared/test.sksl
# //skia/tests/sksl/shared/golden/
# //skia/tests/sksl/intrinsics/abs.sksl
# //skia/tests/sksl/intrinsics/golden/
# ... (etc) ...
# Here we loop over these inputs and convert them into a worklist file for skslc.
for input, targetDir in pairwise(inputs):
noExt, ext = os.path.splitext(input)
head, tail = os.path.split(noExt)
if not os.path.isdir(targetDir):
os.mkdir(targetDir)
target = os.path.join(targetDir, tail)
if settings == "--nosettings":
target += "StandaloneSettings"
targets.append(target)
if lang == "--glsl":
worklist.write(input + "\n")
worklist.write(target + ".glsl\n")
worklist.write(settings + "\n\n")
elif lang == "--metal":
worklist.write(input + "\n")
worklist.write(target + ".metal\n")
worklist.write(settings + "\n\n")
elif lang == "--spirv":
worklist.write(input + "\n")
worklist.write(target + ".asm" + extensionForSpirvAsm(ext) + "\n")
worklist.write(settings + "\n\n")
elif lang == "--skvm":
worklist.write(input + "\n")
worklist.write(target + ".skvm\n")
worklist.write(settings + "\n\n")
elif lang == "--stage":
worklist.write(input + "\n")
worklist.write(target + ".stage\n")
worklist.write(settings + "\n\n")
else:
sys.exit("### Expected one of: --glsl --metal --spirv --skvm --stage --dsl, got " + lang)
# Compile items one at a time.
if not batchCompile:
executeWorklist(input, worklist)
worklist = tempfile.NamedTemporaryFile(suffix='.worklist', delete=False, mode='w')
# Compile everything all in one go.
if batchCompile:
executeWorklist("", worklist)
else:
worklist.close()
os.remove(worklist.name)