"Fossies" - the Fresh Open Source Software Archive

Member "tesseract-5.2.0/unittest/fuzzers/oss-fuzz-build.sh" (6 Jul 2022, 2127 Bytes) of package /linux/misc/tesseract-5.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "oss-fuzz-build.sh": 5.1.0_vs_5.2.0.

    1 #!/bin/bash -eu
    2 # Copyright 2019 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 
   18 cd $SRC/leptonica
   19 ./autogen.sh
   20 ./configure --disable-shared
   21 make SUBDIRS=src install -j$(nproc)
   22 ldconfig
   23 
   24 cd $SRC/tesseract
   25 ./autogen.sh
   26 CXXFLAGS="$CXXFLAGS -D_GLIBCXX_DEBUG" ./configure --disable-graphics --disable-shared
   27 make -j$(nproc)
   28 
   29 # Get the models which are needed for the fuzzers.
   30 
   31 mkdir -p $OUT/tessdata
   32 (
   33 cd $OUT/tessdata
   34 test -f eng.traineddata || \
   35   curl -L -O https://github.com/tesseract-ocr/tessdata/raw/main/eng.traineddata
   36 )
   37 
   38 # OSS-Fuzz requires static linking for the project specific libraries,
   39 # so get the list of those libraries for Leptonica and TIFF.
   40 # Note that libm must be linker dynamically to avoid linker errors.
   41 
   42 LEPTONICA_CFLAGS=$(pkg-config --cflags lept)
   43 LEPTONICA_LIBS=$(pkg-config --static --libs lept)
   44 LIBTIFF_LIBS=$(pkg-config --static --libs libtiff-4 | sed 's/ -lm//')
   45 
   46 $CXX $CXXFLAGS \
   47     -I $SRC/tesseract/include \
   48      $SRC/tesseract/unittest/fuzzers/fuzzer-api.cpp -o $OUT/fuzzer-api \
   49      $SRC/tesseract/.libs/libtesseract.a \
   50      $LEPTONICA_CFLAGS \
   51      -Wl,-Bstatic $LEPTONICA_LIBS $LIBTIFF_LIBS -Wl,-Bdynamic \
   52      $LIB_FUZZING_ENGINE
   53 
   54 $CXX $CXXFLAGS \
   55     -DTESSERACT_FUZZER_WIDTH=512 \
   56     -DTESSERACT_FUZZER_HEIGHT=256 \
   57     -I $SRC/tesseract/include \
   58      $SRC/tesseract/unittest/fuzzers/fuzzer-api.cpp -o $OUT/fuzzer-api-512x256 \
   59      $SRC/tesseract/.libs/libtesseract.a \
   60      $LEPTONICA_CFLAGS \
   61      -Wl,-Bstatic $LEPTONICA_LIBS $LIBTIFF_LIBS -Wl,-Bdynamic \
   62      $LIB_FUZZING_ENGINE