blob: d537d363c9818a8111e91e700fb3b8393541bbbf [file] [log] [blame]
chudy@google.com607357f2012-08-07 16:12:23 +00001
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 <QApplication>
11
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000012static void usage(const char * argv0) {
13 SkDebugf("%s <input> \n", argv0);
14 SkDebugf(" [--help|-h]: show this help message\n");
15 SkDebugf("\n\n");
16 SkDebugf(" input: Either a directory or a single .skp file.\n");
17}
18
chudy@google.com607357f2012-08-07 16:12:23 +000019int main(int argc, char *argv[]) {
kkinnunen6438f9a2014-11-13 05:13:50 -080020#ifndef SK_BUILD_FOR_WIN32
21 // Set numeric formatting to default. Otherwise shaders will have numbers with wrong comma.
22 // QApplication documentation recommends setlocale("LC_NUMERIC", "C") after QApplication
23 // constuction. However, the components Qt calls (X11 libs, ..) will override that.
24 setenv("LC_NUMERIC", "C", 1);
25#endif
chudy@google.com607357f2012-08-07 16:12:23 +000026 QApplication a(argc, argv);
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000027 QStringList argList = a.arguments();
28
29 if (argList.count() <= 0) {
30 return -1; // should at least have command name
31 }
32
33 SkString input;
34
35 QStringList::const_iterator iter = argList.begin();
36
robertphillips@google.come219baf2013-01-28 19:25:43 +000037 SkString commandName(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000038 ++iter; // skip the command name
39
40 for ( ; iter != argList.end(); ++iter) {
41 if (0 == iter->compare("--help") || 0 == iter->compare("-h")) {
42 usage(commandName.c_str());
43 return -1;
44 } else if (input.isEmpty()) {
robertphillips@google.come219baf2013-01-28 19:25:43 +000045 input = SkString(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000046 } else {
47 usage(commandName.c_str());
48 return -1;
49 }
50 }
51
chudy@google.com607357f2012-08-07 16:12:23 +000052 SkDebuggerGUI w;
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000053
54 if (!input.isEmpty()) {
55 if (SkStrEndsWith(input.c_str(), ".skp")) {
56 w.openFile(input.c_str());
57 } else {
58 w.setupDirectoryWidget(input.c_str());
59 }
60 }
61
chudy@google.com607357f2012-08-07 16:12:23 +000062 w.show();
63 return a.exec();
64}