Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright 2014 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 | echo Compile then run the Kotlin test. |
| 18 | |
| 19 | testdir=$(dirname $0) |
| 20 | targetdir="${testdir}/kotlin" |
| 21 | |
| 22 | if [[ -e "${targetdir}" ]]; then |
| 23 | echo "cleaning target" |
| 24 | rm -rf "${targetdir}" |
| 25 | fi |
| 26 | |
| 27 | mkdir -v "${targetdir}" |
| 28 | |
| 29 | if ! find "${testdir}/../java" -type f -name "*.class" -delete; then |
| 30 | echo "failed to clean .class files from java directory" >&2 |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | all_kt_files=`find . -name "*.kt" -print` |
| 35 | |
| 36 | # Compile java FlatBuffer library |
| 37 | javac ${testdir}/../java/com/google/flatbuffers/*.java -d $targetdir |
| 38 | # Compile Kotlin files |
| 39 | kotlinc $all_kt_files -classpath $targetdir -include-runtime -d $targetdir |
| 40 | # Make jar |
| 41 | jar cvf ${testdir}/kotlin_test.jar -C $targetdir . > /dev/null |
| 42 | # Run test |
| 43 | kotlin -cp ${testdir}/kotlin_test.jar KotlinTest |
| 44 | # clean up |
| 45 | rm -rf $targetdir |
| 46 | rm ${testdir}/kotlin_test.jar |