From 0a0a50ae973680fa136e1b0b28d9af47be46a8dd Mon Sep 17 00:00:00 2001 From: John Stiles Date: Wed, 14 Apr 2021 09:35:24 -0400 Subject: [PATCH] Use .dsl.cpp suffix for DSL C++ instead of _dsl.cpp. This requires the GN processing to be slightly more complex, as GN has no native support for more than one extension on a file. Context: https://groups.google.com/a/chromium.org/g/gn-dev/c/RdEpjeYtb-4 Change-Id: I630511fca9eb291f0e414481ef439f18a8e1b72f Bug: skia:11854 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396197 Reviewed-by: Ethan Nicholas Commit-Queue: Ethan Nicholas Auto-Submit: John Stiles --- BUILD.gn | 13 ++++++++++--- gn/compile_sksl_tests.py | 4 ++-- gn/sksl_tests.gni | 2 +- src/sksl/SkSLMain.cpp | 2 +- ...SLHelloWorld_dsl.cpp => GrDSLHelloWorld.dsl.cpp} | 0 5 files changed, 14 insertions(+), 7 deletions(-) rename tests/sksl/fp/{GrDSLHelloWorld_dsl.cpp => GrDSLHelloWorld.dsl.cpp} (100%) diff --git a/BUILD.gn b/BUILD.gn index 1116d026e1..cf062733d3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -780,8 +780,15 @@ if (skia_compile_sksl_tests) { src = resourcesDir + partialPath dir = get_path_info(dst, "dir") - name = get_path_info(dst, "name") - ext = get_path_info(dst, "extension") + + # We want to support double-extensions (for '.dsl.cpp') but GN doesn't natively handle this. + # Workaround: http://go/ggroup/a/chromium.org/g/gn-dev/c/RdEpjeYtb-4 + # For input path "file.aa.bb", name will contain "file" and ext will contain ".aa.bb". + # For input path "file.cc", name will contain "file" and ext will contain ".cc". + nameTmp = get_path_info(dst, "name") + name = get_path_info(nameTmp, "name") + ext = get_path_info(nameTmp, "extension") + ext += get_path_info(dst, "extension") response_file_contents += rebase_path([ src, dir, @@ -814,7 +821,7 @@ if (skia_compile_sksl_tests) { compile_sksl("dsl_fp_tests") { sources = sksl_dsl_fp_tests_sources outExtensions = [ - "_dsl.cpp", + ".dsl.cpp", ".h", ] lang = "--dslfp" diff --git a/gn/compile_sksl_tests.py b/gn/compile_sksl_tests.py index 99203a87b6..2efec1417c 100755 --- a/gn/compile_sksl_tests.py +++ b/gn/compile_sksl_tests.py @@ -82,7 +82,7 @@ for input, targetDir in pairwise(inputs): worklist.write(settings + "\n\n") elif lang == "--dslfp": worklist.write(input + "\n") - worklist.write(target + "_dsl.cpp\n") + worklist.write(target + ".dsl.cpp\n") worklist.write(settings + "\n\n") worklist.write(input + "\n") worklist.write(target + ".h\n") @@ -127,7 +127,7 @@ else: # `### Compilation failed`, its sibling should be replaced by an empty file. This improves clarity # during code review; a failure on either file means that success on the sibling is irrelevant. if lang == "--fp" or lang == "--dslfp": - cppExtension = ("_dsl.cpp" if lang == "--dslfp" else ".cpp") + cppExtension = (".dsl.cpp" if lang == "--dslfp" else ".cpp") hExtension = ".h" for target in targets: diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni index d5cb0caa3a..43b35a74a7 100644 --- a/gn/sksl_tests.gni +++ b/gn/sksl_tests.gni @@ -592,7 +592,7 @@ sksl_rte_error_tests = [ sksl_fp_tests_sources = sksl_fp_error_tests + sksl_fp_tests # Tests in sksl_dsl_fp_tests_sources will be compiled with --settings on, and are expected to -# generate a _dsl.cpp and a .h output file. +# generate a .dsl.cpp and a .h output file. sksl_dsl_fp_tests_sources = sksl_dsl_fp_tests # Tests in sksl_glsl_tests_sources will be compiled with --settings on, and are expected to generate diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp index b9670e2129..d49b5b5a70 100644 --- a/src/sksl/SkSLMain.cpp +++ b/src/sksl/SkSLMain.cpp @@ -379,7 +379,7 @@ ResultCode processCommand(std::vector& args) { [&](SkSL::Compiler& compiler, SkSL::Program& program, SkSL::OutputStream& out) { return compiler.toH(program, base_name(inputPath.c_str(), "Gr", ".fp"), out); }); - } else if (outputPath.endsWith("_dsl.cpp")) { + } else if (outputPath.endsWith(".dsl.cpp")) { settings.fReplaceSettings = false; settings.fPermitInvalidStaticTests = true; return compileProgram( diff --git a/tests/sksl/fp/GrDSLHelloWorld_dsl.cpp b/tests/sksl/fp/GrDSLHelloWorld.dsl.cpp similarity index 100% rename from tests/sksl/fp/GrDSLHelloWorld_dsl.cpp rename to tests/sksl/fp/GrDSLHelloWorld.dsl.cpp