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