diff options
author | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2018-02-13 14:32:54 +0000 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2018-02-14 20:47:17 +0000 |
commit | 4b5fe9d1b4c6e8491a0f793ad43710fef7b78b74 (patch) | |
tree | 8466075dae2e245b43fc1e6d027f8e2bd158d8b2 /scripts | |
parent | 51be632b95c0693641b7fdf8ec08e797ce804198 (diff) | |
download | build_soong-4b5fe9d1b4c6e8491a0f793ad43710fef7b78b74.tar.gz build_soong-4b5fe9d1b4c6e8491a0f793ad43710fef7b78b74.tar.bz2 build_soong-4b5fe9d1b4c6e8491a0f793ad43710fef7b78b74.zip |
Add rsp and srcjar support to kotlinc build rule
Rsp files are supported through helper script (gen-kotlin-build-file.sh)
that generates the kotlinc module/build xml file.
Since rsp files are supported, I've added ExtractSrcJarsCmd step
to handle srcjars extraction.
Minor reorderings to make sure that TransformKotlinToClasses
recives only .java and .kt files when called from Module.compile.
Bug: 73281388
Test: make -j hidl-doc
Change-Id: I5a40b914569018dc529903a7f2864a5aeae838e5
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gen-kotlin-build-file.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/gen-kotlin-build-file.sh b/scripts/gen-kotlin-build-file.sh new file mode 100755 index 00000000..f077a0cb --- /dev/null +++ b/scripts/gen-kotlin-build-file.sh @@ -0,0 +1,60 @@ +#!/bin/bash -e + +# Copyright 2018 Google Inc. All rights reserved. +# +# 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. + +# Generates kotlinc module xml file to standard output based on rsp files + +if [ -z "$1" ]; then + echo "usage: $0 <classpath> <outDir> <rspFiles>..." >&2 + exit 1 +fi + +# Classpath variable has a tendency to be prefixed by "-classpath", remove it. +if [[ $1 == "-classpath" ]]; then + shift +fi; + +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` + +# 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}\"/>" +done + +# For each rsp file, print source entries +while (( "$#" )); do + for file in $(cat $1); do + if [[ $file == *.java ]]; then + echo " <javaSourceRoots path=\"${prefix}/${file}\"/>" + elif [[ $file == *.kt ]]; then + echo " <sources path=\"${prefix}/${file}\"/>" + else + echo "Unknown source file type ${file}" + exit 1 + fi + done + + shift +done + +echo "</module></modules>" |