1#!/bin/bash 2 3# Copyright 2022 Google LLC 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 17set -e 18 19SCRIPT_DIR=$(dirname "$(realpath $0)") 20BENCHMARK_DIR=$1 21PREFIX=$2 22 23if [ -z $PREFIX ] 24then 25 PREFIX=.. 26fi 27 28JAVA_ARG=$3 29 30if [ -z $JAVA_ARG ] 31then 32 JAVA=java 33else 34 JAVA=$(realpath $SCRIPT_DIR/$JAVA_ARG) 35fi 36 37BENCHMARK_DATA_DIR=$(realpath $SCRIPT_DIR/$PREFIX/$BENCHMARK_DIR) 38 39echo Running benchmark: $BENCHMARK_DIR 40echo With benchmark data directory: $BENCHMARK_DATA_DIR 41echo Using java: $JAVA 42 43cd $SCRIPT_DIR 44CP=../build/libs/benchmark.jar:$(echo $BENCHMARK_DATA_DIR/lib/*.jar | tr ' ' ':') 45KSP_PLUGIN_ID=com.google.devtools.ksp.symbol-processing 46KSP_PLUGIN_OPT=plugin:$KSP_PLUGIN_ID 47 48KSP_PLUGIN_JAR=./com/google/devtools/ksp/symbol-processing-cmdline/2.0.255/symbol-processing-cmdline-2.0.255.jar 49KSP_API_JAR=./com/google/devtools/ksp/symbol-processing-api/2.0.255/symbol-processing-api-2.0.255.jar 50 51AP=processor-1.0-SNAPSHOT.jar 52 53mkdir -p out 54find $BENCHMARK_DATA_DIR -name "*.kt" | xargs $JAVA -cp $CP com.google.devtools.ksp.BenchRunnerKt $BENCHMARK_DIR\ 55 -kotlin-home . \ 56 -Xplugin=$KSP_PLUGIN_JAR \ 57 -Xplugin=$KSP_API_JAR \ 58 -Xallow-no-source-files \ 59 -P $KSP_PLUGIN_OPT:apclasspath=$AP \ 60 -P $KSP_PLUGIN_OPT:projectBaseDir=. \ 61 -P $KSP_PLUGIN_OPT:classOutputDir=./out \ 62 -P $KSP_PLUGIN_OPT:javaOutputDir=./out \ 63 -P $KSP_PLUGIN_OPT:kotlinOutputDir=./out \ 64 -P $KSP_PLUGIN_OPT:resourceOutputDir=./out \ 65 -P $KSP_PLUGIN_OPT:kspOutputDir=./out \ 66 -P $KSP_PLUGIN_OPT:cachesDir=./out \ 67 -P $KSP_PLUGIN_OPT:incremental=false \ 68 -P $KSP_PLUGIN_OPT:apoption=key1=value1 \ 69 -P $KSP_PLUGIN_OPT:apoption=key2=value2 \ 70 -cp $CP 71