aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2015-10-22 16:30:00 -0700
committerYing Wang <wangying@google.com>2015-10-23 13:19:47 -0700
commit4d68879ca6a8a97f002d62c28e25fcc935246dfa (patch)
tree81d6938fdf4a3752e1ffa5dd1c4b6e15bb20c668
parentac4ec1a4ea83a150e08ccd43f30fe34de52cdebf (diff)
downloadbuild-4d68879ca6a8a97f002d62c28e25fcc935246dfa.tar.gz
Normalize java source file paths before running "sort -u".
We rely on "sort -u" to dedupe aidl/logtags generated java files added by both from $(all_java_sources) and from "find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java". But "sort -u" doesn't work if any of the aidl/logtags source file path has "../" in it. This change fixes this issue by normalizing the source file paths before passing them to "sort -u". Change-Id: I12d2c4e0397bed9f426a1ed9b13608d72d01e0df
-rw-r--r--core/config.mk2
-rw-r--r--core/definitions.mk6
-rwxr-xr-xtools/normalize_path.py24
3 files changed, 29 insertions, 3 deletions
diff --git a/core/config.mk b/core/config.mk
index 8863064ad1..ba2e7d5c03 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -550,6 +550,8 @@ else
MD5SUM:=md5sum
endif
+NORMALIZE_PATH := build/tools/normalize_path.py
+
APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
diff --git a/core/definitions.mk b/core/definitions.mk
index a036a25306..ecc72532d1 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1804,7 +1804,7 @@ $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \
fi
$(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \
- | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+ | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
$(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
$(1) -encoding UTF-8 \
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
@@ -1867,7 +1867,7 @@ $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
fi
$(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
- | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
+ | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
$(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
$(hide) echo -basedirectory $(CURDIR) > $@.flags; \
echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \
@@ -1946,7 +1946,7 @@ $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
fi
$(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
- | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
+ | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
$(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
$(hide) echo -basedirectory $(CURDIR) > $@.flags; \
echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \
diff --git a/tools/normalize_path.py b/tools/normalize_path.py
new file mode 100755
index 0000000000..1b3d42e64c
--- /dev/null
+++ b/tools/normalize_path.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2015 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.
+"""
+Normalize and output paths read from stdin.
+"""
+
+import os.path
+import sys
+
+for line in sys.stdin:
+ print os.path.normpath(line.strip())