17c804472Sopenharmony_ci#!/bin/bash
27c804472Sopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
37c804472Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
47c804472Sopenharmony_ci# you may not use this file except in compliance with the License.
57c804472Sopenharmony_ci# You may obtain a copy of the License at
67c804472Sopenharmony_ci#
77c804472Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
87c804472Sopenharmony_ci#
97c804472Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
107c804472Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
117c804472Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127c804472Sopenharmony_ci# See the License for the specific language governing permissions and
137c804472Sopenharmony_ci# limitations under the License.
147c804472Sopenharmony_ci
157c804472Sopenharmony_ciset -e
167c804472Sopenharmony_ciBIN_PATH=$(dirname $0)
177c804472Sopenharmony_ciCOMPLIER_PATH_USE=""
187c804472Sopenharmony_ci#read config.
197c804472Sopenharmony_ciwhile read line;do
207c804472Sopenharmony_ci    eval "$line"
217c804472Sopenharmony_cidone < config.cfg
227c804472Sopenharmony_ci
237c804472Sopenharmony_ci#clean
247c804472Sopenharmony_ciif [ -d "build" ]; then
257c804472Sopenharmony_ci  rm -rf build
267c804472Sopenharmony_cifi
277c804472Sopenharmony_ciif [ -d "output" ]; then
287c804472Sopenharmony_ci  rm -rf output
297c804472Sopenharmony_cifi
307c804472Sopenharmony_ci
317c804472Sopenharmony_ci#build
327c804472Sopenharmony_ciif [ "$1" == "clean" ]; then
337c804472Sopenharmony_ci  echo "clean finished"
347c804472Sopenharmony_cielse
357c804472Sopenharmony_ci  echo "build start"
367c804472Sopenharmony_ci  mkdir build 
377c804472Sopenharmony_ci  mkdir output
387c804472Sopenharmony_ci  cd build
397c804472Sopenharmony_ci  if [ -f  "$COMPLIER_PATH_LOCAL"/bin/clang ]; then
407c804472Sopenharmony_ci    COMPLIER_PATH_USE=$(dirname $(readlink -f "$COMPLIER_PATH_LOCAL"/clang-mingw))
417c804472Sopenharmony_ci  fi
427c804472Sopenharmony_ci  if [ -f "$COMPLIER_PATH"/bin/clang ]; then
437c804472Sopenharmony_ci    COMPLIER_PATH_USE=$COMPLIER_PATH
447c804472Sopenharmony_ci  fi
457c804472Sopenharmony_ci  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"
467c804472Sopenharmony_ci  cpu_processor_num=$(grep processor /proc/cpuinfo | wc -l)
477c804472Sopenharmony_ci  job_num=$(expr "$cpu_processor_num" \* 2)
487c804472Sopenharmony_ci  echo Parallel job num is "$job_num"
497c804472Sopenharmony_ci  make -j"$job_num"
507c804472Sopenharmony_ci  if [ "$1" == "THIN" ]
517c804472Sopenharmony_ci  then
527c804472Sopenharmony_ci    mv Simulator.exe ../output
537c804472Sopenharmony_ci  elif [ "$1" == "RICH" ]
547c804472Sopenharmony_ci  then
557c804472Sopenharmony_ci    mv Previewer.exe ../output
567c804472Sopenharmony_ci  fi
577c804472Sopenharmony_ci  echo "build finished"
587c804472Sopenharmony_cifi
59