diff --git a/gn/compile_processors.py b/gn/compile_processors.py
index a8b1c4c5db..3e6cd4551c 100755
--- a/gn/compile_processors.py
+++ b/gn/compile_processors.py
@@ -8,6 +8,7 @@
import os
import subprocess
import sys
+import tempfile
skslc = sys.argv[1]
clangFormat = sys.argv[2]
@@ -15,14 +16,14 @@ fetchClangFormat = sys.argv[3]
processors = sys.argv[4:]
exeSuffix = '.exe' if sys.platform.startswith('win') else '';
-skslcArgs = [skslc]
-clangFormatArgs = [clangFormat, "--sort-includes=false", "-i"]
+targets = []
+worklist = tempfile.NamedTemporaryFile(suffix='.worklist')
# Fetch clang-format if it's not present already.
if not os.path.isfile(clangFormat + exeSuffix):
subprocess.check_call([sys.executable, fetchClangFormat]);
-# Build argument lists for all the fragment processors that we want to compile.
+# Build a worklist of all the fragment processors that we want to compile.
for p in processors:
noExt, _ = os.path.splitext(p)
head, tail = os.path.split(noExt)
@@ -30,27 +31,26 @@ for p in processors:
if not os.path.isdir(targetDir):
os.mkdir(targetDir)
target = os.path.join(targetDir, tail)
- clangFormatArgs.append(target + ".h")
- clangFormatArgs.append(target + ".cpp")
- skslcArgs.append("--");
- skslcArgs.append(p);
- skslcArgs.append(target + ".h");
- skslcArgs.append("--");
- skslcArgs.append(p);
- skslcArgs.append(target + ".cpp");
+ targets.append(target + ".h")
+ targets.append(target + ".cpp")
-# Invoke skslc on every target that needs to be compiled.
+ worklist.write(p + "\n")
+ worklist.write(target + ".h\n\n")
+ worklist.write(p + "\n")
+ worklist.write(target + ".cpp\n\n")
+
+# Invoke skslc, passing in the worklist.
+worklist.close()
try:
- output = subprocess.check_output(skslcArgs, stderr=subprocess.STDOUT)
+ output = subprocess.check_output([skslc, worklist.name], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as err:
print("### skslc error:\n")
print("\n".join(err.output.splitlines()))
- sys.exit(err.returncode)
# Invoke clang-format on every generated target.
try:
- output = subprocess.check_output(clangFormatArgs, stderr=subprocess.STDOUT)
+ output = subprocess.check_output([clangFormat, "--sort-includes=false", "-i"] + targets,
+ stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as err:
print("### clang-format error:\n")
print("\n".join(err.output.splitlines()))
- sys.exit(err.returncode)
diff --git a/gn/compile_sksl_tests.py b/gn/compile_sksl_tests.py
index 92abd57d9f..4b106b2d7c 100755
--- a/gn/compile_sksl_tests.py
+++ b/gn/compile_sksl_tests.py
@@ -8,6 +8,7 @@
import os
import subprocess
import sys
+import tempfile
skslc = sys.argv[1]
lang = sys.argv[2]
@@ -23,8 +24,8 @@ def makeEmptyFile(path):
if settings != "--settings" and settings != "--nosettings":
sys.exit("### Expected --settings or --nosettings, got " + settings)
-skslcArgs = [skslc]
targets = []
+worklist = tempfile.NamedTemporaryFile(suffix='.worklist')
# Convert the list of command-line inputs into a worklist file sfor skslc.
for input in inputs:
@@ -41,36 +42,31 @@ for input in inputs:
targets.append(target)
if lang == "--fp":
- skslcArgs.append("--")
- skslcArgs.append(input)
- skslcArgs.append(target + ".cpp")
- skslcArgs.append(settings)
- skslcArgs.append("--")
- skslcArgs.append(input)
- skslcArgs.append(target + ".h")
- skslcArgs.append(settings)
+ worklist.write(input + "\n")
+ worklist.write(target + ".cpp\n")
+ worklist.write(settings + "\n\n")
+ worklist.write(input + "\n")
+ worklist.write(target + ".h\n")
+ worklist.write(settings + "\n\n")
elif lang == "--glsl":
- skslcArgs.append("--")
- skslcArgs.append(input)
- skslcArgs.append(target + ".glsl")
- skslcArgs.append(settings)
+ worklist.write(input + "\n")
+ worklist.write(target + ".glsl\n")
+ worklist.write(settings + "\n\n")
elif lang == "--metal":
- skslcArgs.append("--")
- skslcArgs.append(input)
- skslcArgs.append(target + ".metal")
- skslcArgs.append(settings)
+ worklist.write(input + "\n")
+ worklist.write(target + ".metal\n")
+ worklist.write(settings + "\n\n")
else:
sys.exit("### Expected one of: --fp --glsl --metal, got " + lang)
-# Invoke skslc on every target that needs to be compiled.
+# Invoke skslc, passing in the worklist.
+worklist.close()
try:
- output = subprocess.check_output(skslcArgs, stderr=subprocess.STDOUT)
+ output = subprocess.check_output([skslc, worklist.name], stderr=subprocess.STDOUT)
+
except subprocess.CalledProcessError as err:
- if err.returncode != 1:
- print("### skslc error:\n")
- print("\n".join(err.output.splitlines()))
- sys.exit(err.returncode)
- pass # Compile errors (exit code 1) are expected and normal in test code
+ print("### skslc error:\n")
+ print("\n".join(err.output.splitlines()))
# A special case cleanup pass, just for CPP and H files: if either one of these files starts with
# `### Compilation failed`, its sibling should be replaced by an empty file. This improves clarity
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
index 5ee4d3696b..0f44e4fe7b 100644
--- a/src/sksl/SkSLMain.cpp
+++ b/src/sksl/SkSLMain.cpp
@@ -33,13 +33,6 @@ namespace SkOpts {
decltype(hash_fn) hash_fn = skslc_standalone::hash_fn;
}
-enum class ResultCode {
- kSuccess = 0,
- kCompileError = 1,
- kInputError = 2,
- kOutputError = 3,
-};
-
// Given the path to a file (e.g. src/gpu/effects/GrFooFragmentProcessor.fp) and the expected
// filename prefix and suffix (e.g. "Gr" and ".fp"), returns the "base name" of the
// file (in this case, 'FooFragmentProcessor'). If no match, returns the empty string.
@@ -209,7 +202,8 @@ static bool detect_shader_settings(const SkSL::String& text,
* Displays a usage banner; used when the command line arguments don't make sense.
*/
static void show_usage() {
- printf("usage: skslc