• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2021 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# Build the jar.
19CURRENT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
20-Dexpression=project.version -q -DforceStdout)
21mvn package -Dmaven.test.skip=true
22cp "javaparser-core/target/javaparser-core-$CURRENT_VERSION.jar" $OUT/javaparser.jar
23
24# The jar files containing the project (separated by spaces).
25PROJECT_JARS=javaparser.jar
26
27# Build fuzzers in $OUT.
28BUILD_CLASSPATH=$(echo $PROJECT_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH
29
30# All jars and class files lie in the same directory as the fuzzer at runtime.
31RUNTIME_CLASSPATH=$(echo $PROJECT_JARS | xargs printf -- "\$this_dir/%s:"):.:\$this_dir
32
33for fuzzer in $(find $SRC -name '*Fuzzer.java'); do
34  fuzzer_basename=$(basename -s .java $fuzzer)
35  javac -cp $BUILD_CLASSPATH $fuzzer
36  cp $SRC/$fuzzer_basename.class $OUT/
37
38  # Create execution wrapper.
39  echo "#!/bin/sh
40# LLVMFuzzerTestOneInput for fuzzer detection.
41this_dir=\$(dirname \"\$0\")
42LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\":\$this_dir \
43\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \
44--cp=$RUNTIME_CLASSPATH \
45--target_class=$fuzzer_basename \
46--jvm_args=\"-Xmx2048m\" \
47\$@" > $OUT/$fuzzer_basename
48  chmod +x $OUT/$fuzzer_basename
49done
50