Merge "Add a build rule providing ICU .dat prebuilt under /system/etc/icu."
diff --git a/android_icu4c/include/uconfig_local.h b/android_icu4c/include/uconfig_local.h
index ec4a4a0..4b4e76d 100644
--- a/android_icu4c/include/uconfig_local.h
+++ b/android_icu4c/include/uconfig_local.h
@@ -20,13 +20,9 @@
  * stops the build process. Only the following libraries should have this
  * flag,
  * - Libraries in Runtime APEX module
- * - Host libraries
- * - Includes libicuuc as a static library
  * Otherwise, the libraries should use libandroidicu.
  */
 #if defined(__ANDROID__) && !defined(ANDROID_LINK_SHARED_ICU4C)
-// TODO: Enable #error when the exception flag ANDROID_LINK_SHARED_ICU4C is
-// added to all the android libraries
-// #error "Please use libandroidicu and do not directly link to libicuuc or libicui18n."
+#error "Please use libandroidicu and do not directly link to libicuuc or libicui18n."
 #endif
 
diff --git a/tools/i18nutil.py b/tools/i18nutil.py
index e4773f4..c8859d2 100644
--- a/tools/i18nutil.py
+++ b/tools/i18nutil.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 import os
 import sys
 import tempfile
@@ -6,14 +8,14 @@
 
 def CheckDirExists(dir, dirname):
   if not os.path.isdir(dir):
-    print "Couldn't find %s (%s)!" % (dirname, dir)
+    print("Couldn't find %s (%s)!" % (dirname, dir))
     sys.exit(1)
 
 
 def GetAndroidRootOrDie():
   value = os.environ.get('ANDROID_BUILD_TOP')
   if not value:
-    print "ANDROID_BUILD_TOP not defined: run envsetup.sh / lunch"
+    print("ANDROID_BUILD_TOP not defined: run envsetup.sh / lunch")
     sys.exit(1);
   CheckDirExists(value, '$ANDROID_BUILD_TOP')
   return value
@@ -22,7 +24,7 @@
 def GetAndroidHostOutOrDie():
   value = os.environ.get('ANDROID_HOST_OUT')
   if not value:
-    print "ANDROID_HOST_OUT not defined: run envsetup.sh / lunch"
+    print("ANDROID_HOST_OUT not defined: run envsetup.sh / lunch")
     sys.exit(1);
   CheckDirExists(value, '$ANDROID_HOST_OUT')
   return value
@@ -31,6 +33,6 @@
 def SwitchToNewTemporaryDirectory():
   tmp_dir = tempfile.mkdtemp('-i18n')
   os.chdir(tmp_dir)
-  print 'Created temporary directory "%s"...' % tmp_dir
+  print('Created temporary directory "%s"...' % tmp_dir)
 
 
diff --git a/tools/icuutil.py b/tools/icuutil.py
index 04b5063..0e10ec8 100644
--- a/tools/icuutil.py
+++ b/tools/icuutil.py
@@ -16,6 +16,8 @@
 
 """Utility methods associated with ICU source and builds."""
 
+from __future__ import print_function
+
 import glob
 import os
 import shutil
@@ -60,7 +62,7 @@
   dat_file_pattern = '%s/data/out/tmp/icudt??l.dat' % icu_build_dir
   dat_files = glob.glob(dat_file_pattern)
   if len(dat_files) != 1:
-    print 'ERROR: Unexpectedly found %d .dat files (%s). Halting.' % (len(datfiles), datfiles)
+    print('ERROR: Unexpectedly found %d .dat files (%s). Halting.' % (len(datfiles), datfiles))
     sys.exit(1)
   dat_file = dat_files[0]
   return dat_file
@@ -79,7 +81,7 @@
   os.chdir(icu_build_dir)
 
   # Build the ICU tools.
-  print 'Configuring ICU tools...'
+  print('Configuring ICU tools...')
   subprocess.check_call(['%s/runConfigureICU' % icu4cDir(), 'Linux'])
 
   os.chdir(original_working_dir)
@@ -104,7 +106,7 @@
   working_iana_tar_file = '%s/%s' % (tzcode_working_dir, iana_tar_filename)
   shutil.copyfile(iana_tar_file, working_iana_tar_file)
 
-  print 'Making ICU tz data files...'
+  print('Making ICU tz data files...')
   # The Makefile assumes the existence of the bin directory.
   os.mkdir('%s/bin' % icu_build_dir)
 
@@ -114,7 +116,7 @@
   # Copy the source file to its ultimate destination.
   zoneinfo_file = '%s/zoneinfo64.txt' % tzcode_working_dir
   icu_txt_data_dir = '%s/data/misc' % icu4cDir()
-  print 'Copying zoneinfo64.txt to %s ...' % icu_txt_data_dir
+  print('Copying zoneinfo64.txt to %s ...' % icu_txt_data_dir)
   shutil.copy(zoneinfo_file, icu_txt_data_dir)
 
 
@@ -134,7 +136,7 @@
   icu_dat_data_dir = '%s/stubdata' % icu4cDir()
   dat_file = datFile(icu_build_dir)
 
-  print 'Copying %s to %s ...' % (dat_file, icu_dat_data_dir)
+  print('Copying %s to %s ...' % (dat_file, icu_dat_data_dir))
   shutil.copy(dat_file, icu_dat_data_dir)
 
   # Generate the ICU4J .jar files
@@ -145,14 +147,14 @@
   icu_jar_data_dir = '%s/main/shared/data' % icu4jDir()
   jarfiles = glob.glob('out/icu4j/*.jar')
   if len(jarfiles) != 2:
-    print 'ERROR: Unexpectedly found %d .jar files (%s). Halting.' % (len(jarfiles), jarfiles)
+    print('ERROR: Unexpectedly found %d .jar files (%s). Halting.' % (len(jarfiles), jarfiles))
     sys.exit(1)
   for jarfile in jarfiles:
     icu_jarfile = os.path.join(icu_jar_data_dir, os.path.basename(jarfile))
     if ziputil.ZipCompare(jarfile, icu_jarfile):
-      print 'Ignoring %s which is identical to %s ...' % (jarfile, icu_jarfile)
+      print('Ignoring %s which is identical to %s ...' % (jarfile, icu_jarfile))
     else:
-      print 'Copying %s to %s ...' % (jarfile, icu_jar_data_dir)
+      print('Copying %s to %s ...' % (jarfile, icu_jar_data_dir))
       shutil.copy(jarfile, icu_jar_data_dir)
 
   # Switch back to the original working cwd.
@@ -183,7 +185,7 @@
   dat_file = datFile(icu_build_dir)
   icu_package_dat = os.path.basename(dat_file)
   if not icu_package_dat.endswith('.dat'):
-      print '%s does not end with .dat' % icu_package_dat
+      print('%s does not end with .dat' % icu_package_dat)
       sys.exit(1)
   icu_package = icu_package_dat[:-4]
 
@@ -225,12 +227,12 @@
       env=icu_env)
   p.wait()
   if p.returncode != 0:
-    print 'pkgdata failed with status code: %s' % p.returncode
+    print('pkgdata failed with status code: %s' % p.returncode)
 
   # Copy the .dat to the chosen place / name.
   generated_dat_file = '%s/%s' % (res_staging_dir, icu_package_dat)
   shutil.copyfile(generated_dat_file, dest_file)
-  print 'ICU overlay .dat can be found here: %s' % dest_file
+  print('ICU overlay .dat can be found here: %s' % dest_file)
 
   # Switch back to the original working cwd.
   os.chdir(original_working_dir)
@@ -240,6 +242,6 @@
   """Copies ICU license files to the target_dir"""
 
   license_file = '%s/main/shared/licenses/LICENSE' % icu4jDir()
-  print 'Copying %s to %s ...' % (license_file, target_dir)
+  print('Copying %s to %s ...' % (license_file, target_dir))
   shutil.copy(license_file, target_dir)
 
diff --git a/tools/updatecldrdata.py b/tools/updatecldrdata.py
index 1116d14..b4544a4 100755
--- a/tools/updatecldrdata.py
+++ b/tools/updatecldrdata.py
@@ -2,6 +2,8 @@
 
 """Regenerates (just) ICU data source files used to build ICU data files."""
 
+from __future__ import print_function
+
 import os
 import pipes
 import shutil
@@ -16,18 +18,18 @@
 # See icu4c/source/data/cldr-icu-readme.txt for the upstream ICU instructions.
 def main():
   cldr_dir = icuutil.cldrDir()
-  print 'Found cldr in %s ...' % cldr_dir
+  print('Found cldr in %s ...' % cldr_dir)
   icu_dir = icuutil.icuDir()
-  print 'Found icu in %s ...' % icu_dir
+  print('Found icu in %s ...' % icu_dir)
 
   # Ant doesn't have any mechanism for using a build directory separate from the
   # source directory so this build script creates a temporary directory and then
   # copies all necessary ICU4J and CLDR source code to here before building it:
   i18nutil.SwitchToNewTemporaryDirectory()
 
-  print 'Copying ICU4J source code ...'
+  print('Copying ICU4J source code ...')
   shutil.copytree(os.path.join(icu_dir, 'icu4j'), 'icu4j', True)
-  print 'Building ICU4J ...'
+  print('Building ICU4J ...')
   subprocess.check_call([
       'ant',
       '-f', 'icu4j/build.xml',
@@ -51,9 +53,9 @@
   # copy of the tools source code) from where the data files are to be read:
   os.environ['CLDR_DIR'] = cldr_dir
 
-  print 'Copying CLDR source code ...'
+  print('Copying CLDR source code ...')
   shutil.copytree(os.path.join(cldr_dir, 'tools/java'), 'cldr-tools-java', True)
-  print 'Building CLDR tools ...'
+  print('Building CLDR tools ...')
   subprocess.check_call([
       'ant',
       '-f', 'cldr-tools-java/build.xml',
@@ -71,7 +73,7 @@
   os.environ['ANT_OPTS'] = '-DCLDR_DTD_CACHE=%s' % pipes.quote(os.path.join(
       os.getcwd(), 'cldr-dtd-cache'))
 
-  print 'Building ICU data source files ...'
+  print('Building ICU data source files ...')
   subprocess.check_call([
       'ant',
       '-f', os.path.join(icu_dir, 'icu4c/source/data/build.xml'),
@@ -79,7 +81,7 @@
       'all',
   ])
 
-  print 'Look in %s/icu4c/source/data for new data source files' % icu_dir
+  print('Look in %s/icu4c/source/data for new data source files' % icu_dir)
   sys.exit(0)
 
 if __name__ == '__main__':
diff --git a/tools/updateicudata.py b/tools/updateicudata.py
index 3de7ebc..01122c1 100755
--- a/tools/updateicudata.py
+++ b/tools/updateicudata.py
@@ -2,6 +2,8 @@
 
 """Regenerates (just) ICU data files used in the Android system image."""
 
+from __future__ import print_function
+
 import os
 import sys
 
@@ -15,13 +17,13 @@
   icu_build_dir = '%s/icu' % os.getcwd()
 
   icu_dir = icuutil.icuDir()
-  print 'Found icu in %s ...' % icu_dir
+  print('Found icu in %s ...' % icu_dir)
 
   icuutil.PrepareIcuBuild(icu_build_dir)
 
   icuutil.MakeAndCopyIcuDataFiles(icu_build_dir)
 
-  print 'Look in %s for new data files' % icu_dir
+  print('Look in %s for new data files' % icu_dir)
   sys.exit(0)
 
 if __name__ == '__main__':
diff --git a/tools/ziputil.py b/tools/ziputil.py
index 4b44f38..daee0cc 100644
--- a/tools/ziputil.py
+++ b/tools/ziputil.py
@@ -16,7 +16,10 @@
 
 """Utility methods to work with Zip archives."""
 
-import itertools
+try:
+    import itertools.izip as zip
+except ImportError:
+    pass
 
 from operator import attrgetter
 from zipfile import ZipFile
@@ -41,4 +44,4 @@
       a.filename == b.filename and
       a.file_size == b.file_size and
       a.CRC == b.CRC
-      for a, b in itertools.izip(info_a, info_b))
+      for a, b in zip(info_a, info_b))