summaryrefslogtreecommitdiff
path: root/tools/normalize_path.py
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 /tools/normalize_path.py
parentac4ec1a4ea83a150e08ccd43f30fe34de52cdebf (diff)
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
Diffstat (limited to 'tools/normalize_path.py')
-rwxr-xr-xtools/normalize_path.py24
1 files changed, 24 insertions, 0 deletions
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())