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

Side by Side 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, 5 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 unified diff | Download patch
« no previous file with comments | « src/sksl/SkSLIRGenerator.cpp ('k') | src/sksl/SkSLParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "stdio.h"
9 #include <fstream>
10 #include "SkSLCompiler.h"
11
12 /**
13 * Very simple standalone executable to facilitate testing.
14 */
15 int main(int argc, const char** argv) {
16 if (argc != 3) {
17 printf("usage: skslc <input> <output>\n");
18 exit(1);
19 }
20 SkSL::Program::Kind kind;
21 size_t len = strlen(argv[1]);
22 if (len > 5 && !strcmp(argv[1] + strlen(argv[1]) - 5, ".vert")) {
23 kind = SkSL::Program::kVertex_Kind;
24 } else if (len > 5 && !strcmp(argv[1] + strlen(argv[1]) - 5, ".frag")) {
25 kind = SkSL::Program::kFragment_Kind;
26 } else {
27 printf("input filename must end in '.vert' or '.frag'\n");
28 exit(1);
29 }
30
31 std::ifstream in(argv[1]);
32 std::string text((std::istreambuf_iterator<char>(in)),
33 std::istreambuf_iterator<char>());
34 if (in.rdstate()) {
35 printf("error reading '%s'\n", argv[1]);
36 exit(2);
37 }
38 std::ofstream out(argv[2], std::ofstream::binary);
39 SkSL::Compiler compiler;
40 if (!compiler.toSPIRV(kind, text, out)) {
41 printf("%s", compiler.errorText().c_str());
42 exit(3);
43 }
44 if (out.rdstate()) {
45 printf("error writing '%s'\n", argv[2]);
46 exit(4);
47 }
48 }
OLDNEW
« 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