libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

ossfuzz-build.sh (1974B)


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