Reland "SkSL CPP and H backends no longer emitted in non-dev builds"
This is a reland of bc6fb279fe9714947ecd1fadcff22ef84785c349
Original change's description:
> SkSL CPP and H backends no longer emitted in non-dev builds
>
> As these backends are never used at runtime, it's pointless to include
> them in the Skia binaries. We still include them in GR_TEST_UTILS mode
> to support unit tests.
>
> Change-Id: I9ec9cc9300b74c501985656323ec894008255a70
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311454
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
Change-Id: I214d6d952befbe77f301cf252fe4795f8c411a76
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/312242
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp
index 5f9b821..478f0f5 100644
--- a/src/sksl/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/SkSLCPPCodeGenerator.cpp
@@ -15,6 +15,8 @@
#include <algorithm>
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
namespace SkSL {
static bool needs_uniform_var(const Variable& var) {
@@ -1393,3 +1395,5 @@
}
} // namespace SkSL
+
+#endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
diff --git a/src/sksl/SkSLCPPCodeGenerator.h b/src/sksl/SkSLCPPCodeGenerator.h
index 4edb106..8bd3977 100644
--- a/src/sksl/SkSLCPPCodeGenerator.h
+++ b/src/sksl/SkSLCPPCodeGenerator.h
@@ -13,6 +13,8 @@
#include <set>
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
namespace SkSL {
class CPPCodeGenerator : public GLSLCodeGenerator {
@@ -143,4 +145,6 @@
} // namespace SkSL
-#endif
+#endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
+#endif // SKSL_CPPCODEGENERATOR
diff --git a/src/sksl/SkSLCPPUniformCTypes.cpp b/src/sksl/SkSLCPPUniformCTypes.cpp
index 74146d7..b36ae1e 100644
--- a/src/sksl/SkSLCPPUniformCTypes.cpp
+++ b/src/sksl/SkSLCPPUniformCTypes.cpp
@@ -11,6 +11,8 @@
#include <vector>
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
namespace SkSL {
/////////////////////////
@@ -232,3 +234,5 @@
}
} // namespace SkSL
+
+#endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
diff --git a/src/sksl/SkSLCPPUniformCTypes.h b/src/sksl/SkSLCPPUniformCTypes.h
index a838aa5..076dda3 100644
--- a/src/sksl/SkSLCPPUniformCTypes.h
+++ b/src/sksl/SkSLCPPUniformCTypes.h
@@ -13,6 +13,8 @@
#include "src/sksl/ir/SkSLType.h"
#include "src/sksl/ir/SkSLVariable.h"
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
namespace SkSL {
// This uses templates to define dirtyExpression(), saveState() and setUniform(). Each template can
@@ -130,4 +132,6 @@
} // namespace SkSL
+#endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
#endif // SkSLUniformCTypes_DEFINED
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 543dfed..9795a1e 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -1771,6 +1771,7 @@
return result;
}
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
bool Compiler::toCPP(Program& program, String name, OutputStream& out) {
if (!this->optimize(program)) {
return false;
@@ -1792,8 +1793,9 @@
fSource = nullptr;
return result;
}
+#endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
-#endif
+#endif // defined(SKSL_STANDALONE) || SK_SUPPORT_GPU
#if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU
bool Compiler::toPipelineStage(Program& program, PipelineStageArgs* outArgs) {
diff --git a/src/sksl/SkSLCompiler.h b/src/sksl/SkSLCompiler.h
index d41378d..c01e317 100644
--- a/src/sksl/SkSLCompiler.h
+++ b/src/sksl/SkSLCompiler.h
@@ -139,9 +139,11 @@
bool toMetal(Program& program, String* out);
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
bool toCPP(Program& program, String name, OutputStream& out);
bool toH(Program& program, String name, OutputStream& out);
+#endif
std::unique_ptr<ByteCode> toByteCode(Program& program);
diff --git a/src/sksl/SkSLHCodeGenerator.cpp b/src/sksl/SkSLHCodeGenerator.cpp
index 8af06c5..012b302 100644
--- a/src/sksl/SkSLHCodeGenerator.cpp
+++ b/src/sksl/SkSLHCodeGenerator.cpp
@@ -19,6 +19,8 @@
#include <set>
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
namespace SkSL {
HCodeGenerator::HCodeGenerator(const Context* context, const Program* program,
@@ -383,3 +385,5 @@
}
} // namespace SkSL
+
+#endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
diff --git a/src/sksl/SkSLHCodeGenerator.h b/src/sksl/SkSLHCodeGenerator.h
index 03ab038..6e9bf42 100644
--- a/src/sksl/SkSLHCodeGenerator.h
+++ b/src/sksl/SkSLHCodeGenerator.h
@@ -15,6 +15,8 @@
#include <cctype>
+#if defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
constexpr const char* kFragmentProcessorHeader =
R"(
/**************************************************************************************************
@@ -83,4 +85,6 @@
} // namespace SkSL
-#endif
+#endif // defined(SKSL_STANDALONE) || defined(GR_TEST_UTILS)
+
+#endif // SKSL_HCODEGENERATOR