aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kalauskas <peskal@google.com>2018-07-10 12:01:03 -0700
committerPeter Kalauskas <peskal@google.com>2018-07-10 12:42:22 -0700
commit39b0deb0d7b5ee1bec1573f436f7379525f1c23c (patch)
treee1687fbc018b364371230cd59249db2b51b16e87
parent73ea6a3cf104991216e27fe0f9e957fe62525bad (diff)
downloadbuild_soong-39b0deb0d7b5ee1bec1573f436f7379525f1c23c.tar.gz
build_soong-39b0deb0d7b5ee1bec1573f436f7379525f1c23c.tar.bz2
build_soong-39b0deb0d7b5ee1bec1573f436f7379525f1c23c.zip
Fix error in build when OUT_DIR_COMMON_BASE is used
Without this change, gen-kotlin-build-file.sh will generate kotlinc-build.xml file with path that look like: /path/to/aosp-top//path/to/aosp-out/soong/.intermediates/... Also fixed a couple lint errors. Test: Set OUT_DIR_COMMON_BASE and was able to build Bug: 111309264 Change-Id: I86173571667deca79ee0d9a7324715c9a0e4cd97
-rwxr-xr-xscripts/gen-kotlin-build-file.sh28
1 files changed, 20 insertions, 8 deletions
diff --git a/scripts/gen-kotlin-build-file.sh b/scripts/gen-kotlin-build-file.sh
index f077a0cb..1e03f72e 100755
--- a/scripts/gen-kotlin-build-file.sh
+++ b/scripts/gen-kotlin-build-file.sh
@@ -16,7 +16,7 @@
# Generates kotlinc module xml file to standard output based on rsp files
-if [ -z "$1" ]; then
+if [[ -z "$1" ]]; then
echo "usage: $0 <classpath> <outDir> <rspFiles>..." >&2
exit 1
fi
@@ -30,24 +30,36 @@ classpath=$1
out_dir=$2
shift 2
-# Path in the build file are relative to the build file, we need to make them absolute.
-prefix=`pwd`
+# Path in the build file may be relative to the build file, we need to make them
+# absolute
+prefix="$(pwd)"
+
+get_abs_path () {
+ local file="$1"
+ if [[ "${file:0:1}" == '/' ]] ; then
+ echo "${file}"
+ else
+ echo "${prefix}/${file}"
+ fi
+}
# Print preamble
echo "<modules><module name=\"name\" type=\"java-production\" outputDir=\"${out_dir}\">"
# Print classpath entries
-for file in $(echo $classpath | tr ":" "\n"); do
- echo " <classpath path=\"${prefix}/${file}\"/>"
+for file in $(echo "$classpath" | tr ":" "\n"); do
+ path="$(get_abs_path "$file")"
+ echo " <classpath path=\"${path}\"/>"
done
# For each rsp file, print source entries
while (( "$#" )); do
- for file in $(cat $1); do
+ for file in $(cat "$1"); do
+ path="$(get_abs_path "$file")"
if [[ $file == *.java ]]; then
- echo " <javaSourceRoots path=\"${prefix}/${file}\"/>"
+ echo " <javaSourceRoots path=\"${path}\"/>"
elif [[ $file == *.kt ]]; then
- echo " <sources path=\"${prefix}/${file}\"/>"
+ echo " <sources path=\"${path}\"/>"
else
echo "Unknown source file type ${file}"
exit 1