Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: src/sksl/SkSLMain.cpp

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixed CMake build Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/sksl/SkSLIRGenerator.cpp ('k') | src/sksl/SkSLParser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/sksl/SkSLMain.cpp
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..24fbb6c260fa7921dd9502173cf1f263f3d4d800
--- /dev/null
+++ b/src/sksl/SkSLMain.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "stdio.h"
+#include <fstream>
+#include "SkSLCompiler.h"
+
+/**
+ * Very simple standalone executable to facilitate testing.
+ */
+int main(int argc, const char** argv) {
+ if (argc != 3) {
+ printf("usage: skslc <input> <output>\n");
+ exit(1);
+ }
+ SkSL::Program::Kind kind;
+ size_t len = strlen(argv[1]);
+ if (len > 5 && !strcmp(argv[1] + strlen(argv[1]) - 5, ".vert")) {
+ kind = SkSL::Program::kVertex_Kind;
+ } else if (len > 5 && !strcmp(argv[1] + strlen(argv[1]) - 5, ".frag")) {
+ kind = SkSL::Program::kFragment_Kind;
+ } else {
+ printf("input filename must end in '.vert' or '.frag'\n");
+ exit(1);
+ }
+
+ std::ifstream in(argv[1]);
+ std::string text((std::istreambuf_iterator<char>(in)),
+ std::istreambuf_iterator<char>());
+ if (in.rdstate()) {
+ printf("error reading '%s'\n", argv[1]);
+ exit(2);
+ }
+ std::ofstream out(argv[2], std::ofstream::binary);
+ SkSL::Compiler compiler;
+ if (!compiler.toSPIRV(kind, text, out)) {
+ printf("%s", compiler.errorText().c_str());
+ exit(3);
+ }
+ if (out.rdstate()) {
+ printf("error writing '%s'\n", argv[2]);
+ exit(4);
+ }
+}
« no previous file with comments | « src/sksl/SkSLIRGenerator.cpp ('k') | src/sksl/SkSLParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698