1
2 /*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #include "SkDebuggerGUI.h"
10 #include "SkGraphics.h"
11 #include <QApplication>
12
usage(const char * argv0)13 static void usage(const char * argv0) {
14 SkDebugf("%s <input> \n", argv0);
15 SkDebugf(" [--help|-h]: show this help message\n");
16 SkDebugf("\n\n");
17 SkDebugf(" input: Either a directory or a single .skp file.\n");
18 }
19
main(int argc,char * argv[])20 int main(int argc, char *argv[]) {
21 #ifndef SK_BUILD_FOR_WIN
22 // Set numeric formatting to default. Otherwise shaders will have numbers with wrong comma.
23 // QApplication documentation recommends setlocale("LC_NUMERIC", "C") after QApplication
24 // constuction. However, the components Qt calls (X11 libs, ..) will override that.
25 setenv("LC_NUMERIC", "C", 1);
26 #endif
27 SkGraphics::Init();
28 QApplication a(argc, argv);
29 QStringList argList = a.arguments();
30
31 if (argList.count() <= 0) {
32 return -1; // should at least have command name
33 }
34
35 SkString input;
36
37 QStringList::const_iterator iter = argList.begin();
38
39 SkString commandName(iter->toAscii().data());
40 ++iter; // skip the command name
41
42 for ( ; iter != argList.end(); ++iter) {
43 if (0 == iter->compare("--help") || 0 == iter->compare("-h")) {
44 usage(commandName.c_str());
45 return -1;
46 } else if (input.isEmpty()) {
47 input = SkString(iter->toAscii().data());
48 } else {
49 usage(commandName.c_str());
50 return -1;
51 }
52 }
53
54 SkDebuggerGUI w;
55
56 if (!input.isEmpty()) {
57 if (SkStrEndsWith(input.c_str(), ".skp")) {
58 w.openFile(input.c_str());
59 } else {
60 w.setupDirectoryWidget(input.c_str());
61 }
62 }
63
64 w.show();
65 int result = a.exec();
66 return result;
67 }
68