1#!/bin/bash
2
3set -euo pipefail
4
5$SRC/perfetto/tools/install-build-deps
6
7mkdir -p $WORK/build
8
9# sanitize=vptr needs RTTI, which we do not compile with.
10CXXFLAGS="$CXXFLAGS -fno-sanitize=vptr"
11
12GN_ARGS="is_clang=true is_debug=false is_fuzzer=true use_libfuzzer=false \
13link_fuzzer=\"-lFuzzingEngine\" is_hermetic_clang=false \
14use_custom_libcxx=false \
15extra_cflags=\"$CFLAGS -Wno-implicit-int-float-conversion\" \
16extra_cxxflags=\"$CXXFLAGS\" extra_ldflags=\"$CXXFLAGS\" \
17is_system_compiler=true cc=\"$CC\" cxx=\"$CXX\" linker=\"gold\""
18
19if [ "$SANITIZER" = "address" ]; then
20  GN_ARGS="$GN_ARGS is_asan=true";
21fi;
22
23OUTDIR=$WORK/build
24$SRC/perfetto/tools/gn gen "$OUTDIR" --args="${GN_ARGS}" --check
25
26$SRC/perfetto/tools/ninja -C $WORK/build fuzzers -v
27cp $WORK/build/*fuzzer $OUT
28mkdir -p $OUT/src/traced/probes/ftrace/test/data
29cp -a $SRC/perfetto/src/traced/probes/ftrace/test/data/synthetic \
30  $OUT/src/traced/probes/ftrace/test/data
31
32if [ "$SANITIZER" = "undefined" ]; then
33  rm $OUT/trace_processor_fuzzer
34fi;
35