1fb726d48Sopenharmony_ci#!/bin/bash
2fb726d48Sopenharmony_ci# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
3fb726d48Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
4fb726d48Sopenharmony_ci# you may not use this file except in compliance with the License.
5fb726d48Sopenharmony_ci# You may obtain a copy of the License at
6fb726d48Sopenharmony_ci#
7fb726d48Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
8fb726d48Sopenharmony_ci#
9fb726d48Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
10fb726d48Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
11fb726d48Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb726d48Sopenharmony_ci# See the License for the specific language governing permissions and
13fb726d48Sopenharmony_ci# limitations under the License.
14fb726d48Sopenharmony_ciset -e
15fb726d48Sopenharmony_ciecho "target_operator = $target_operator"
16fb726d48Sopenharmony_ciif [ "$target" != "trace" ] && [ "$target" != "linux" ] && [ "$target" != "windows" ] &&
17fb726d48Sopenharmony_ci    [ "$target" != "macx" ] && [ "$target" != "trace_streamer" ] && [ "$target" != "wasm" ] &&
18fb726d48Sopenharmony_ci    [ "$target" != "test" ] && [ "$target" != "spb" ] && [ "$target" != "fuzz" ] &&
19fb726d48Sopenharmony_ci    [ "$target" != "protoc" ] && [ "$target" != "sdkdemo" ] && [ "$target" != "sdkdemotest" ];then
20fb726d48Sopenharmony_ci    echo "failed"
21fb726d48Sopenharmony_ci    exit
22fb726d48Sopenharmony_cifi
23fb726d48Sopenharmony_ciif [ "$target_operator" != "" ] && [ "$target_operator" != "debug" ] && [ "$target_operator" != "release" ] && [ "$target_operator" != "clean" ];then
24fb726d48Sopenharmony_ci    if [ "$target_operator" == "protoc" ];then
25fb726d48Sopenharmony_ci    target=$target_operator
26fb726d48Sopenharmony_ci    else
27fb726d48Sopenharmony_ci    echo "failed"
28fb726d48Sopenharmony_ci    exit
29fb726d48Sopenharmony_ci    fi
30fb726d48Sopenharmony_cifi
31fb726d48Sopenharmony_ciif [ "$target_operator" == "debug" ];then
32fb726d48Sopenharmony_ci    is_debug="true"
33fb726d48Sopenharmony_cielif [ "$target_operator" == "clean" ];then
34fb726d48Sopenharmony_ci    is_clean="true"
35fb726d48Sopenharmony_cielse
36fb726d48Sopenharmony_ci    is_debug="false"
37fb726d48Sopenharmony_cifi
38fb726d48Sopenharmony_ciecho "platform is $target_os"
39fb726d48Sopenharmony_ciecho "isdebug: $is_debug"
40fb726d48Sopenharmony_ciecho "isclean: $is_clean"
41fb726d48Sopenharmony_ciif [ "$is_debug" != "false" ];then
42fb726d48Sopenharmony_ci    ext="_debug"
43fb726d48Sopenharmony_cifi
44fb726d48Sopenharmony_ci
45fb726d48Sopenharmony_ciif [ "$target" == "test" ] || [ "$target" == "fuzz" ] || [ "$target" == "wasm" ] || [ "$target" == "sdkdemo" ] || [ "$target" == "sdkdemotest" ];then
46fb726d48Sopenharmony_ci    target_dir=$target
47fb726d48Sopenharmony_cielse
48fb726d48Sopenharmony_ci    target_dir=$target_os
49fb726d48Sopenharmony_cifi
50fb726d48Sopenharmony_ciif [ "$target" == "trace_streamer" ] || [ "$target" == "trace" ] || [ "$target" == "spb" ] || [ "$target" == "protoc" ];then
51fb726d48Sopenharmony_ci    target_dir=$target_os
52fb726d48Sopenharmony_cifi
53fb726d48Sopenharmony_ciecho "target_dir:" "$target_dir"
54fb726d48Sopenharmony_ciecho "target:" "$target"
55fb726d48Sopenharmony_ci
56fb726d48Sopenharmony_ciout_dir=out/$target_dir$ext
57fb726d48Sopenharmony_ciif [ "$is_clean" == "true" ];then
58fb726d48Sopenharmony_ci    prebuilts/"$gn_path"/"$gn" gen "$out_dir" --clean
59fb726d48Sopenharmony_ci    prebuilts/"$gn_path"/"$ninja" -C "$out_dir" -t clean
60fb726d48Sopenharmony_cielse
61fb726d48Sopenharmony_ci    prebuilts/"$gn_path"/"$gn" gen "$out_dir" --args='is_debug='"$is_debug"' target="'"$target"'" target_os="'"$target_os"'" is_independent_compile=true'' use_local_emsdk='"$use_local_emsdk"" $enable_all_plugins_str"
62fb726d48Sopenharmony_ci    echo "begin to build ..."
63fb726d48Sopenharmony_ci    prebuilts/"$gn_path"/"$ninja" -C "$out_dir"
64fb726d48Sopenharmony_cifi
65fb726d48Sopenharmony_ciif [ "$out_dir" == "macx" ];then
66fb726d48Sopenharmony_ci    ./mac_depend.sh
67fb726d48Sopenharmony_cifi