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/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