Add documentation for GN's GYP generation.

BUG=
R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/35933003

Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0ff08a372f26e388e35d4dc78c6760c6659bab15
diff --git a/tools/gn/command_gyp.cc b/tools/gn/command_gyp.cc
index 4d75200..de089d3 100644
--- a/tools/gn/command_gyp.cc
+++ b/tools/gn/command_gyp.cc
@@ -270,7 +270,61 @@
 const char kGyp[] = "gyp";
 const char kGyp_HelpShort[] =
     "gyp: Make GYP files from GN.";
-const char kGyp_Help[] = "Doooooom.\n";
+const char kGyp_Help[] =
+    "gyp: Make GYP files from GN.\n"
+    "\n"
+    "  This command will generate GYP files from GN sources. You can then run\n"
+    "  GYP over the result to produce a build. Native GYP targets can depend\n"
+    "  on any GN target except source sets. GN targets can depend on native\n"
+    "  GYP targets, but all/direct dependent settings will NOT be pushed\n"
+    "  across the boundary.\n"
+    "\n"
+    "  To make this work you first need to manually run GN, then GYP, then\n"
+    "  do the build. Because GN doesn't generate the final .ninja files,\n"
+    "  there will be no rules to regenerate the .ninja files if the inputs\n"
+    "  change, so you will have to manually repeat these steps each time\n"
+    "  something changes:\n"
+    "\n"
+    "    out/Debug/gn gyp\n"
+    "    python build/gyp_chromiunm\n"
+    "    ninja -C out/Debug foo_target\n"
+    "\n"
+    "  Two variables are used to control how a target relates to GYP:\n"
+    "\n"
+    "  - \"external != true\" and \"gyp_file\" is set: This target will be\n"
+    "    written to the named GYP file in the source tree (not restricted to\n"
+    "    an output or generated files directory).\n"
+    "\n"
+    "  - \"external == true\" and \"gyp_file\" is set: The target will not\n"
+    "    be written to a GYP file. But other targets being written to GYP\n"
+    "    files can depend on it, and they will reference the given GYP file\n"
+    "    name for GYP to use. This allows you to specify how GN->GYP\n"
+    "    dependencies and named, and provides a place to manually set the\n"
+    "    dependent configs from GYP to GN.\n"
+    "\n"
+    "  - \"gyp_file\" is unset: Like the previous case, but if a GN target is\n"
+    "    being written to a GYP file that depends on this one, the default\n"
+    "    GYP file name will be assumed. The default name will match the name\n"
+    "    of the current directory, so \"//foo/bar:baz\" would be\n"
+    "    \"<(DEPTH)/foo/bar/bar.gyp:baz\".\n"
+    "\n"
+    "Example:\n"
+    "  # This target is assumed to be in the GYP build in the file\n"
+    "  # \"foo/foo.gyp\". This declaration tells GN where to find the GYP\n"
+    "  # equivalent, and gives it some direct dependent settings that targets\n"
+    "  # depending on it should receive (since these don't flow from GYP to\n"
+    "  # GN-generated targets).\n"
+    "  shared_library(\"gyp_target\") {\n"
+    "    gyp_file = \"//foo/foo.gyp\"\n"
+    "    external = true\n"
+    "    direct_dependen_configs = [ \":gyp_target_config\" ]\n"
+    "  }\n"
+    "\n"
+    "  executable(\"my_app\") {\n"
+    "    deps = [ \":gyp_target\" ]\n"
+    "    gyp_file = \"//foo/myapp.gyp\"\n"
+    "    sources = ...\n"
+    "  }\n";
 
 int RunGyp(const std::vector<std::string>& args) {
   const CommandLine* cmdline = CommandLine::ForCurrentProcess();
diff --git a/tools/gn/variables.cc b/tools/gn/variables.cc
index 7345b96..ea40ade 100644
--- a/tools/gn/variables.cc
+++ b/tools/gn/variables.cc
@@ -492,7 +492,13 @@
 const char kGypFile_HelpShort[] =
     "gyp_file: [file name] Name of GYP file to write to in GYP mode.";
 const char kGypFile_Help[] =
-    "gyp_file: Name of GYP file to write to in GYP mode.\n";
+    "gyp_file: Name of GYP file to write to in GYP mode.\n"
+    "\n"
+    "  See \"gn help gyp\" for an overview of how this works.\n"
+    "\n"
+    "  Tip: If all targets in a given BUILD.gn file should go in the same\n"
+    "  GYP file, just put gyp_file = \"foo\" at the top of the file and\n"
+    "  the variable will be in scope for all targets.\n";
 
 const char kHardDep[] = "hard_dep";
 const char kHardDep_HelpShort[] =