skia2/gn/dehydrate_sksl.py
John Stiles e4fbfa6a90 Separate SkSL module dehydration from SkSL test compilation.
gn flag `skia_compile_modules` now compiles the `sksl-precompile` binary
and generates dehydrated data. gn flag `skia_compile_sksl_tests`
now compiles `skslc` and builds the SkSL test corpus, but does not
generate dehydrated data. (skslc uses the raw sksl_xxxxx.sksl inputs
directly, not the dehydrated data, so this is safe.)

Change-Id: I96f6837b4312cd01309496da743a8a0e8a66d69e
Bug: skia:13164
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528158
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-04-06 21:55:39 +00:00

29 lines
774 B
Python

#!/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 subprocess
import sys
sksl_precompile = sys.argv[1]
targetDir = sys.argv[2]
modules = sys.argv[3:]
for module in modules:
try:
noExt, _ = os.path.splitext(module)
head, tail = os.path.split(noExt)
if not os.path.isdir(targetDir):
os.mkdir(targetDir)
target = os.path.join(targetDir, tail)
subprocess.check_output([
sksl_precompile, target + ".dehydrated.sksl", module]).decode('utf-8')
except subprocess.CalledProcessError as err:
print("### Error compiling " + module + ":")
print(err.output)
exit(1)