Move ndk-gdb into the host-tools package.

Bug: http://b/25454836
Change-Id: I30f4f44a6a3fefb977bc94111adfb3edc28d6ee6
diff --git a/checkbuild.py b/checkbuild.py
index edfdb59..6ed2b62 100644
--- a/checkbuild.py
+++ b/checkbuild.py
@@ -379,6 +379,12 @@
         'ndk-yasm',
     ]
 
+    files = [
+        'ndk-gdb',
+        'ndk-gdb.cmd',
+        'ndk-gdb.py',
+    ]
+
     if host in ('windows', 'windows64'):
         packages.append('toolbox')
 
@@ -390,6 +396,10 @@
         for package_name in package_names:
             package_path = os.path.join(out_dir, package_name)
             subprocess.check_call(['tar', 'xf', package_path, '-C', temp_dir])
+
+        for f in files:
+            shutil.copy2(f, os.path.join(temp_dir, 'prebuilt/bin'))
+
         package_name = 'host-tools-' + host_tag
         build_support.make_package(package_name, ['prebuilt'], out_dir,
                                    temp_dir, repo_prop_dir='prebuilt')
@@ -480,28 +490,14 @@
                                repo_prop_dir='build')
 
 def build_python_packages(out_dir, _):
-    root_dir = build_support.ndk_path()
-    files = [
-        'ndk-gdb',
-        'ndk-gdb.cmd',
-        'ndk-gdb.py',
-        '../development/python-packages',
-    ]
-
     # Stage the files in a temporary directory to make things easier.
     temp_dir = tempfile.mkdtemp()
-    def copy(path):
-        if os.path.isdir(path):
-            shutil.copytree(path, os.path.join(temp_dir, os.path.basename(path)))
-        else:
-            shutil.copy(path, temp_dir)
-
     try:
-        files = [os.path.join(root_dir, path) for path in files]
-        for f in files:
-            copy(f)
-        files = [os.path.basename(path) for path in files]
-        build_support.make_package('python-packages', files, out_dir, temp_dir,
+        shutil.copytree(
+            build_support.android_path('development/python-packages'),
+            os.path.join(temp_dir, 'python-packages'))
+        build_support.make_package('python-packages', ['python-packages'],
+                                   out_dir, temp_dir,
                                    repo_prop_dir='python-packages')
     finally:
         shutil.rmtree(temp_dir)
diff --git a/ndk-gdb.cmd b/ndk-gdb.cmd
index 8e5fabb..392eb56 100755
--- a/ndk-gdb.cmd
+++ b/ndk-gdb.cmd
@@ -1,6 +1,6 @@
 @echo off
 setlocal
-set NDK_ROOT=%~dp0
+set PREBUILT_BIN=%~dp0
 set SHELL=cmd
-"%NDK_ROOT%prebuilt/bin/python.exe" -u "%~dp0ndk-gdb" %*
+"%PREBUILT_BIN%/python.exe" -u "%~dp0ndk-gdb" %*
 endlocal
diff --git a/ndk-gdb.py b/ndk-gdb.py
index 6d61730..fba4250 100755
--- a/ndk-gdb.py
+++ b/ndk-gdb.py
@@ -32,7 +32,8 @@
 import logging
 
 # Shared functions across gdbclient.py and ndk-gdb.py.
-NDK_PATH = os.path.dirname(__file__)
+# ndk-gdb is installed to $NDK/prebuilt/bin
+NDK_PATH = os.path.normpath(os.path.join(os.path.dirname(__file__), '../..'))
 sys.path.append(os.path.join(NDK_PATH, "python-packages"))
 import gdbrunner