• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15ext="/clang_x64"
16target_dir="linux"
17subsys_name="developtools"
18part_name="profiler"
19is_debug="$1"
20target="$2"
21target_os="$3"
22is_clean="$4"
23gn_path="$5"
24gn="$6"
25ninja="$7"
26target_operator="$8"
27if [ "$#" -ge "7" ];then
28    if [ "$target" != "trace" ] && [ "$target" != "linux" ] && [ "$target" != "windows" ] &&
29        [ "$target" != "macx" ] && [ "$target" != "trace_streamer" ] && [ "$target" != "wasm" ] &&
30        [ "$target" != "test" ] && [ "$target" != "spb" ] && [ "$target" != "fuzz" ] &&
31        [ "$target" != "protoc" ] && [ "$target" != "sdkdemo" ] && [ "$target" != "dubaisdk" ] && [ "$target" != "sdkdemotest" ];then
32        echo "failed"
33        exit
34    fi
35    if [ "$target_operator" != "" ] && [ "$target_operator" != "debug" ] && [ "$target_operator" != "release" ] && [ "$target_operator" != "clean" ];then
36        if [ "$target_operator" == "protoc" ];then
37        target=$target_operator
38        else
39        echo "failed"
40        exit
41        fi
42    fi
43    if [ "$target_operator" == "debug" ];then
44        is_debug="true"
45    elif [ "$target_operator" == "clean" ];then
46        is_clean="true"
47    else
48        is_debug="false"
49    fi
50    echo "platform is $target_os"
51    echo "isdebug: $is_debug"
52    echo "isclean: $is_clean"
53else
54    echo "$usage"
55    echo "It is not recommended to execute this file and use it by build.sh."
56    echo "use default input paramter"
57    echo "platform is $target_os"
58    echo "target is $target"
59    echo "is_debug:$is_debug"
60    exit
61fi
62if [ "$is_debug" != "false" ];then
63       	ext="_debug"
64fi
65
66if [ "$target" == "test" ] || [ "$target" == "fuzz" ] || [ "$target"="wasm" ] || [ "$target"="sdkdemo" ] || [ "$target"="sdkdemotest" ];then
67    target_dir=$target
68else
69    target_dir=$target_os
70fi
71if [ "$target" == "trace_streamer" ] || [ "$target" == "trace" ] || [ "$target" == "spb" ] || [ "$target" == "protoc" ];then
72    target_dir=$target_os
73fi
74echo "target_dir:" $target_dir
75echo "target:" $target
76# exit
77if [ "$is_clean" == "true"  ];then
78    prebuilts/$gn_path/$gn gen out/"$target_dir""$ext"/$subsys_name/$part_name --clean
79    prebuilts/$gn_path/$ninja -C out/"$target_dir""$ext"/$subsys_name/$part_name -t clean
80else
81    prebuilts/$gn_path/$gn gen out/"$target_dir""$ext"/$subsys_name/$part_name --args='is_debug='"$is_debug"' target="'"$target"'" target_os="'"$target_os"'"'
82    echo "begin to build ..."
83    prebuilts/$gn_path/$ninja -C out/"$target_dir""$ext"/$subsys_name/$part_name
84    if [ $target_dir == "linux" ] && [ -f "out/$target_dir$ext/$subsys_name/$part_name/trace_streamer" ];then
85        mkdir -p out/linux
86        cp out/"$target_dir""$ext"/$subsys_name/$part_name/trace_streamer out/linux/
87    fi
88fi
89