1cc1dc7a3Sopenharmony_ci#!/bin/bash -eu 2cc1dc7a3Sopenharmony_ci 3cc1dc7a3Sopenharmony_ci# SPDX-License-Identifier: Apache-2.0 4cc1dc7a3Sopenharmony_ci# ---------------------------------------------------------------------------- 5cc1dc7a3Sopenharmony_ci# Copyright 2020-2021 Arm Limited 6cc1dc7a3Sopenharmony_ci# Copyright 2020 Google Inc. 7cc1dc7a3Sopenharmony_ci# 8cc1dc7a3Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); you may not 9cc1dc7a3Sopenharmony_ci# use this file except in compliance with the License. You may obtain a copy 10cc1dc7a3Sopenharmony_ci# of the License at: 11cc1dc7a3Sopenharmony_ci# 12cc1dc7a3Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 13cc1dc7a3Sopenharmony_ci# 14cc1dc7a3Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 15cc1dc7a3Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 16cc1dc7a3Sopenharmony_ci# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 17cc1dc7a3Sopenharmony_ci# License for the specific language governing permissions and limitations 18cc1dc7a3Sopenharmony_ci# under the License. 19cc1dc7a3Sopenharmony_ci# ---------------------------------------------------------------------------- 20cc1dc7a3Sopenharmony_ci 21cc1dc7a3Sopenharmony_ci# This script is invoked by oss-fuzz from <root>/Source/ 22cc1dc7a3Sopenharmony_ci 23cc1dc7a3Sopenharmony_ci# Generate a dummy version header (normally built by CMake variable expansion) 24cc1dc7a3Sopenharmony_ciecho "#pragma once" > astcenccli_version.h 25cc1dc7a3Sopenharmony_ciecho "#define VERSION_STRING \"0.0.0\"" >> astcenccli_version.h 26cc1dc7a3Sopenharmony_ciecho "#define YEAR_STRING \"2021\"" >> astcenccli_version.h 27cc1dc7a3Sopenharmony_ci 28cc1dc7a3Sopenharmony_ci# Build the core project for fuzz tests to link against 29cc1dc7a3Sopenharmony_cifor source in ./*.cpp; do 30cc1dc7a3Sopenharmony_ci BASE="${source##*/}" 31cc1dc7a3Sopenharmony_ci BASE="${BASE%.cpp}" 32cc1dc7a3Sopenharmony_ci echo ${BASE} 33cc1dc7a3Sopenharmony_ci 34cc1dc7a3Sopenharmony_ci $CXX $CXXFLAGS \ 35cc1dc7a3Sopenharmony_ci -c \ 36cc1dc7a3Sopenharmony_ci -DASTCENC_SSE=0 \ 37cc1dc7a3Sopenharmony_ci -DASTCENC_AVX=0 \ 38cc1dc7a3Sopenharmony_ci -DASTCENC_POPCNT=0 \ 39cc1dc7a3Sopenharmony_ci -I. -std=c++14 -mfpmath=sse -msse2 -fno-strict-aliasing -O0 -g \ 40cc1dc7a3Sopenharmony_ci $source \ 41cc1dc7a3Sopenharmony_ci -o ${BASE}.o 42cc1dc7a3Sopenharmony_cidone 43cc1dc7a3Sopenharmony_ci 44cc1dc7a3Sopenharmony_ciar -qc libastcenc.a *.o 45cc1dc7a3Sopenharmony_ci 46cc1dc7a3Sopenharmony_ci# Build project local fuzzers 47cc1dc7a3Sopenharmony_cifor fuzzer in ./Fuzzers/fuzz_*.cpp; do 48cc1dc7a3Sopenharmony_ci $CXX $CXXFLAGS \ 49cc1dc7a3Sopenharmony_ci -DASTCENC_SSE=0 \ 50cc1dc7a3Sopenharmony_ci -DASTCENC_AVX=0 \ 51cc1dc7a3Sopenharmony_ci -DASTCENC_POPCNT=0 \ 52cc1dc7a3Sopenharmony_ci -I. -std=c++14 $fuzzer $LIB_FUZZING_ENGINE ./libastcenc.a \ 53cc1dc7a3Sopenharmony_ci -o $OUT/$(basename -s .cpp $fuzzer) 54cc1dc7a3Sopenharmony_cidone 55cc1dc7a3Sopenharmony_ci 56cc1dc7a3Sopenharmony_ci# Cleanup temporary build files 57cc1dc7a3Sopenharmony_cirm *.o 58cc1dc7a3Sopenharmony_cirm *.a 59