1#!/bin/bash 2# Copyright (C) 2021 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. 14set -e 15PARAMS=$* 16echo $PARAMS 17echo "begin to check input" 18SOURCE="${BASH_SOURCE[0]}" 19cd $(dirname ${SOURCE}) 20./pare_third_party.sh 21target_os="linux" 22target_dir="linux" 23gn_path="linux" 24is_debug="false" 25is_clean="false" 26target="trace_streamer" 27gn="gn" 28ninja="ninja" 29case "$OSTYPE" in 30 solaris*) echo "SOLARIS" ;; 31 darwin*) gn_path="macx" target_os="macx" ;; 32 linux*) gn_path="linux" target_os="linux" ;; 33 bsd*) echo "is bsd os" ;; 34 msys*) gn_path="windows" target_os="windows" gn="gn.exe" ninja="ninja.exe" ;; 35 *) echo "unknown: $OSTYPE" ;; 36esac 37usage="Usage: $basename $0 wasm/test/fuzz/protoc debug/release/clean" 38 39./dl_tools.sh $gn_path 40 41if { [ "$1" == "dubaisdk" ] || [ "$1" == "sdkdemo" ] || [ "$1" == "wasm" ] || [ "$1" == "test" ] || [ "$1" == "fuzz" ]; } && [ "$#" -ne 0 ];then 42 TARGET_DIR=$1 43 if [[ $PARAMS == *"debug"* ]]; then 44 TARGET_DIR=$1"_debug" 45 fi 46 if [ ! -f "out/$TARGET_DIR/clang_x64/developtools/smartperf_host/protoc" ] && [ "$1" != "protoc" ];then 47 ./build.sh protoc 48 mkdir -p out/$TARGET_DIR/clang_x64/developtools/smartperf_host 49 cp out/$target_os/clang_x64/developtools/smartperf_host/protoc out/$TARGET_DIR/clang_x64/developtools/smartperf_host/protoc 50 fi 51 if [ ! -f "out/$TARGET_DIR/clang_x64/developtools/smartperf_host/protoreader_plugin" ] && [ "$1" != "spb" ] && [ -f "out/$TARGET_DIR/clang_x64/developtools/smartperf_host/protoc" ];then 52 ./build.sh spb 53 mkdir -p out/$TARGET_DIR/clang_x64/developtools/smartperf_host 54 cp out/$target_os/clang_x64/developtools/smartperf_host/protoreader_plugin out/$TARGET_DIR/clang_x64/developtools/smartperf_host/protoreader_plugin 55 fi 56fi 57if [ $target_os == "windows" ];then 58 cp .gn_win .gn 59else 60 cp .gn_unix .gn 61fi 62if [ "$1" == "windows" ];then 63 echo "gn only support linux and wasm build currently" 64 if [ ! -d "out/windows" ];then 65 mkdir out/windows 66 fi 67 touch out/windows/trace_streamer.exe 68 exit 69fi 70 71if [ "$#" -ne "0" ];then 72 if [ "$1" == "wasm" ];then 73 ./dl_emsdk.sh 74 target="wasm" 75 fi 76 if [ "$1" == "test" ];then 77 target="test" 78 fi 79 if [ "$1" == "fuzz" ];then 80 target="fuzz" 81 fi 82 if [ "$1" == "protoc" ];then 83 target="protoc" 84 fi 85 if [ "$1" == "sdkdemo" ];then 86 target="sdkdemo" 87 fi 88 if [ "$1" == "dubaisdk" ];then 89 target="dubaisdk" 90 fi 91 if [ "$1" == "sdkdemotest" ];then 92 target="sdkdemotest" 93 fi 94 if [ "$1" == "spb" ];then 95 target="spb" 96 fi 97fi 98target_operator="$2" 99if [ "$target" == "wasm" ] && [ "$target_os" == "windows" ];then 100 echo "!!!build wasm on winows will occur unknown error, strongly suggest you build wasm on linux(Ubuntu)" 101 exit 102fi 103./build_operator.sh $is_debug $target $target_os $is_clean $gn_path $gn $ninja $target_operator 104