1#!/bin/bash -eu
2# Copyright 2017 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
18mkdir -p $WORK/open62541
19cd $WORK/open62541
20
21# LOGLEVEL:
22# <= 100 TRACE
23# <= 200 DEBUG
24# <= 300 INFO
25# <= 400 WARNING
26# <= 500 ERROR
27# <= 600 FATAL
28# > 600 No LOG output
29
30cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_ENABLE_AMALGAMATION=OFF \
31      -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python2 \
32      -DBUILD_SHARED_LIBS=OFF -DUA_BUILD_EXAMPLES=OFF -DUA_LOGLEVEL=600 \
33      -DUA_ENABLE_ENCRYPTION=ON \
34      -DUA_BUILD_OSS_FUZZ=ON \
35      $SRC/open62541/
36
37# This also builds all the fuzz targets and places them in the $OUT directory
38# Only build with one process otherwise amalgamation fails.
39make -j1
40
41# Copy the corpus, dict and options to the $OUT dir
42$SRC/open62541/tests/fuzz/oss-fuzz-copy.sh
43
44echo "Built all fuzzer targets."
45