aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2014-07-22 10:15:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-22 10:15:35 -0700
commit17f0b6df7248b9bbdaddacc3a6c9c6efe4ae278e (patch)
tree4e8140b396a43b1aee58cc0ab5fe84c63fbe2f3e /tools
parentac9779234ef7a8cf3d791ab7690ef8c388662836 (diff)
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
Diffstat (limited to 'tools')
-rw-r--r--tools/flags/SkCommonFlags.cpp50
-rw-r--r--tools/flags/SkCommonFlags.h28
-rw-r--r--tools/iOSShell.cpp27
3 files changed, 95 insertions, 10 deletions
diff --git a/tools/flags/SkCommonFlags.cpp b/tools/flags/SkCommonFlags.cpp
new file mode 100644
index 0000000000..7b47c58c6b
--- /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 0000000000..3c4910b6b4
--- /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 bd709386ec..49be34d65b 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 @@ void ShellWindow::onSizeChange() {
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;
+ }
+ if (FLAGS_dm) {
+ return dm_main() ? kError_iOSLaunchType : kTool_iOSLaunchType;
}
- return false;
+ return kError_iOSLaunchType;
}
// FIXME: this should be in a header