1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15cd $SRC/myanmar-tools/clients/cpp
16mkdir build
17cd build
18cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \
19    -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
20    -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
21make all
22
23# Note: don't use the myanmartools_fuzz CMake target directly because we want
24# to link with LIB_FUZZING_ENGINE instead of the default fuzzer.
25# Copy the .so file to $OUT as well as the executable.
26mkdir -p $OUT/lib
27cp libmyanmartools.so $OUT/lib
28# TODO(https://github.com/google/oss-fuzz/issues/2947): Link in libunwind
29# statically or stop copying if ClusterFuzz bot images get libunwind.
30# Copy libunwind since it isn't on the ClusterFuzz bot images.
31cp /usr/lib/x86_64-linux-gnu/libunwind.so.8 $OUT/lib/
32$CXX $CXXFLAGS -std=c++11 -I../public -L$OUT/lib \
33    -Wl,-rpath,'$ORIGIN/lib' -lmyanmartools \
34    -o $OUT/zawgyi_detector_fuzz_target \
35    ../zawgyi_detector_fuzz_target.cpp \
36    $LIB_FUZZING_ENGINE
37