1#!/bin/bash -eu
2# Copyright 2020 Google Inc.
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
18if [ "${SANITIZER}" = address ]
19then
20    CONFIGURE_FLAGS="--enable-asan"
21elif [ "${SANITIZER}" = undefined ]
22then
23    CONFIGURE_FLAGS="--enable-ubsan"
24else
25    CONFIGURE_FLAGS=""
26fi
27
28./utils/build/configure.py "${OUT}/build" --build-system "Ninja" ${CONFIGURE_FLAGS} \
29                           --cmake-flags="-DHERMES_USE_STATIC_ICU=ON -DHERMES_FUZZING_FLAG=${LIB_FUZZING_ENGINE} -DHERMES_ENABLE_LIBFUZZER=ON"
30cmake --build "$OUT/build"  --parallel --target fuzzer-jsi-entry
31cp "${OUT}/build/bin/fuzzer-jsi-entry" "${OUT}"
32