share dm and command flags
Share command flags between dm and unit tests.
Also, allow dm's core to be included by itself and iOSShell.
Command line flags that are the same (or nearly the same) in DM
and in skia_tests have been moved to common_flags. Authors,
please check to see that the shared common flag is correct for
the tool.
For iOS, the 'tool_main' entry point has a wrapper to allow multiple
tools to be statically linked in the iOSShell.
Since SkCommandLineFlags::Parse can only be called once, these calls
are disabled in the IOS build.
Since the iOS app directory is dynamically assigned a name, use '@' to
select it. (This is the same convention chosen by the Mobile Harness
iOS file system utilities.)
Move the heart of dm.gyp into dm.gypi so that it can be included by
itself and iOSShell.gyp.
Add tools/flags/SkCommonFlags.* to define and declare common
command line flags.
Add support for dm to iOSShell.
BUG=skia:
R=scroggo@google.com, mtklein@google.com, jvanverth@google.com, bsalomon@google.com
Author: caryclark@google.com
Review URL: https://codereview.chromium.org/389653004
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 0af0552..a3cd495 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -14,7 +14,7 @@
#include "Timer.h"
#include "SkCanvas.h"
-#include "SkCommandLineFlags.h"
+#include "SkCommonFlags.h"
#include "SkForceLinking.h"
#include "SkGraphics.h"
#include "SkString.h"
@@ -38,26 +38,16 @@
DEFINE_int32(overheadLoops, 100000, "Loops to estimate timer overhead.");
DEFINE_double(overheadGoal, 0.0001,
"Loop until timer overhead is at most this fraction of our measurments.");
-DEFINE_string(match, "", "The usual filters on file names of benchmarks to measure.");
-DEFINE_bool2(quiet, q, false, "Print only bench name and minimum sample.");
-DEFINE_bool2(verbose, v, false, "Print all samples.");
-DEFINE_string(config, "nonrendering 8888 gpu", "Configs to measure. Options: "
- "565 8888 gpu nonrendering debug nullgpu msaa4 msaa16 nvprmsaa4 nvprmsaa16 angle");
DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
DEFINE_int32(gpuFrameLag, 5, "Overestimate of maximum number of frames GPU allows to lag.");
-DEFINE_bool(cpu, true, "Master switch for CPU-bound work.");
-DEFINE_bool(gpu, true, "Master switch for GPU-bound work.");
-
DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
-DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each bench.");
DEFINE_int32(maxCalibrationAttempts, 3,
"Try up to this many times to guess loops for a bench, or skip the bench.");
DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this.");
DEFINE_string(key, "", "Space-separated key/value pairs to add to JSON.");
DEFINE_string(gitHash, "", "Git hash to add to JSON.");
-
static SkString humanize(double ms) {
if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3);
if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6);
@@ -298,11 +288,10 @@
}
#endif
-int tool_main(int argc, char** argv);
-int tool_main(int argc, char** argv) {
+int nanobench_main();
+int nanobench_main() {
SetupCrashHandler();
SkAutoGraphics ag;
- SkCommandLineFlags::Parse(argc, argv);
if (FLAGS_runOnce) {
FLAGS_samples = 1;
@@ -429,7 +418,8 @@
}
#if !defined SK_BUILD_FOR_IOS
-int main(int argc, char * const argv[]) {
- return tool_main(argc, (char**) argv);
+int main(int argc, char** argv) {
+ SkCommandLineFlags::Parse(argc, argv);
+ return nanobench_main();
}
#endif
diff --git a/dm/DM.cpp b/dm/DM.cpp
index c71450c..003145b 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -2,7 +2,7 @@
// For a high-level overview, please see dm/README.
#include "CrashHandler.h"
-#include "SkCommandLineFlags.h"
+#include "SkCommonFlags.h"
#include "SkForceLinking.h"
#include "SkGraphics.h"
#include "SkPicture.h"
@@ -38,38 +38,17 @@
static const char kGpuAPINameGL[] = "gl";
static const char kGpuAPINameGLES[] = "gles";
-DEFINE_int32(threads, -1, "Threads for CPU work. Default NUM_CPUS.");
DEFINE_int32(gpuThreads, 1, "Threads for GPU work.");
-DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" "
- "forces OpenGL API. Using \"gles\" forces OpenGL ES API. "
- "Defaults to empty string, which selects the API native to the "
- "system.");
DEFINE_string2(expectations, r, "",
"If a directory, compare generated images against images under this path. "
"If a file, compare generated images against JSON expectations at this path."
);
-DEFINE_string2(resources, i, "resources", "Path to resources directory.");
-DEFINE_string(match, "", "[~][^]substring[$] [...] of GM name to run.\n"
- "Multiple matches may be separated by spaces.\n"
- "~ causes a matching GM to always be skipped\n"
- "^ requires the start of the GM to match\n"
- "$ requires the end of the GM to match\n"
- "^ and $ requires an exact match\n"
- "If a GM does not match any list entry,\n"
- "it is skipped unless some list entry starts with ~");
-DEFINE_string(config, "565 8888 pdf gpu nonrendering",
- "Options: 565 8888 pdf gpu nonrendering msaa4 msaa16 nvprmsaa4 nvprmsaa16 "
- "gpunull gpudebug angle mesa");
-DEFINE_bool(dryRun, false,
- "Just print the tests that would be run, without actually running them.");
-DEFINE_bool(leaks, false, "Print leaked instance-counted objects at exit?");
+
DEFINE_string(skps, "", "Directory to read skps from.");
DEFINE_bool(gms, true, "Run GMs?");
DEFINE_bool(tests, true, "Run tests?");
-DECLARE_bool(verbose);
-
__SK_FORCE_IMAGE_DECODER_LINKING;
// "FooBar" -> "foobar". Obviously, ASCII only.
@@ -203,11 +182,10 @@
}
}
-int tool_main(int argc, char** argv);
-int tool_main(int argc, char** argv) {
+int dm_main();
+int dm_main() {
SetupCrashHandler();
SkAutoGraphics ag;
- SkCommandLineFlags::Parse(argc, argv);
if (FLAGS_dryRun) {
FLAGS_verbose = true;
@@ -262,6 +240,7 @@
#if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
int main(int argc, char** argv) {
- return tool_main(argc, argv);
+ SkCommandLineFlags::Parse(argc, argv);
+ return dm_main();
}
#endif
diff --git a/dm/DMReporter.cpp b/dm/DMReporter.cpp
index 0bc77bd..3f71d69 100644
--- a/dm/DMReporter.cpp
+++ b/dm/DMReporter.cpp
@@ -1,12 +1,9 @@
#include "DMReporter.h"
#include "SkDynamicAnnotations.h"
-#include "SkCommandLineFlags.h"
+#include "SkCommonFlags.h"
#include "OverwriteLine.h"
-DEFINE_bool2(quiet, q, false, "If true, don't print status updates.");
-DEFINE_bool2(verbose, v, false, "If true, print status updates one-per-line.");
-
namespace DM {
void Reporter::printStatus(SkString name, SkMSec timeMs) const {
diff --git a/dm/DMTask.cpp b/dm/DMTask.cpp
index 2c7cdd7..d0a82b6 100644
--- a/dm/DMTask.cpp
+++ b/dm/DMTask.cpp
@@ -1,12 +1,6 @@
#include "DMTask.h"
#include "DMTaskRunner.h"
-#include "SkCommandLineFlags.h"
-
-DEFINE_bool(cpu, true, "Master switch for running CPU-bound work.");
-DEFINE_bool(gpu, true, "Master switch for running GPU-bound work.");
-DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each task.");
-
-DECLARE_bool(dryRun);
+#include "SkCommonFlags.h"
namespace DM {
diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp
index 13f25d0..b90e44a 100644
--- a/dm/DMWriteTask.cpp
+++ b/dm/DMWriteTask.cpp
@@ -2,7 +2,7 @@
#include "DMUtil.h"
#include "SkColorPriv.h"
-#include "SkCommandLineFlags.h"
+#include "SkCommonFlags.h"
#include "SkImageEncoder.h"
#include "SkMallocPixelRef.h"
#include "SkStream.h"
@@ -129,6 +129,11 @@
void WriteTask::draw() {
SkString dir(FLAGS_writePath[0]);
+#if SK_BUILD_FOR_IOS
+ if (dir.equals("@")) {
+ dir.set(FLAGS_resourcePath[0]);
+ }
+#endif
this->makeDirOrFail(dir);
for (int i = 0; i < fSuffixes.count(); i++) {
dir = SkOSPath::SkPathJoin(dir.c_str(), fSuffixes[i].c_str());
diff --git a/experimental/SimpleiOSApp/SimpleApp.mm b/experimental/SimpleiOSApp/SimpleApp.mm
index 44b646f..040472c 100644
--- a/experimental/SimpleiOSApp/SimpleApp.mm
+++ b/experimental/SimpleiOSApp/SimpleApp.mm
@@ -1,11 +1,12 @@
+#include "SkApplication.h"
#import "SkCanvas.h"
#import "SkPaint.h"
#import "SkWindow.h"
#include "SkGraphics.h"
#include "SkCGUtils.h"
-extern void tool_main(int argc, char *argv[]);
-extern bool set_cmd_line_args(int argc, char *argv[], const char* dir);
+void dummy_main(int , char *[]) {
+}
class SkSampleView : public SkView {
public:
@@ -41,10 +42,10 @@
int saved_argc;
char** saved_argv;
-bool set_cmd_line_args(int argc, char *argv[], const char* ) {
+IOS_launch_type set_cmd_line_args(int argc, char *argv[], const char* ) {
saved_argc = argc;
saved_argv = argv;
- return true;
+ return kTool_iOSLaunchType;
}
class FillLayout : public SkView::Layout {
@@ -59,7 +60,7 @@
@implementation SimpleApp
- (id)initWithDefaults {
- (void) tool_main(saved_argc, saved_argv);
+ dummy_main(saved_argc, saved_argv);
if (self = [super initWithDefaults]) {
fWind = new SkOSWindow(self);
fWind->setLayout(new FillLayout, false);
diff --git a/experimental/iOSSampleApp/Shared/skia_ios.mm b/experimental/iOSSampleApp/Shared/skia_ios.mm
index 4fce139..45675fa 100644
--- a/experimental/iOSSampleApp/Shared/skia_ios.mm
+++ b/experimental/iOSSampleApp/Shared/skia_ios.mm
@@ -1,8 +1,6 @@
#import <UIKit/UIKit.h>
#include "SkApplication.h"
-extern bool set_cmd_line_args(int argc, char *argv[], const char* dir);
-
int main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_IGN);
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@@ -11,9 +9,9 @@
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = [dirPaths objectAtIndex:0];
const char *d = [docsDir UTF8String];
-
- bool ranCommand = set_cmd_line_args(argc, argv, d);
- int retVal = ranCommand ? 0 : UIApplicationMain(argc, argv, nil, nil);
+ IOS_launch_type launchType = set_cmd_line_args(argc, argv, d);
+ int retVal = launchType == kApplication__iOSLaunchType
+ ? UIApplicationMain(argc, argv, nil, nil) : (int) launchType;
application_term();
[pool release];
return retVal;
diff --git a/gyp/bench.gyp b/gyp/bench.gyp
index 6618403..ad026a6 100644
--- a/gyp/bench.gyp
+++ b/gyp/bench.gyp
@@ -42,7 +42,7 @@
],
'includes': [ 'bench.gypi' ],
'dependencies': [
- 'flags.gyp:flags',
+ 'flags.gyp:flags_common',
'jsoncpp.gyp:jsoncpp',
'skia_lib.gyp:skia_lib',
'tools.gyp:crash_handler',
diff --git a/gyp/dm.gyp b/gyp/dm.gyp
index 51c8569..e4d6bd6 100644
--- a/gyp/dm.gyp
+++ b/gyp/dm.gyp
@@ -1,62 +1,12 @@
# GYP for "dm" (Diamond Master, a.k.a Dungeon master, a.k.a GM 2).
-# vim: set expandtab tabstop=4 shiftwidth=4
{
'includes': [ 'apptype_console.gypi' ],
'targets': [{
'target_name': 'dm',
'type': 'executable',
- 'include_dirs': [
- '../dm',
- '../gm',
- '../tests',
- '../src/images',
- '../src/lazy',
- '../src/core',
- '../src/effects',
- '../src/pipe/utils/',
- '../src/utils',
- '../src/utils/debugger',
- '../tools',
- ],
'includes': [
- 'gmslides.gypi',
- 'pathops_unittest.gypi',
- 'tests.gypi',
- ],
- 'sources': [
- '../dm/DM.cpp',
- '../dm/DMCpuGMTask.cpp',
- '../dm/DMExpectationsTask.cpp',
- '../dm/DMGpuGMTask.cpp',
- '../dm/DMPDFRasterizeTask.cpp',
- '../dm/DMPDFTask.cpp',
- '../dm/DMPipeTask.cpp',
- '../dm/DMQuiltTask.cpp',
- '../dm/DMReporter.cpp',
- '../dm/DMSKPTask.cpp',
- '../dm/DMSerializeTask.cpp',
- '../dm/DMTask.cpp',
- '../dm/DMTaskRunner.cpp',
- '../dm/DMTestTask.cpp',
- '../dm/DMUtil.cpp',
- '../dm/DMWriteTask.cpp',
- '../gm/gm.cpp',
- '../gm/gm_expectations.cpp',
-
- '../src/pipe/utils/SamplePipeControllers.cpp',
- '../src/utils/debugger/SkDebugCanvas.cpp',
- '../src/utils/debugger/SkDrawCommand.cpp',
- '../src/utils/debugger/SkObjectParser.cpp',
- ],
- 'dependencies': [
- 'etc1.gyp:libetc1',
- 'flags.gyp:flags',
- 'gputest.gyp:skgputest',
- 'jsoncpp.gyp:jsoncpp',
- 'skia_lib.gyp:skia_lib',
- 'tools.gyp:crash_handler',
- 'tools.gyp:sk_tool_utils',
+ 'dm.gypi',
],
'conditions': [
['skia_android_framework', {
diff --git a/gyp/dm.gypi b/gyp/dm.gypi
new file mode 100644
index 0000000..2db3087
--- /dev/null
+++ b/gyp/dm.gypi
@@ -0,0 +1,55 @@
+# GYP for "dm" (Diamond Master, a.k.a Dungeon master, a.k.a GM 2).
+{
+ 'include_dirs': [
+ '../dm',
+ '../gm',
+ '../tests',
+ '../src/images',
+ '../src/lazy',
+ '../src/core',
+ '../src/effects',
+ '../src/pipe/utils/',
+ '../src/utils',
+ '../src/utils/debugger',
+ '../tools',
+ ],
+ 'dependencies': [
+ 'etc1.gyp:libetc1',
+ 'flags.gyp:flags',
+ 'gputest.gyp:skgputest',
+ 'jsoncpp.gyp:jsoncpp',
+ 'skia_lib.gyp:skia_lib',
+ 'tools.gyp:crash_handler',
+ 'tools.gyp:sk_tool_utils',
+ ],
+ 'includes': [
+ 'gmslides.gypi',
+ 'pathops_unittest.gypi',
+ 'tests.gypi',
+ ],
+ 'sources': [
+ '../dm/DM.cpp',
+ '../dm/DMCpuGMTask.cpp',
+ '../dm/DMExpectationsTask.cpp',
+ '../dm/DMGpuGMTask.cpp',
+ '../dm/DMPDFRasterizeTask.cpp',
+ '../dm/DMPDFTask.cpp',
+ '../dm/DMPipeTask.cpp',
+ '../dm/DMQuiltTask.cpp',
+ '../dm/DMReporter.cpp',
+ '../dm/DMSKPTask.cpp',
+ '../dm/DMSerializeTask.cpp',
+ '../dm/DMTask.cpp',
+ '../dm/DMTaskRunner.cpp',
+ '../dm/DMTestTask.cpp',
+ '../dm/DMUtil.cpp',
+ '../dm/DMWriteTask.cpp',
+ '../gm/gm.cpp',
+ '../gm/gm_expectations.cpp',
+
+ '../src/pipe/utils/SamplePipeControllers.cpp',
+ '../src/utils/debugger/SkDebugCanvas.cpp',
+ '../src/utils/debugger/SkDrawCommand.cpp',
+ '../src/utils/debugger/SkObjectParser.cpp',
+ ],
+}
diff --git a/gyp/flags.gyp b/gyp/flags.gyp
index 874a4b2..02f17dd 100644
--- a/gyp/flags.gyp
+++ b/gyp/flags.gyp
@@ -18,5 +18,22 @@
],
}
},
+ {
+ 'target_name': 'flags_common',
+ 'type': 'static_library',
+ 'sources': [
+ '../tools/flags/SkCommonFlags.cpp',
+ '../tools/flags/SkCommonFlags.h',
+ ],
+ 'dependencies': [
+ 'skia_lib.gyp:skia_lib',
+ 'flags.gyp:flags',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '../tools/flags',
+ ],
+ }
+ },
],
}
diff --git a/gyp/iOSShell.gyp b/gyp/iOSShell.gyp
index ed648a3..1cb0872 100644
--- a/gyp/iOSShell.gyp
+++ b/gyp/iOSShell.gyp
@@ -8,15 +8,18 @@
'type': 'executable',
'mac_bundle' : 1,
'includes': [
- 'tests.gypi',
- 'pathops_unittest.gypi',
+ 'bench.gypi',
+ 'dm.gypi',
],
'dependencies': [
'tools.gyp:crash_handler',
+ 'tools.gyp:timer',
'views.gyp:views',
'xml.gyp:xml',
],
'sources': [
+ '../bench/nanobench.cpp',
+ '../bench/ResultsWriter.cpp',
'../tests/skia_test.cpp',
'../tools/iOSShell.cpp',
'../src/views/mac/SkEventNotifier.mm',
diff --git a/gyp/pathops_unittest.gyp b/gyp/pathops_unittest.gyp
index b8f6835..d3152d2 100644
--- a/gyp/pathops_unittest.gyp
+++ b/gyp/pathops_unittest.gyp
@@ -10,7 +10,10 @@
'includes': [
'pathops_unittest.gypi',
],
- 'dependencies': [ 'tools.gyp:crash_handler' ],
+ 'dependencies': [
+ 'flags.gyp:flags_common',
+ 'tools.gyp:crash_handler',
+ ],
'sources': [
'../tests/PathOpsAngleIdeas.cpp',
'../tests/PathOpsCubicLineIntersectionIdeas.cpp',
diff --git a/gyp/tests.gypi b/gyp/tests.gypi
index 34e8f54..2d316c7 100644
--- a/gyp/tests.gypi
+++ b/gyp/tests.gypi
@@ -18,7 +18,7 @@
],
'dependencies': [
'experimental.gyp:experimental',
- 'flags.gyp:flags',
+ 'flags.gyp:flags_common',
'pdf.gyp:pdf',
'skia_lib.gyp:skia_lib',
'tools.gyp:picture_utils',
diff --git a/include/views/SkApplication.h b/include/views/SkApplication.h
index 8369f68..8f63539 100644
--- a/include/views/SkApplication.h
+++ b/include/views/SkApplication.h
@@ -16,4 +16,15 @@
extern void application_init();
extern void application_term();
+#ifdef SK_BUILD_FOR_IOS
+enum IOS_launch_type {
+ kError_iOSLaunchType = -1,
+ kTool_iOSLaunchType = 0,
+ kApplication__iOSLaunchType = 1
+};
+
+extern IOS_launch_type set_cmd_line_args(int argc, char *argv[],
+ const char* resourceDir);
+#endif
+
#endif // SkApplication_DEFINED
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 3f37d35..27365e0 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -2386,14 +2386,12 @@
}
#ifdef SK_BUILD_FOR_IOS
-bool set_cmd_line_args(int , char *[], const char* resourceDir) {
+IOS_launch_type set_cmd_line_args(int , char *[], const char* resourceDir) {
SetResourcePath(resourceDir);
- return false;
+ return kApplication__iOSLaunchType;
}
#endif
-// FIXME: this should be in a header
-void application_init();
void application_init() {
// setenv("ANDROID_ROOT", "../../../data", 0);
#ifdef SK_BUILD_FOR_MAC
@@ -2403,8 +2401,6 @@
SkEvent::Init();
}
-// FIXME: this should be in a header
-void application_term();
void application_term() {
SkEvent::Term();
SkGraphics::Term();
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index f4b67c9..97ac29b 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -8,7 +8,7 @@
#include "CrashHandler.h"
#include "OverwriteLine.h"
#include "Resources.h"
-#include "SkCommandLineFlags.h"
+#include "SkCommonFlags.h"
#include "SkGraphics.h"
#include "SkOSFile.h"
#include "SkTArray.h"
@@ -24,23 +24,7 @@
using namespace skiatest;
-DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n" \
- "Multiple matches may be separated by spaces.\n" \
- "~ causes a matching test to always be skipped\n" \
- "^ requires the start of the test to match\n" \
- "$ requires the end of the test to match\n" \
- "^ and $ requires an exact match\n" \
- "If a test does not match any list entry,\n" \
- "it is skipped unless some list entry starts with ~");
DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps.");
-DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects.");
-DEFINE_bool2(single, z, false, "run tests on a single thread internally.");
-DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
-DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
-DEFINE_bool(cpu, true, "whether or not to run CPU tests.");
-DEFINE_bool(gpu, true, "whether or not to run GPU tests.");
-DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
- "Run threadsafe tests on a threadpool with this many threads.");
// need to explicitly declare this, or we get some weird infinite loop llist
template TestRegistry* TestRegistry::gHead;
@@ -131,11 +115,9 @@
return true;
}
-int tool_main(int argc, char** argv);
-int tool_main(int argc, char** argv) {
+int test_main();
+int test_main() {
SetupCrashHandler();
- SkCommandLineFlags::SetUsage("");
- SkCommandLineFlags::Parse(argc, argv);
#if SK_ENABLE_INST_COUNT
if (FLAGS_leaks) {
@@ -235,7 +217,8 @@
}
#if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
-int main(int argc, char * const argv[]) {
- return tool_main(argc, (char**) argv);
+int main(int argc, char** argv) {
+ SkCommandLineFlags::Parse(argc, argv);
+ return test_main();
}
#endif
diff --git a/tools/flags/SkCommonFlags.cpp b/tools/flags/SkCommonFlags.cpp
new file mode 100644
index 0000000..7b47c58
--- /dev/null
+++ b/tools/flags/SkCommonFlags.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkCommonFlags.h"
+#include "SkThreadPool.h"
+
+DEFINE_string(config, "565 8888 pdf gpu nonrendering",
+ "Options: 565 8888 pdf gpu nonrendering msaa4 msaa16 nvprmsaa4 nvprmsaa16 "
+ "gpunull gpudebug angle mesa");
+
+DEFINE_bool(cpu, true, "master switch for running CPU-bound work.");
+
+DEFINE_bool(dryRun, false,
+ "just print the tests that would be run, without actually running them.");
+
+DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
+
+DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" "
+ "forces OpenGL API. Using \"gles\" forces OpenGL ES API. "
+ "Defaults to empty string, which selects the API native to the "
+ "system.");
+
+DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects.");
+
+DEFINE_string2(match, m, NULL,
+ "[~][^]substring[$] [...] of GM name to run.\n"
+ "Multiple matches may be separated by spaces.\n"
+ "~ causes a matching GM to always be skipped\n"
+ "^ requires the start of the GM to match\n"
+ "$ requires the end of the GM to match\n"
+ "^ and $ requires an exact match\n"
+ "If a GM does not match any list entry,\n"
+ "it is skipped unless some list entry starts with ~");
+
+DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
+
+DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each bench.");
+
+DEFINE_bool2(single, z, false, "run tests on a single thread internally.");
+
+DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
+ "run threadsafe tests on a threadpool with this many threads.");
+
+DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
+
+DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
diff --git a/tools/flags/SkCommonFlags.h b/tools/flags/SkCommonFlags.h
new file mode 100644
index 0000000..3c4910b
--- /dev/null
+++ b/tools/flags/SkCommonFlags.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SK_COMMON_FLAGS_H
+#define SK_COMMON_FLAGS_H
+
+#include "SkCommandLineFlags.h"
+
+DECLARE_string(config);
+DECLARE_bool(cpu);
+DECLARE_bool(dryRun);
+DECLARE_bool(gpu);
+DECLARE_string(gpuAPI);
+DECLARE_bool(leaks);
+DECLARE_string(match);
+DECLARE_bool(quiet);
+DECLARE_bool(resetGpuContext);
+DECLARE_bool(single);
+DECLARE_int32(threads);
+DECLARE_string(resourcePath);
+DECLARE_bool(verbose);
+DECLARE_bool(veryVerbose);
+
+#endif
diff --git a/tools/iOSShell.cpp b/tools/iOSShell.cpp
index bd70938..49be34d 100644
--- a/tools/iOSShell.cpp
+++ b/tools/iOSShell.cpp
@@ -8,9 +8,11 @@
#include "iOSShell.h"
#include "Resources.h"
+#include "SkApplication.h"
#include "SkCanvas.h"
-#include "SkCommandLineFlags.h"
+#include "SkCommonFlags.h"
#include "SkGraphics.h"
+#include "SkThreadPool.h"
#include "SkWindow.h"
#include "sk_tool_utils.h"
@@ -52,17 +54,22 @@
view->setSize(this->width(), this->height());
}
-void tool_main(int argc, char *argv[]);
+DEFINE_bool(dm, false, "run dm");
+DEFINE_bool(nanobench, false, "run nanobench");
-bool set_cmd_line_args(int argc, char *argv[], const char* resourceDir) {
- for (int index = 0; index < argc; ++index) {
- if (!strcmp("--test", argv[index])) {
- SetResourcePath(resourceDir);
- tool_main(argc - 1, argv);
- return true;
- }
+int nanobench_main();
+int dm_main();
+
+IOS_launch_type set_cmd_line_args(int argc, char *argv[], const char* resourceDir) {
+ SkCommandLineFlags::Parse(argc, argv);
+ SetResourcePath(resourceDir);
+ if (FLAGS_nanobench) {
+ return nanobench_main() ? kError_iOSLaunchType : kTool_iOSLaunchType;
}
- return false;
+ if (FLAGS_dm) {
+ return dm_main() ? kError_iOSLaunchType : kTool_iOSLaunchType;
+ }
+ return kError_iOSLaunchType;
}
// FIXME: this should be in a header