aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLMain.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2016-11-20 14:53:35 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-20 14:53:48 +0000
commit792d0f13d6cb58ddf27b45e6835ba54c1d8ade77 (patch)
tree929ba3d4638561e480bb070da4d01eec2cce21ab /src/sksl/SkSLMain.cpp
parent7a5b48a75b6f5819c196d158eefa70677783554f (diff)
Revert "switched skslc from std::string to SkString"
This reverts commit d8df21a1e08b5b3380261f4b90acfbdc538ef93c. Reason for revert: Breaking Roll Original change's description: > switched skslc from std::string to SkString > > BUG=skia: > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4977 > > Change-Id: I15e24963b09b719a2c07da67745114f5ac66cee8 > Reviewed-on: https://skia-review.googlesource.com/4977 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > TBR=bsalomon@google.com,benjaminwagner@google.com,ethannicholas@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I84d5311beb9d5e607b7a4a3c138332f0c8f19648 Reviewed-on: https://skia-review.googlesource.com/5077 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/sksl/SkSLMain.cpp')
-rw-r--r--src/sksl/SkSLMain.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
index d9fc81470e..3658992412 100644
--- a/src/sksl/SkSLMain.cpp
+++ b/src/sksl/SkSLMain.cpp
@@ -10,6 +10,13 @@
#include "SkSLCompiler.h"
#include "GrContextOptions.h"
+bool endsWith(const std::string& s, const std::string& ending) {
+ if (s.length() >= ending.length()) {
+ return (0 == s.compare(s.length() - ending.length(), ending.length(), ending));
+ }
+ return false;
+}
+
/**
* Very simple standalone executable to facilitate testing.
*/
@@ -30,36 +37,35 @@ int main(int argc, const char** argv) {
}
std::ifstream in(argv[1]);
- std::string stdText((std::istreambuf_iterator<char>(in)),
- std::istreambuf_iterator<char>());
- SkString text(stdText.c_str());
+ std::string text((std::istreambuf_iterator<char>(in)),
+ std::istreambuf_iterator<char>());
if (in.rdstate()) {
printf("error reading '%s'\n", argv[1]);
exit(2);
}
- SkString name(argv[2]);
- if (name.endsWith(".spirv")) {
- SkFILEWStream out(argv[2]);
+ std::string name(argv[2]);
+ if (endsWith(name, ".spirv")) {
+ std::ofstream out(argv[2], std::ofstream::binary);
SkSL::Compiler compiler;
- if (!out.isValid()) {
- printf("error writing '%s'\n", argv[2]);
- exit(4);
- }
if (!compiler.toSPIRV(kind, text, out)) {
printf("%s", compiler.errorText().c_str());
exit(3);
}
- } else if (name.endsWith(".glsl")) {
- SkFILEWStream out(argv[2]);
- SkSL::Compiler compiler;
- if (!out.isValid()) {
+ if (out.rdstate()) {
printf("error writing '%s'\n", argv[2]);
exit(4);
}
+ } else if (endsWith(name, ".glsl")) {
+ std::ofstream out(argv[2], std::ofstream::binary);
+ SkSL::Compiler compiler;
if (!compiler.toGLSL(kind, text, *SkSL::GLSLCapsFactory::Default(), out)) {
printf("%s", compiler.errorText().c_str());
exit(3);
}
+ if (out.rdstate()) {
+ printf("error writing '%s'\n", argv[2]);
+ exit(4);
+ }
} else {
printf("expected output filename to end with '.spirv' or '.glsl'");
}