Support <include> directives in manifests.

Test: "development/tools/repo_pull/repo_pull.py pull ..." on a large topic
  from a manifest with includes.
Bug: 140113116
Change-Id: I781c9a3ca0bcdf53cc8ed1896b3ec12389e4e797
diff --git a/tools/repo_pull/repo_pull.py b/tools/repo_pull/repo_pull.py
index 79b94c5..2042614 100755
--- a/tools/repo_pull/repo_pull.py
+++ b/tools/repo_pull/repo_pull.py
@@ -26,6 +26,7 @@
 import json
 import multiprocessing
 import os
+import os.path
 import re
 import sys
 import xml.dom.minidom
@@ -170,6 +171,15 @@
     directory path."""
     project_dirs = {}
     parsed_xml = xml.dom.minidom.parse(manifest_path)
+
+    includes = parsed_xml.getElementsByTagName('include')
+    for include in includes:
+        include_path = include.getAttribute('name')
+        if not os.path.isabs(include_path):
+            manifest_dir = os.path.dirname(os.path.realpath(manifest_path))
+            include_path = os.path.join(manifest_dir, include_path)
+        project_dirs.update(build_project_name_dir_dict(include_path))
+
     projects = parsed_xml.getElementsByTagName('project')
     for project in projects:
         name = project.getAttribute('name')
@@ -178,6 +188,7 @@
             project_dirs[name] = path
         else:
             project_dirs[name] = name
+
     return project_dirs