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 if [ ! -f "out/$1/clang_x64/developtools/profiler/protoc" ] && [ "$1" != "protoc" ];then 43 ./build.sh protoc 44 mkdir -p out/$1/clang_x64/developtools/profiler 45 cp out/$target_os/clang_x64/developtools/profiler/protoc out/$1/clang_x64/developtools/profiler/protoc 46 fi 47 if [ ! -f "out/$1/clang_x64/developtools/profiler/protoreader_plugin" ] && [ "$1" != "spb" ] && [ -f "out/$1/clang_x64/developtools/profiler/protoc" ];then 48 ./build.sh spb 49 mkdir -p out/$1/clang_x64/developtools/profiler 50 cp out/$target_os/clang_x64/developtools/profiler/protoreader_plugin out/$1/clang_x64/developtools/profiler/protoreader_plugin 51 fi 52fi 53if [ $target_os == "windows" ];then 54 cp .gn_win .gn 55else 56 cp .gn_unix .gn 57fi 58if [ "$1" == "windows" ];then 59 echo "gn only support linux and wasm build currently" 60 if [ ! -d "out/windows" ];then 61 mkdir out/windows 62 fi 63 touch out/windows/trace_streamer.exe 64 exit 65fi 66 67if [ "$#" -ne "0" ];then 68 if [ "$1" == "wasm" ];then 69 ./dl_emsdk.sh 70 target="wasm" 71 fi 72 if [ "$1" == "test" ];then 73 target="test" 74 fi 75 if [ "$1" == "fuzz" ];then 76 target="fuzz" 77 fi 78 if [ "$1" == "protoc" ];then 79 target="protoc" 80 fi 81 if [ "$1" == "sdkdemo" ];then 82 target="sdkdemo" 83 fi 84 if [ "$1" == "dubaisdk" ];then 85 target="dubaisdk" 86 fi 87 if [ "$1" == "sdkdemotest" ];then 88 target="sdkdemotest" 89 fi 90 if [ "$1" == "spb" ];then 91 target="spb" 92 fi 93fi 94target_operator="$2" 95if [ "$target" == "wasm" ] && [ "$target_os" == "windows" ];then 96 echo "!!!build wasm on winows will occur unknown error, strongly suggest you build wasm on linux(Ubuntu)" 97 exit 98fi 99./build_operator.sh $is_debug $target $target_os $is_clean $gn_path $gn $ninja $target_operator 100