Merge "Update droiddoc templates for build/make move"
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index 1a0dc5b..c26b0fc 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -52,7 +52,7 @@
 
 $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix)
 # Use dex2oat debug version for better error reporting
-$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGET_BOOT_DEX_FILES) $(DEX2OAT_DEPENDENCY)
+$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGET_BOOT_DEX_FILES) $(PRELOADED_CLASSES) $(COMPILED_CLASSES) $(DEX2OAT_DEPENDENCY)
 	@echo "target dex2oat: $@"
 	@mkdir -p $(dir $@)
 	@mkdir -p $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index d19dcb2..e008640 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -75,6 +75,7 @@
     make_ext4fs \
     e2fsck \
     resize2fs \
+    tune2fs \
     screencap \
     sensorservice \
     telephony-common \
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
index ec2fa41..ea70454 100644
--- a/target/product/core_tiny.mk
+++ b/target/product/core_tiny.mk
@@ -72,6 +72,7 @@
     make_ext4fs \
     e2fsck \
     resize2fs \
+    tune2fs \
     nullwebview \
     screencap \
     sensorservice \
diff --git a/tools/warn.py b/tools/warn.py
index ea1cd22..3c75825 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -32,6 +32,7 @@
 #   warning_records      array of [idx to warn_patterns,
 #                                  idx to project_names,
 #                                  idx to warning_messages]
+#   android_root
 #   platform_version
 #   target_product
 #   target_variant
@@ -80,6 +81,7 @@
 #   dump_csv():
 
 import argparse
+import os
 import re
 
 parser = argparse.ArgumentParser(description='Convert a build log into HTML')
@@ -1776,6 +1778,7 @@
 initialize_arrays()
 
 
+android_root = ''
 platform_version = 'unknown'
 target_product = 'unknown'
 target_variant = 'unknown'
@@ -2020,6 +2023,53 @@
       i['compiled_patterns'].append(re.compile(pat))
 
 
+def find_android_root(path):
+  """Set and return android_root path if it is found."""
+  global android_root
+  parts = path.split('/')
+  for idx in reversed(range(2, len(parts))):
+    root_path = '/'.join(parts[:idx])
+    # Android root directory should contain this script.
+    if os.path.exists(root_path + '/build/tools/warn.py'):
+      android_root = root_path
+      return root_path
+  return ''
+
+
+def remove_android_root_prefix(path):
+  """Remove android_root prefix from path if it is found."""
+  if path.startswith(android_root):
+    return path[1 + len(android_root):]
+  else:
+    return path
+
+
+def normalize_path(path):
+  """Normalize file path relative to android_root."""
+  # If path is not an absolute path, just normalize it.
+  path = os.path.normpath(path)
+  if path[0] != '/':
+    return path
+  # Remove known prefix of root path and normalize the suffix.
+  if android_root or find_android_root(path):
+    return remove_android_root_prefix(path)
+  else:
+    return path
+
+
+def normalize_warning_line(line):
+  """Normalize file path relative to android_root in a warning line."""
+  # replace fancy quotes with plain ol' quotes
+  line = line.replace('‘', "'")
+  line = line.replace('’', "'")
+  line = line.strip()
+  first_column = line.find(':')
+  if first_column > 0:
+    return normalize_path(line[:first_column]) + line[first_column:]
+  else:
+    return line
+
+
 def parse_input_file():
   """Parse input file, match warning lines."""
   global platform_version
@@ -2028,16 +2078,15 @@
   infile = open(args.buildlog, 'r')
   line_counter = 0
 
-  warning_pattern = re.compile('.* warning:.*')
+  # handle only warning messages with a file path
+  warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
   compile_patterns()
 
   # read the log file and classify all the warnings
   warning_lines = set()
   for line in infile:
-    # replace fancy quotes with plain ol' quotes
-    line = line.replace('‘', "'")
-    line = line.replace('’', "'")
     if warning_pattern.match(line):
+      line = normalize_warning_line(line)
       if line not in warning_lines:
         classify_warning(line)
         warning_lines.add(line)
@@ -2055,9 +2104,9 @@
         target_variant = m.group(0)
 
 
-# Return s with escaped quotation characters.
+# Return s with escaped backslash and quotation characters.
 def escape_string(s):
-  return s.replace('"', '\\"')
+  return s.replace('\\', '\\\\').replace('"', '\\"')
 
 
 # Return s without trailing '\n' and escape the quotation characters.