1#!/bin/bash 2# Copyright (c) 2023 Huawei Device Co., Ltd. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15set -e 16BIN_PATH=$(dirname $0) 17COMPLIER_PATH_USE="" 18#read config. 19while read line;do 20 eval "$line" 21done < config.cfg 22 23#clean 24if [ -d "build" ]; then 25 rm -rf build 26fi 27if [ -d "output" ]; then 28 rm -rf output 29fi 30 31#build 32if [ "$1" == "clean" ]; then 33 echo "clean finished" 34else 35 echo "build start" 36 mkdir build 37 mkdir output 38 cd build 39 if [ -f "$COMPLIER_PATH_LOCAL"/bin/clang ]; then 40 COMPLIER_PATH_USE=$(dirname $(readlink -f "$COMPLIER_PATH_LOCAL"/clang-mingw)) 41 fi 42 if [ -f "$COMPLIER_PATH"/bin/clang ]; then 43 COMPLIER_PATH_USE=$COMPLIER_PATH 44 fi 45 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../output .. -DCMAKE_TOOLCHAIN_FILE=$BIN_PATH/cmake/mingw_clang_noerror.cmake -DTOOLCHAIN_PATH="$COMPLIER_PATH_USE" -DENGINE_TYPE="$1" 46 cpu_processor_num=$(grep processor /proc/cpuinfo | wc -l) 47 job_num=$(expr "$cpu_processor_num" \* 2) 48 echo Parallel job num is "$job_num" 49 make -j"$job_num" 50 if [ "$1" == "THIN" ] 51 then 52 mv Simulator.exe ../output 53 elif [ "$1" == "RICH" ] 54 then 55 mv Previewer.exe ../output 56 fi 57 echo "build finished" 58fi 59