blob: b5fbb45b10a9f8682edbf440ea69649d0ff73fb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/usr/bin/env bash
# Copyright (c) the JPEG XL Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# Helper builder file to replace the /src/build.sh one in oss-fuzz/
if [[ -z "${FUZZING_ENGINE:-}" ]]; then
echo "Don't call this script directly. Use ./ci.sh ossfuzz_* commands" \
"instead." >&2
exit 1
fi
set -eux
main() {
# Build the fuzzers in release mode but force the inclusion of JXL_DASSERT()
# checks.
build_args=(
-G Ninja
-DBUILD_TESTING=OFF
-DJPEGXL_ENABLE_BENCHMARK=OFF
-DJPEGXL_ENABLE_DEVTOOLS=ON
-DJPEGXL_ENABLE_EXAMPLES=OFF
-DJPEGXL_ENABLE_FUZZERS=ON
-DJPEGXL_ENABLE_MANPAGES=OFF
-DJPEGXL_ENABLE_SJPEG=OFF
-DJPEGXL_ENABLE_VIEWERS=OFF
-DCMAKE_BUILD_TYPE=Release
)
export CXXFLAGS="${CXXFLAGS} -DJXL_IS_DEBUG_BUILD=1"
mkdir -p ${WORK}
cd ${WORK}
cmake \
"${build_args[@]}" \
-DJPEGXL_FUZZER_LINK_FLAGS="${LIB_FUZZING_ENGINE}" \
"${SRC}/libjxl"
fuzzers=(
color_encoding_fuzzer
djxl_fuzzer
fields_fuzzer
icc_codec_fuzzer
rans_fuzzer
transforms_fuzzer
)
if [[ -n "${JPEGXL_EXTRA_ARGS:-}" ]]; then
# Extra arguments passed to ci.sh ossfuzz commands are treated as ninja
# targets. The environment variable is split into individual targets here,
# which might break if passing paths with spaces, which is an unlikely use
# case.
fuzzers=(${JPEGXL_EXTRA_ARGS})
echo "Building with targets: ${JPEGXL_EXTRA_ARGS}"
fi
ninja "${fuzzers[@]}"
}
# Build as the regular user if not already running as that user. This avoids
# having root files in the build directory.
if [[ -n "${JPEGXL_UID:-}" && "${JPEGXL_UID}" != $(id -u) ]]; then
userspec="${JPEGXL_UID}:${JPEGXL_GID}"
unset JPEGXL_UID
unset JPEGXL_GID
chroot --skip-chdir --userspec="${userspec}" \
/ $(realpath "$0") "$@"
exit $?
fi
main "$@"
|