script to create PDK build tree from existing full source tree

- This sciript generate a mount_pdk.sh which will mount existing dirs to PDK dir using mount --bind
- After mount, PDK source tree looks like normal PDK source except the absence of .repo
- The PDK build directory can be used for PDK build, and changes made are transparent to both places
Example: pdk/build/prepare_pdk_tree.py ../tmp/pdk_build grouper tegra3 broadcom_wlan
         generates necessary dir under ../tmp/pdk_build with mount_pdk.sh and umount_pdk.sh
- mount_pdk.sh requires sudo, and once executed, all necessary sources are mounted.
- umount_pdk.sh unmounts mounted files
- This change also cleans old pdk build scripts which are not used any more.

Change-Id: I49c10be366a9a4c9eb28328ab2e57db1e592d2f4
diff --git a/build/build_pdk_vendor.py b/build/build_pdk_vendor.py
deleted file mode 100755
index 624dbef..0000000
--- a/build/build_pdk_vendor.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import os, re, string, sys
-import pdk_utils as pu
-import setup_pdk_rel as setup
-
-def main(argv):
-  if len(argv) < 4:
-    print "Usage: build_pdk_vendor.py top_dir cpu_arch target_hw [lunch_target] [-jxx] [-c]"
-    print "   Runs pdk_rel build from given top_dir"
-    print "   cpu_arch: cpu arch to use like armv7-a-neon_true"
-    print "   target_hw: target H/W to build"
-    print "   lunch_target: lunch target for build. If not specified, full_target_hw-eng"
-    print "   -jxx : number of jobs for make"
-    print "   -c: clean before build"
-    sys.exit(1)
-
-  top_dir = argv[1]
-  cpu_arch = argv[2]
-  target_hw = argv[3]
-  build_j = "-j12"
-  lunch_target = "full_" + target_hw + "-eng"
-  clean_build = False
-  argv_current = 4
-  while len(argv) > argv_current:
-    arg = argv[argv_current]
-    if arg.startswith("-j"):  
-      build_j = arg
-    elif arg == "-c":
-      clean_build = True
-    else:
-      lunch_target = arg
-    argv_current += 1
-  if not os.path.isfile(top_dir + "/pdk/build/pdk_vendor.mk"):
-    print "WARNING: pdk/build/pdk_vendor.mk does not exist!!!!"
-
-  if clean_build:
-    command = "python " + top_dir + "/pdk/build/clean_pdk_rel.py " + top_dir
-    pu.execute_command(command, "cannot clean")
-
-  # setup binary and data
-  command = "python " + top_dir + "/pdk/build/setup_pdk_rel.py " + top_dir + " " \
-           + cpu_arch + " " + target_hw
-  pu.execute_command(command, "cannot copy pdk bin")
-
-  # actual build
-  command = "cd " + top_dir + " && . build/envsetup.sh && lunch " + lunch_target + " && " \
-          + "make " + build_j + " pdk_rel"
-  pu.execute_command(command, "pdk build failed")
-
-if __name__ == '__main__':
-  main(sys.argv)
diff --git a/build/clean_pdk_rel.py b/build/clean_pdk_rel.py
deleted file mode 100755
index 7306c04..0000000
--- a/build/clean_pdk_rel.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# script to clean pdk_rel source tree to allow copying new PDK bins and data
-import os, sys
-
-import pdk_utils as pu
-import setup_pdk_rel as setup
-
-def main(argv):
-  if len(argv) != 2:
-    print "Usage: clean_pdk_rel.py top_dir"
-    print "   cleans PDK data and PDK bin copied."
-    print "   Following directories are removed:"
-    print "     out"
-    print "     all files copied from pdk_data.zip, and PDK_DATA_COPIED"
-    print "     all files under " + setup.PDK_CPU_ARCH_TOP_DIR + "/pdk_bin_XXX directories" 
-    sys.exit(1)
-
-  top_dir = argv[1]
-
-  os.system("rm -rf " + top_dir + "/out")
-  pu.remove_files_listed(top_dir,
-                         pu.load_list(top_dir + "/PDK_DATA_COPIED"))
-  os.system("rm -f " + top_dir + "/PDK_DATA_COPIED")
-  os.system(" rm -rf " + top_dir + "/" + setup.PDK_CPU_ARCH_TOP_DIR + "/pdk_bin_*")
-
-if __name__ == '__main__':
-  main(sys.argv)
diff --git a/build/copy_pdk_bins.py b/build/copy_pdk_bins.py
deleted file mode 100755
index 0fa0bbe..0000000
--- a/build/copy_pdk_bins.py
+++ /dev/null
@@ -1,280 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# script to copy PDK_eng build result into a dir for PDK_rel build
-
-import os, string, sys, shutil
-import pdk_utils as pu
-
-
-# currently javalib.jar is not used and target jar is just copied in raw copy process
-def copy_jar(src_jar_dir, dest_dir, jar_name):
-  """copy classes.jar and javalib.jar to dest_dir/jar_name dir"""
-  pu.copy_file_if_exists(src_jar_dir, dest_dir + "/" + jar_name, "classes.jar")
-  pu.copy_file_if_exists(src_jar_dir, dest_dir + "/" + jar_name, "javalib.jar")
-
-def copy_classes_or_javalib(src_jar_dir, dest_dir, jar_name):
-  """For host, either classes.jar or javalib.jar is enough.
-     Use javalib only when there is no classes.jar"""
-  if pu.copy_file_new_name_if_exists(src_jar_dir + "/classes.jar", dest_dir + "/" + jar_name,
-                                     jar_name + ".jar"):
-    return
-  pu.copy_file_new_name_if_exists(src_jar_dir + "/javalib.jar", dest_dir + "/" + jar_name,
-                                  jar_name + ".jar")
-
-class DependencyMk(object):
-  def __init__(self, file_full_name):
-    self.f = open(file_full_name, "a+")
-
-  def __del__(self):
-    self.f.flush()
-    self.f.close()
-
-  def addHostA(self, a_name):
-    self.f.write("include $(CLEAR_VARS)\n")
-    self.f.write("LOCAL_PREBUILT_LIBS := " + "host/lib/" + a_name + ".a\n")
-    self.f.write("LOCAL_MODULE_TAGS := optional\n")
-    self.f.write("include $(BUILD_HOST_PREBUILT)\n")
-
-  def addHostSo(self, so_name):
-    # same as .a in makefile, distinguished by extension in build/core/multi_prebuilt.mk
-    self.f.write("include $(CLEAR_VARS)\n")
-    self.f.write("LOCAL_PREBUILT_LIBS := " + "host/lib/" + so_name + ".so\n")
-    self.f.write("LOCAL_MODULE_TAGS := optional\n")
-    self.f.write("include $(BUILD_HOST_PREBUILT)\n")
-
-  def addHostJar(self, jar_name):
-    self.f.write("include $(CLEAR_VARS)\n")
-    self.f.write("LOCAL_MODULE_TAGS := optional\n")
-    self.f.write("LOCAL_PREBUILT_JAVA_LIBRARIES := " + "host/java_lib/" + jar_name
-                 + "/" + jar_name + ".jar\n")
-    self.f.write("include $(BUILD_HOST_PREBUILT)\n")
-
-  def addTargetA(self, a_name):
-    self.f.write("include $(CLEAR_VARS)\n")
-    self.f.write("LOCAL_MODULE := " + a_name + "\n")
-    self.f.write("LOCAL_SRC_FILES := target/lib/" + a_name + ".a\n")
-    self.f.write("LOCAL_MODULE_TAGS := optional\n")
-    self.f.write("LOCAL_MODULE_SUFFIX := .a\n")
-    self.f.write("LOCAL_MODULE_CLASS := STATIC_LIBRARIES\n")
-    self.f.write("include $(BUILD_PREBUILT)\n")
-
-  def addTargetSo(self, so_name):
-    self.f.write("include $(CLEAR_VARS)\n")
-    self.f.write("LOCAL_MODULE := " + so_name + "\n")
-    self.f.write("LOCAL_SRC_FILES := target/lib/" + so_name + ".so\n")
-    self.f.write("LOCAL_MODULE_TAGS := optional\n")
-    self.f.write("LOCAL_MODULE_SUFFIX := .so\n")
-    self.f.write("LOCAL_MODULE_CLASS := SHARED_LIBRARIES\n")
-    self.f.write("LOCAL_MODULE_PATH := $(TARGET_OUT)/lib\n")
-    self.f.write("OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)\n")
-    self.f.write("include $(BUILD_PREBUILT)\n")
-
-  def addTargetJar(self, jar_name):
-    self.f.write("include $(CLEAR_VARS)\n")
-    self.f.write("LOCAL_MODULE_TAGS := optional\n")
-    self.f.write("LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := " + jar_name + ":target/java_lib/" +
-                 jar_name + "/classes.jar\n")
-    self.f.write("include $(BUILD_MULTI_PREBUILT)\n")
-
-  def addString(self, message):
-    self.f.write(message)
-
-# individual files top copy as it is
-# product/maguro will be substituted into product/target_name later
-raw_file_list = [
-# "target/common/obj/PACKAGING/public_api.txt",
-  "host/linux-x86/bin/dx",
-  "host/linux-x86/bin/aapt",
-  # necessary for bootstrapping in host as the path is always assumed
-  "host/common/obj/JAVA_LIBRARIES/core-hostdex_intermediates/classes.jar",
-  "host/common/obj/JAVA_LIBRARIES/core-hostdex_intermediates/javalib.jar",
-  "host/common/obj/JAVA_LIBRARIES/core-junit-hostdex_intermediates/classes.jar",
-  "host/common/obj/JAVA_LIBRARIES/core-junit-hostdex_intermediates/javalib.jar",
-  # these permission stuffs are not copied as frameworks is not built
-  "target/product/maguro/system/etc/permissions/com.android.location.provider.xml",
-  "target/product/maguro/system/etc/permissions/platform.xml",
-  ]
-
-# the whole dir to copy as it is
-raw_dir_list = [
-  "target/product/maguro/system/etc/dhcpcd",
-  "target/product/maguro/system/etc/ppp",
-  "target/product/maguro/system/app",
-  "target/product/maguro/system/bin",
-  "target/product/maguro/system/etc/security",
-  "target/product/maguro/system/framework",
-  "target/product/maguro/system/lib",
-  # tools for debugging, not all of them are built in pdk_rel build
-  "target/product/maguro/system/xbin"
-  ]
-
-# from host/linux-x86/obj/STATIC_LIBRARIES/XYZ_intermediates
-host_a_list = [
-  "libandroidfw",
-  "libRS"
-  ]
-
-# from host/linux-x86/obj/lib
-host_so_list = [
-  ]
-
-# from host/commom/JAVA_LIBRARIES/XYZ_intermediates
-host_jar_list = [
-  "core-hostdex",
-  "dx",
-  "core-junit-hostdex"
-  ]
-
-# from target/product/product_name/obj/STATIC_LIBRARIES/XYZ_intermediates
-target_a_list = [
-  "libdrmframeworkcommon",
-  "libcpustats",
-  "libv8",
-  "libmedia_helper"
-  ]
-
-# from target/product/product_name/obj/lib
-target_so_list = [
-  "libandroid",
-  "libandroidfw",
-  "libandroid_runtime",
-  "libandroid_servers",
-  "libjnigraphics",
-  "libnativehelper",
-  "libemoji",
-  "libdrmframework",
-  "libdvm",
-  "libchromium_net",
-  "libcamera_client",
-  "libmedia",
-  "libstagefright",
-  "libstagefright_foundation",
-  "libRS",
-  "libmedia_native" # TODO temp fix for build error: should be removed after moving to f/native
-  ]
-
-
-# from target/common/obj/JAVA_LIBRARIES
-target_jar_list = [
-  "core",
-  "core-junit",
-  "ext",
-  "framework",
-  "android.test.runner",
-  "android_stubs_current",
-  "filterfw"
-  ]
-
-# files unnecessarily built for PDK. remove after copy
-raw_target_files_to_remove = [
-  # redundant
-  "target/product/maguro/system/app/Home.apk",
-  # stingray build included due to wrong mk file
-  "target/product/maguro/system/app/StingrayProgramMenu*.apk",
-  "target/product/maguro/system/app/SprintMenu.apk",
-  "target/product/maguro/system/app/WiMAX*.apk",
-  # wallpaper, not necessary
-  "target/product/maguro/system/app/Microbes.apk",
-  # H/W depedent anyway
-  "target/procuct/maguro/system/hw",
-  "target/product/maguro/system/lib/hw",
-  "target/product/maguro/system/lib/libOMX.SEC.*.so",
-  "target/product/maguro/system/lib/libSEC_OMX*.so",
-  "target/product/maguro/system/lib/libWiMAX*.so",
-  "target/product/maguro/system/lib/libOMX.TI.*.so",
-  "target/product/maguro/system/lib/libOMX_Core.so"
-  ]
-
-def main(argv):
-  if len(argv) != 4:
-    print "Usage: copy_pdk_bins.py src_top_dir dest_top_dir src_target_device"
-    print "   ex: copy_pdk_bins.py ../master vendor/pdk_bin_j_arm maguro"
-    sys.exit(1)
-  src_top_dir = argv[1]
-  src_out_dir = argv[1] + "/out/"
-  dest_top_dir = argv[2]
-  target_name = argv[3]
-
-  # now replace product/maguro to product/target_name for all lists
-  replacement_list = [
-    raw_file_list,
-    raw_dir_list,
-    raw_target_files_to_remove
-    ]
-  for dir_list in replacement_list:
-    for i in xrange(len(dir_list)):
-      replacement = dir_list[i].replace("product/maguro", "product/" + target_name)
-      dir_list[i] = replacement
-
-  src_target_top_dir = src_out_dir + "/target/product/" + target_name + "/"
-  # delete existing binaries
-  os.system("rm -rf " + dest_top_dir + "/host")
-  os.system("rm -rf " + dest_top_dir + "/raw_copy")
-  os.system("rm -rf " + dest_top_dir + "/target")
-  # copy template for mk
-  pu.copy_file_if_exists(src_top_dir + "/pdk/build", dest_top_dir, "pdk_prebuilt.mk")
-  mkFile = DependencyMk(dest_top_dir + "/pdk_prebuilt.mk")
-  mkFile.addString("\n\n\n")
-  mkFile.addString("PDK_BIN_ORIGINAL_TARGET := " + target_name + "\n")
-
-  for file_name in raw_file_list:
-    pu.copy_file_if_exists(src_out_dir, dest_top_dir + "/raw_copy", file_name)
-
-  for raw_dir in raw_dir_list:
-    pu.copy_dir(src_out_dir, dest_top_dir + "/raw_copy", raw_dir)
-
-  for host_a in host_a_list:
-    pu.copy_file_if_exists(src_out_dir + "/host/linux-x86/obj/STATIC_LIBRARIES/" + host_a +
-                           "_intermediates", dest_top_dir + "/host/lib", host_a + ".a")
-    mkFile.addHostA(host_a)
-
-  for host_so in host_so_list:
-    pu.copy_file_if_exists(src_out_dir + "/host/linux-x86/obj/lib/",
-                           dest_top_dir + "/host/lib", host_so + ".so")
-    mkFile.addHostSo(host_so)
-
-  src_host_jar_top = src_out_dir + "/host/common/obj/JAVA_LIBRARIES/"
-  for host_jar in host_jar_list:
-    src_host_jar_dir = src_host_jar_top + host_jar + "_intermediates/"
-    copy_classes_or_javalib(src_host_jar_dir, dest_top_dir + "/host/java_lib/", host_jar)
-    mkFile.addHostJar(host_jar)
-
-  for target_a in target_a_list:
-    pu.copy_file_if_exists(src_target_top_dir + "obj/STATIC_LIBRARIES/" + target_a +
-                           "_intermediates", dest_top_dir + "/target/lib", target_a + ".a")
-    mkFile.addTargetA(target_a)
-
-  for target_so in target_so_list:
-    pu.copy_file_if_exists(src_target_top_dir + "obj/lib/",
-                           dest_top_dir + "/target/lib", target_so + ".so")
-    mkFile.addTargetSo(target_so)
-
-  src_target_jar_top = src_out_dir + "/target/common/obj/JAVA_LIBRARIES/"
-  for target_jar in target_jar_list:
-    src_target_jar_dir = src_target_jar_top + target_jar + "_intermediates/"
-    copy_jar(src_target_jar_dir, dest_top_dir + "/target/java_lib", target_jar)
-    mkFile.addTargetJar(target_jar)
-
-  for file_to_remove in raw_target_files_to_remove:
-    os.system("rm -rf " + dest_top_dir + "/raw_copy/" + file_to_remove)
-
-  # rename raw_copy/target/product/target_name to target/product/pdk_target
-  os.system("mv " + dest_top_dir + "/raw_copy/target/product/" + target_name \
-             + " " + dest_top_dir + "/raw_copy/target/product/pdk_target")
-
-if __name__ == '__main__':
-  main(sys.argv)
diff --git a/build/copy_pdk_data.py b/build/copy_pdk_data.py
deleted file mode 100755
index 6a34f36..0000000
--- a/build/copy_pdk_data.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# script to copy necessary data / source for PDK build from
-# the current and the previous branch
-
-import os, string, sys, shutil
-import pdk_utils as pu
-import create_source_tree as tree
-
-def clean_dest_dirs(dest_vendor_data):
-  dir_to_clean = []
-  dir_to_clean += tree.prev_copy_dir_list
-  dir_to_clean += tree.additional_dir_pdk_rel_list
-  print dir_to_clean
-  for file_name in tree.copy_files_pdk_rel_list:
-    [path, name] = file_name.rsplit("/", 1)
-    print path
-    dir_to_clean.append(path)
-
-  for dir_name in dir_to_clean:
-    dir_path = dest_vendor_data + "/" + dir_name
-    print "deleting all files under " + dir_path
-    if os.path.isfile(dir_path):
-      # this is wrong, just remove the file
-      os.system("rm " + dir_path)
-    if os.path.isdir(dir_path):
-      file_list = pu.list_files(dir_path, ".git")
-      print file_list
-      for file_name in file_list:
-        os.system("rm " + file_name)
-
-def main(argv):
-  if len(argv) < 4:
-    print "Usage: copy_pdk_data.py current previous dest_dir [-c]"
-    print "   ex: copy_pdk_data.py ../jb_master ../ics_master ./out/target/pdk_data"
-    print "   -c to clean dest_dir"
-    sys.exit(1)
-  current_branch = os.path.abspath(argv[1])
-  previous_branch = os.path.abspath(argv[2])
-  dest_dir = os.path.abspath(argv[3])
-
-  cp_option = ""
-  if len(argv) == 5 and argv[4] == "-c":
-    clean_dest_dirs(dest_dir)
-    cp_option = "-n" # do not overwrite
-
-  for dir_name in tree.prev_copy_dir_list:
-    pu.copy_dir(previous_branch, dest_dir, dir_name, cp_option)
-
-  for dir_name in tree.additional_dir_pdk_rel_list:
-    pu.copy_dir(current_branch, dest_dir, dir_name, cp_option)
-
-  for file_name in tree.copy_files_pdk_rel_list:
-    pu.copy_files(current_branch, dest_dir, file_name)
-
-if __name__ == '__main__':
-  main(sys.argv)
diff --git a/build/create_source_tree.py b/build/create_source_tree.py
deleted file mode 100755
index e4aea2a..0000000
--- a/build/create_source_tree.py
+++ /dev/null
@@ -1,221 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# script to create minimal source tree for pdk_eng / pdk_rel build
-# pdk/build/pdk.mk file will be checked to detect necessary files
-# together with additional addition in this script for build dependency
-
-import os, string, sys, shutil
-import pdk_utils as pu
-
-
-def get_one_var_occurrence(f, dir_list_var):
-  dir_list = []
-  for line in f:
-    start = line.find(dir_list_var)
-    if (start != -1) and (line[0] != "#"): # found the pattern
-      break
-  # it can be eof, but the next for-loop will filter it out
-  for line in f:
-    words = line.split()
-    #print words
-    if len(words) > 0:
-      dir_list.append(words[0])
-    if len(words) != 2:
-      break
-  return dir_list
-
-def extract_build_dir(makefile, dir_list_var):
-  f = open(makefile, "r")
-  dir_list = []
-  while 1:
-    list_found = get_one_var_occurrence(f, dir_list_var)
-    if len(list_found) == 0:
-      break;
-    dir_list += list_found
-  f.close();
-  return dir_list
-
-def create_symbolic_link(src_top, dest_top, dir_name):
-  src_full = src_top + "/" + dir_name
-  dest_full = dest_top + "/" + dir_name
-  print "create symbolic link from " + dest_full + " to " + src_full
-  # remove existing link first to prevent recursive loop
-  os.system("rm -rf " + dest_full)
-  os.system("ln -s " + src_full + " " + dest_full)
-
-
-# when these dirs are copied as a whlole, only symbolic link will be created
-# instead of full copying. These dirs should not be overwritten or replaced by copy
-symbolic_link_list = [
-  "bionic",
-  "build",
-  "dalvik",
-  "development",
-  "external",
-  "external/clang",
-  "external/llvm",
-  "libcore",
-  "pdk",
-  "prebuilt",
-  "prebuilts",
-  "sdk",
-  "system"
-]
-
-# the whole dir copied
-additional_dir_list = [
-  "pdk"
-  ]
-
-# these dirs will be direcly pulled as the whole git.
-# so these files will not go under vendor/pdk/data
-additional_dir_pdk_rel_list_git = [
-  "external/libnl-headers",
-  "external/proguard",
-  "external/v8",
-  "external/safe-iop",
-]
-
-additional_dir_pdk_rel_list = [
-  "frameworks/base/build",
-  "frameworks/base/cmds/dumpstate",
-  "frameworks/base/include/androidfw",
-  "frameworks/base/include/android_runtime",
-  "frameworks/base/native/include",
-  "dalvik/libnativehelper/include",
-  "system/media/audio_effects/include", # should be removed after refactoring
-  "frameworks/base/include/drm", # for building legacy HAL, not in PDK release?
-  "frameworks/base/include/media", # for building legacy HAL, not in PDK release?
-  "frameworks/base/libs/rs/scriptc" # may remove after refactoring RS
-  ]
-
-# only files under the dir is copied, not subdirs
-dir_copy_only_files_list = [
-  ]
-
-copy_files_list = [
-  "Makefile"
-  ]
-
-copy_files_pdk_rel_list = [
-  "libcore/include/UniquePtr.h", # by h/libhardware/tests/keymaster
-  "frameworks/base/media/libeffects/data/audio_effects.conf",
-  "development/data/etc/apns-conf_sdk.xml",
-  "development/data/etc/vold.conf"
-  ]
-
-prev_copy_dir_list = [
-  "frameworks/base/data"
-  ]
-
-# for PDK_ENG build only, use old version
-prev_copy_dir_pdk_eng_list = [
-  "packages/apps/Bluetooth",
-  "packages/inputmethods/LatinIME",
-  "packages/providers/ApplicationsProvider",
-  "packages/providers/CalendarProvider",
-  #"packages/providers/DownloadProvider", old version does not build
-  "packages/providers/GoogleContactsProvider",
-  "packages/providers/TelephonyProvider",
-  "packages/providers/ContactsProvider",
-  "packages/providers/DrmProvider",
-  "packages/providers/MediaProvider",
-  "packages/providers/UserDictionaryProvider"
-  ]
-
-# not necessary although copied due to the dir list from pdk.mk
-files_to_remove = [
-  "vendor/moto/olympus",
-  "vendor/samsung/manta",
-  "vendor/samsung/mysidspr",
-  "vendor/samsung/toro",
-  "vendor/samsung/crespo", # should be removed when crespo is supproted
-  "vendor/nvidia/proprietary-tegra3",
-  "packages/providers/BrowserProvider",
-  "hardware/ti/omap4xxx/test/CameraHal" # cannot build with PDK source
-  ]
-
-def main(argv):
-  if len(argv) < 5:
-    print "Usage: create_source_tree.py pdk_type(eng or rel) current_src_top_dir prev_src_top_tree dest_top_dir"
-    print "   ex: create_source_tree.py eng ../jb_master ../ics_master /pdk_eng_source"
-    sys.exit(1)
-  pdk_eng = (argv[1] == "eng")
-  src_top_dir = os.path.abspath(argv[2])
-  prev_src_top_dir = os.path.abspath(argv[3])
-  dest_top_dir = os.path.abspath(argv[4])
-
-  full_copy = True
-  # hidden command for initial testing of manually added parts
-  if len(argv) == 6:
-    if argv[5] == "0":
-      full_copy = False
-  dir_list = []
-  if full_copy:
-    dir_list += extract_build_dir(src_top_dir + "/pdk/build/pdk.mk", "BUILD_PDK_SUBDIRS")
-    dir_list += extract_build_dir(src_top_dir + "/pdk/build/pdk_google.mk", "BUILD_PDK_SUBDIRS")
-    if pdk_eng:
-      dir_list += extract_build_dir(src_top_dir + "/pdk/build/pdk.mk", "BUILD_PDK_ENG_SUBDIRS")
-    else:
-      dir_list += extract_build_dir(src_top_dir + "/pdk/build/pdk.mk", "BUILD_PDK_REL_SUBDIRS")
-
-  dir_list += additional_dir_list
-  if not pdk_eng:
-    dir_list += additional_dir_pdk_rel_list_git
-    dir_list += additional_dir_pdk_rel_list
-  for dir_prev_version in prev_copy_dir_list:
-    if dir_prev_version in dir_list:
-      dir_list.remove(dir_prev_version)
-  print "copy list", dir_list
-
-  os.system("mkdir -p " + dest_top_dir)
-  for dir_name in dir_list:
-    if dir_name in symbolic_link_list:
-      create_symbolic_link(src_top_dir, dest_top_dir, dir_name)
-    else:
-      pu.copy_dir(src_top_dir, dest_top_dir, "/" + dir_name)
-
-  for dir_name in dir_copy_only_files_list:
-    pu.copy_dir_only_file(src_top_dir, dest_top_dir, "/" + dir_name)
-
-  copy_files_list_ = copy_files_list
-  if not pdk_eng:
-    copy_files_list_ += copy_files_pdk_rel_list
-  for file_name in copy_files_list_:
-    pu.copy_files(src_top_dir, dest_top_dir, "/" + file_name)
-
-  # overwrite files
-  pu.copy_files(src_top_dir + "/vendor/pdk/data/google/overwrite", dest_top_dir, "/*")
-
-  for file_name in files_to_remove:
-    os.system("rm -rf " + dest_top_dir + "/" + file_name)
-
-  prev_copy_dir_list_ = []
-  prev_copy_dir_list_ += prev_copy_dir_list
-  if pdk_eng:
-    prev_copy_dir_list_ += prev_copy_dir_pdk_eng_list
-  print "use ICS version for ", prev_copy_dir_list_
-  for dir_name in prev_copy_dir_list_:
-    os.system("rm -rf " + dest_top_dir + "/" + dir_name)
-    if dir_name in symbolic_link_list:
-      create_symbolic_link(prev_src_top_dir, dest_top_dir, dir_name)
-    else:
-      pu.copy_dir(prev_src_top_dir, dest_top_dir, "/" + dir_name)
-
-if __name__ == '__main__':
-  main(sys.argv)
diff --git a/build/pdk.mk b/build/pdk.mk
deleted file mode 100644
index 914185c..0000000
--- a/build/pdk.mk
+++ /dev/null
@@ -1,198 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# common build dirs for pdk_eng and pdk_rel builds
-# this list should be minimal to make pdk_rel build fast
-
-# BUILD_PDK_SUBDIRS is parsed by a script to extract source tree list automatically.
-# To make that parsing simple, the first line should not include any explicit directory name.
-BUILD_PDK_SUBDIRS := \
-	abi \
-	bionic \
-	bootable \
-	build \
-	prebuilt \
-	prebuilts
-
-
-# if pdk_vendor.mk exist, do not include pdk_google.mk
-# pdk_vendor.mk should add more dirs for pdk_rel build
-# that is, it should include BUILD_PDK_SUBDIRS += \ to add additional dir for build
-ifneq (,$(wildcard $(TOPDIR)pdk/build/pdk_vendor.mk))
-include $(TOPDIR)pdk/build/pdk_vendor.mk
-else
-include $(TOPDIR)pdk/build/pdk_google.mk
-endif
-
-ifeq ($(PDK_BUILD_TYPE), pdk_eng)
-# addition for pdk_eng
-BUILD_PDK_ENG_SUBDIRS := \
-	dalvik \
-	development \
-	device \
-	external \
-	frameworks \
-	hardware \
-	libcore \
-	packages/apps/Bluetooth \
-	packages/apps/Launcher2 \
-	packages/apps/Settings \
-	packages/inputmethods/LatinIME \
-	packages/providers \
-	sdk \
-	system
-
-
-BUILD_PDK_SUBDIRS += $(BUILD_PDK_ENG_SUBDIRS)
-
-ifeq ($(TARGET_CPU_SMP), true)
-PDK_BIN_NAME := pdk_bin_$(TARGET_ARCH_VARIANT)_true
-else # !SMP
-PDK_BIN_NAME := pdk_bin_$(TARGET_ARCH_VARIANT)_false
-endif # !SMP
-
-.PHONY: pdk_bin_zip pdk_data_zip
-pdk_bin_zip: $(OUT_DIR)/target/$(PDK_BIN_NAME).zip pdk_data_zip
-
-
-$(OUT_DIR)/target/$(PDK_BIN_NAME).zip: $(OUT_DIR)/target/$(PDK_BIN_NAME)
-	$(info Creating $(OUT_DIR)/target/$(PDK_BIN_NAME).zip)
-	$(hide) cd $(dir $@) && rm -rf $(notdir $@) && cd $(PDK_BIN_NAME) && zip -rq ../$(notdir $@) *
-
-# explicitly put dependency on two final images to avoid copying every time
-# It is too early and INSTALLED_SYSTEMIMAGE is not defined yet.
-$(OUT_DIR)/target/$(PDK_BIN_NAME): $(OUT_DIR)/target/product/$(TARGET_DEVICE)/boot.img \
-                                   $(OUT_DIR)/target/product/$(TARGET_DEVICE)/system.img
-	python $(TOPDIR)pdk/build/copy_pdk_bins.py . $(OUT_DIR)/target/$(PDK_BIN_NAME) $(TARGET_DEVICE)
-
-pdk_data_zip: $(OUT_DIR)/target/pdk_data.zip
-
-$(OUT_DIR)/target/pdk_data.zip: $(OUT_DIR)/target/pdk_data
-	$(info Creating $(OUT_DIR)/target/pdk_data.zip)
-	$(hide) cd $(dir $@) && rm -rf $(notdir $@) && cd pdk_data && zip -rq ../$(notdir $@) *
-
-$(OUT_DIR)/target/pdk_data:  $(OUT_DIR)/target/product/$(TARGET_DEVICE)/boot.img \
-                             $(OUT_DIR)/target/product/$(TARGET_DEVICE)/system.img
-	python $(TOPDIR)pdk/build/copy_pdk_data.py . . $(OUT_DIR)/target/pdk_data
-
-else # pdk_rel
-
-# overwrite the definition from conflig.mk, no package build in pdk_rel
-BUILD_PACKAGE :=
-
-# addition for pdk_rel
-BUILD_PDK_REL_SUBDIRS := \
-	device/common \
-	device/sample \
-	external/antlr \
-	external/bluetooth \
-	external/bsdiff \
-	external/bzip2 \
-	external/clang \
-	external/dbus \
-	external/doclava \
-	external/expat \
-	external/fdlibm \
-	external/flac \
-	external/freetype \
-	external/gcc-demangle \
-	external/giflib \
-	external/gtest \
-	external/guava \
-	external/icu4c \
-	external/jhead \
-	external/jpeg \
-	external/jsilver \
-	external/jsr305 \
-	external/liblzf \
-	external/libpng \
-	external/libvpx \
-	external/llvm \
-	external/mksh \
-	external/openssl \
-	external/protobuf \
-	external/sonivox \
-	external/speex \
-	external/stlport \
-	external/tinyalsa \
-	external/tremolo \
-	external/wpa_supplicant \
-	external/wpa_supplicant_6 \
-	external/wpa_supplicant_8 \
-	external/yaffs2 \
-	external/zlib \
-	frameworks/base/data \
-	frameworks/compile \
-	frameworks/native \
-	hardware/libhardware \
-	hardware/libhardware_legacy \
-	hardware/ril \
-	system/bluetooth \
-	system/core \
-	system/extras \
-	system/media/audio_utils \
-	system/netd \
-	system/security \
-	system/vold
-
-# system should be put back to common list once system/media is refactored
-
-BUILD_PDK_SUBDIRS += $(BUILD_PDK_REL_SUBDIRS)
-
-# naming convention for bin repository: pdk_bin_CPUArch_SMPSupport
-# ex: pdk_bin_armv7-a_true (armv7-a with SMP support)
-ifeq ($(TARGET_CPU_SMP), true)
-PDK_BIN_PRIMARY := pdk_bin_$(TARGET_ARCH_VARIANT)_true
-# this dir will not exist, so SMP CPU requires SMP version
-PDK_BIN_SECONDARY := pdk_bin_no_such_dir
-else # !SMP
-PDK_BIN_PRIMARY := pdk_bin_$(TARGET_ARCH_VARIANT)_false
-# if non-SMP binary does not exist, use SMP version
-PDK_BIN_SECONDARY := pdk_bin_$(TARGET_ARCH_VARIANT)_true
-endif # !SMP
-
-PDK_BIN_VENDOR_TOP_DIR := $(TOPDIR)vendor/pdk/data/partner
-
-ifneq (,$(wildcard $(PDK_BIN_VENDOR_TOP_DIR)/$(PDK_BIN_PRIMARY)))
-PDK_BIN_REPOSITORY := $(PDK_BIN_VENDOR_TOP_DIR)/$(PDK_BIN_PRIMARY)
-else # !PRIMARY
-ifneq (,$(wildcard $(PDK_BIN_VENDOR_TOP_DIR)/$(PDK_BIN_SECONDARY)))
-$(info PDK_BIN using secondary option $(PDK_BIN_SECONDARY) for build)
-PDK_BIN_REPOSITORY := $(PDK_BIN_VENDOR_TOP_DIR)/$(PDK_BIN_SECONDARY)
-else # !SECONDARY
-$(error Neither $(PDK_BIN_VENDOR_TOP_DIR)/$(PDK_BIN_PRIMARY) nor \
-  $(PDK_BIN_VENDOR_TOP_DIR)/$(PDK_BIN_SECONDARY) exists.)
-endif # !SECONDARY
-endif # !PRIMARY
-
-
-include $(PDK_BIN_REPOSITORY)/pdk_prebuilt.mk
-
-ifeq ($(PDK_BIN_ORIGINAL_TARGET), )
-$(error PDK_BIN_ORIGINAL_TARGET not set in $(PDK_BIN_REPOSITORY)/pdk_prebuilt.mk)
-endif
-
-ifeq (,$(wildcard $(OUT_DIR)/target/product/$(TARGET_DEVICE)/PDK_BIN_COPIED))
-$(error PDK binaries necessary for pdk_rel build are not there! Did you run setup_pdk_rel.py? )
-endif # PDK_BIN_COPIED
-
-ifeq (,$(wildcard $(TOPDIR)PDK_DATA_COPIED))
-$(error PDK data necessary for pdk_rel build are not there! Did you run setup_pdk_rel.py? )
-endif # PDK_DATA_COPIED
-
-PRODUCT_PACKAGES += core core-junit
-
-endif # pdk_rel
diff --git a/build/pdk_google.mk b/build/pdk_google.mk
deleted file mode 100644
index 639f7c7..0000000
--- a/build/pdk_google.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# subdirs for building pdk_eng/pdk_rel for maruro/crespo
-BUILD_PDK_SUBDIRS += \
-	device/samsung/tuna \
-	device/samsung/maguro \
-	device/ti/panda \
-	hardware/broadcom \
-	hardware/invensense \
-	hardware/ti/omap4xxx \
-	vendor/broadcom \
-	vendor/invensense \
-	vendor/khronos \
-	vendor/nxp/pn544 \
-	vendor/samsung \
-	vendor/ti
-
-
-
diff --git a/build/pdk_prebuilt.mk b/build/pdk_prebuilt.mk
deleted file mode 100644
index 82a2eb9..0000000
--- a/build/pdk_prebuilt.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-
-# This file under pdk/build is the template for the same file under vendor/pdk
-# The file under vendor/pdk is automatically generated, and should not be manually edited.
-
-LOCAL_PATH := $(call my-dir)
-
diff --git a/build/prepare_pdk_tree.py b/build/prepare_pdk_tree.py
new file mode 100755
index 0000000..4be9744
--- /dev/null
+++ b/build/prepare_pdk_tree.py
@@ -0,0 +1,146 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the 'License');
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an 'AS IS' BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# prepare_pdk_tree.py target_dir [-m manifest] pdk_groups
+# Ex: prepare_pdk_tree.py ../tmp/pdk grouper
+# create mount_pdk.sh and umount_pdk.sh, which mounts/umounts pdk sources.
+
+import os
+import re
+import sys
+import subprocess
+
+
+class ManifestHandler(object):
+
+    def __init__(self):
+        # current pattern
+        self.current = 0
+        self.patterns = [re.compile('path=\"([^\"]*)\".*groups=\"([^\"]*)\"'), \
+                         re.compile('groups=\"([^\"]*)\".*path=\"([^\"]*)\"')]
+
+    def getAttribs(self, line):
+        attrib = [None, None] # list of path, groups
+        m = self.patterns[self.current].search(line)
+        # if match fails, try both pattens and change default one
+        # if match founds
+        if m is None:
+            notCurrent = 1 - self.current
+            mOther = self.patterns[notCurrent].search(line)
+            if mOther is not None:
+                # toggle
+                self.current = notCurrent
+                m = mOther
+        if m is not None:
+            if (self.current == 0):
+                attrib[0] = m.group(1)
+                attrib[1] = m.group(2)
+            else:
+                attrib[0] = m.group(2)
+                attrib[1] = m.group(1)
+        return attrib
+
+def isInGroups(groupsAttrib, groups):
+    if groupsAttrib is None:
+        return False
+    for group in groups:
+        if group in groupsAttrib:
+            return True
+    return False
+
+def getPDKDirs(manifest, groups):
+    subdirs = []
+    handler = ManifestHandler()
+    f = open(manifest, 'r')
+    for line in f:
+        [path, groupsAttrib] = handler.getAttribs(line)
+        if isInGroups(groupsAttrib, groups):
+            subdirs.append(path)
+    f.close()
+    return subdirs
+
+def create_symbolic_link(src_top, dest_top, dir_name):
+    src_full = src_top + "/" + dir_name
+    dest_full = dest_top + "/" + dir_name
+    #print "create symbolic link from " + dest_full + " to " + src_full
+    # remove existing link first to prevent recursive loop
+    os.system("rm -rf " + dest_full)
+    os.system("ln -s " + src_full + " " + dest_full)
+
+# The only file not from manifest.
+copy_files_list = [ "Makefile" ]
+MOUNT_FILE = 'mount_pdk.sh'
+UMOUNT_FILE = 'umount_pdk.sh'
+SH_HEADER = "#!/bin/bash\n#Auto-generated file, do not edit!\n"
+
+def main(argv):
+    manifestFile = ".repo/manifest.xml"
+    groups = ["pdk"]
+    if len(argv) < 2:
+        print "create_pdk_tree.py target_dir [-m manifest] pdk_groups"
+        print " ex) create_pdk_tree.py ../tmp grouper"
+        print " Note that pdk group is included by default"
+        print " Do not create target_dir under the current source tree. This will cause build error."
+        sys.exit(1)
+    targetDir = argv[1]
+    argc = 2
+    if len(argv) > 2:
+        if argv[2] == "-m":
+            manifestFile = argv[3]
+            argc += 2
+    while argc < len(argv):
+        groups.append(argv[argc])
+        argc += 1
+    sourceDir = os.path.abspath('.')
+    targetDir = os.path.abspath(targetDir)
+
+    p = subprocess.Popen("mount", stdout = subprocess.PIPE)
+    targetMounted = False
+    for line in p.stdout:
+        if targetDir in line:
+            targetMounted = True
+    p.stdout.close()
+
+    if targetMounted:
+        print "target dir already mounted"
+        if os.path.exists(targetDir + '/' + UMOUNT_FILE):
+            print "Use existing file", UMOUNT_FILE, "to unmount"
+            sys.exit(1)
+        else:
+            print "Will create scripts, but may need manual unmount"
+
+    subdirs = getPDKDirs(manifestFile, groups)
+    print subdirs
+    os.system("mkdir -p " + targetDir)
+    mountf = open(targetDir + '/' + MOUNT_FILE, 'w+')
+    mountf.write(SH_HEADER)
+    umountf = open(targetDir + '/' + UMOUNT_FILE, 'w+')
+    umountf.write(SH_HEADER)
+    for subdir in subdirs:
+        os.system("mkdir -p " + targetDir + '/' + subdir)
+        mountf.write("mount --bind " + sourceDir + "/" + subdir + " " + targetDir + "/" + subdir + \
+                        "\n")
+        umountf.write("umount " + sourceDir + "/" + subdir + "\n")
+    for file_name in copy_files_list:
+        create_symbolic_link(sourceDir, targetDir, file_name)
+    mountf.close()
+    umountf.close()
+    os.system("chmod 700 " + targetDir + '/' + MOUNT_FILE)
+    os.system("chmod 700 " + targetDir + '/' + UMOUNT_FILE)
+
+if __name__ == '__main__':
+    main(sys.argv)
diff --git a/build/setup_pdk_rel.py b/build/setup_pdk_rel.py
deleted file mode 100755
index 75b90f7..0000000
--- a/build/setup_pdk_rel.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# script to prepare pdk_rel branches for build.
-# This should be run after every make clean as necessary files will be deleted
-# TODO : set up source code as well
-
-import os, re, string, sys
-import pdk_utils as pu
-
-PDK_BIN_PREFIX = "pdk_bin_"
-PDK_BIN_TOP_DIR = "/vendor/pdk/data/partner/bin"
-PDK_CPU_ARCH_TOP_DIR = "/vendor/pdk/data/partner"
-PDK_DATA_TOP_DIR = "/vendor/pdk/data/partner/data"
-
-def list_available_pdk_bins(path):
-  """returns the list of pdk_bin_* dir under the given path"""
-  pdk_bins_dict = {}
-
-  file_list = pu.list_files(os.path.abspath(path))
-  for file_name in file_list:
-    m = re.search(PDK_BIN_PREFIX + "(.*)\.zip$", file_name)
-    if m != None:
-      print " pdk_bin for arch " + m.group(1) + " @ " + file_name
-      pdk_bins_dict[m.group(1)] = file_name
-  return pdk_bins_dict
-
-def main(argv):
-  if len(argv) != 4:
-    print "Usage: setup_pdk_rel.py top_dir cpu_conf target_hw"
-    print "   ex: setup_pdk_rel.py pdk_rel_source armv7-a-neon_true maguro"
-    sys.exit(1)
-  top_dir = argv[1]
-  cpu_conf = argv[2]
-  target_hw = argv[3]
-
-  pdk_bins_dict = list_available_pdk_bins(top_dir + PDK_BIN_TOP_DIR)
-
-  if not (cpu_conf in pdk_bins_dict):
-    print "Specified cpu_conf", cpu_conf, "not avaialble under", top_dir + PDK_BIN_TOP_DIR
-    print "Avaiable configurations are ", pdk_bins_dict.keys()
-    sys.exit(1)
-
-  pdk_bin_zip = pdk_bins_dict[cpu_conf]
-  pdk_data_zip = top_dir + PDK_DATA_TOP_DIR + "/pdk_data.zip"
-  pdk_partner_data_cpu_path = top_dir + PDK_CPU_ARCH_TOP_DIR + "/" + PDK_BIN_PREFIX + cpu_conf
-  PDK_BIN_COPIED = top_dir + "/out/target/product/" + target_hw + "/PDK_BIN_COPIED"
-  PDK_DATA_COPIED = top_dir + "/PDK_DATA_COPIED"
-
-  copy_out_dir = pu.src_newer_than_dest(pdk_bin_zip, PDK_BIN_COPIED)
-  copy_partner_data_cpu = pu.src_newer_than_dest(pdk_bin_zip, pdk_partner_data_cpu_path)
-  copy_pdk_data = pu.src_newer_than_dest(pdk_data_zip, PDK_DATA_COPIED)
-
-  if copy_out_dir:
-    print "copy pdk bins to out"
-    # clean out as binary is changed
-    pu.remove_if_exists(top_dir + "/out")
-    command = "mkdir -p " + top_dir + "/out && " \
-            + "cd " + top_dir + "/out && " \
-            + "rm -rf raw_copy && " \
-            + "unzip " + os.path.abspath(pdk_bin_zip) + " raw_copy/* && " \
-            + "mv raw_copy/target/product/pdk_target raw_copy/target/product/" + target_hw + " &&" \
-            + "mv -f raw_copy/* . && " \
-            + "touch " + os.path.abspath(PDK_BIN_COPIED)
-    os.system(command)
-
-  if copy_partner_data_cpu:
-    print "copy pdk bins to " + pdk_partner_data_cpu_path
-    pu.remove_if_exists(pdk_partner_data_cpu_path)
-    command = "mkdir -p " + pdk_partner_data_cpu_path + " && " \
-            + "cd " + pdk_partner_data_cpu_path + " && " \
-            + "unzip -o " + os.path.abspath(pdk_bin_zip) + " host/* target/* pdk_prebuilt.mk"
-    os.system(command)
-
-  if copy_pdk_data:
-    print "copy pdk data"
-    # first remove old files
-    pu.remove_files_listed(top_dir, pu.load_list(PDK_DATA_COPIED))
-    command = "cd " + top_dir + " && " \
-            + "unzip -o " + os.path.abspath(pdk_data_zip)
-    os.system(command)
-    # recorde copied files to delete correctly.
-    pu.save_list(pu.list_files_in_zip(pdk_data_zip), PDK_DATA_COPIED)
-
-
-if __name__ == '__main__':
-  main(sys.argv)