blob: f077a0cbbafb886925f42907807d3127e1b5baf9 [file] [log] [blame]
Przemyslaw Szczepaniak4b5fe9d2018-02-13 14:32:54 +00001#!/bin/bash -e
2
3# Copyright 2018 Google Inc. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Generates kotlinc module xml file to standard output based on rsp files
18
19if [ -z "$1" ]; then
20 echo "usage: $0 <classpath> <outDir> <rspFiles>..." >&2
21 exit 1
22fi
23
24# Classpath variable has a tendency to be prefixed by "-classpath", remove it.
25if [[ $1 == "-classpath" ]]; then
26 shift
27fi;
28
29classpath=$1
30out_dir=$2
31shift 2
32
33# Path in the build file are relative to the build file, we need to make them absolute.
34prefix=`pwd`
35
36# Print preamble
37echo "<modules><module name=\"name\" type=\"java-production\" outputDir=\"${out_dir}\">"
38
39# Print classpath entries
40for file in $(echo $classpath | tr ":" "\n"); do
41 echo " <classpath path=\"${prefix}/${file}\"/>"
42done
43
44# For each rsp file, print source entries
45while (( "$#" )); do
46 for file in $(cat $1); do
47 if [[ $file == *.java ]]; then
48 echo " <javaSourceRoots path=\"${prefix}/${file}\"/>"
49 elif [[ $file == *.kt ]]; then
50 echo " <sources path=\"${prefix}/${file}\"/>"
51 else
52 echo "Unknown source file type ${file}"
53 exit 1
54 fi
55 done
56
57 shift
58done
59
60echo "</module></modules>"