• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13is_win = false
14is_linux = false
15is_mac = false
16is_protoc = false
17is_mingw = false
18with_libunwind = false
19is_sdkdemo = false
20is_sdkdemo_test = false
21is_spb = false
22target_cpu = "x64"
23build_llvm_with_ts = true
24
25declare_args() {
26  ar = "ar"
27  is_debug = true
28  use_wasm = false
29  wasm_use_thread = false
30  is_test = false
31  is_sdkdemo = false
32  is_sdkdemo_test = false
33  testonly = false
34  is_fuzz = false
35  is_mac = false
36  is_spb = false
37  target = "trace_streamer"
38  enable_addr2line = false
39}
40if (target_os == "linux") {
41  is_linux = true
42  current_cpu = target_cpu
43  current_os = host_os
44} else if (target_os == "macx") {
45  is_mac = true
46  current_cpu = target_cpu
47  current_os = host_os
48} else if (target_os == "windows") {
49  is_win = true
50  is_mingw = true
51  current_cpu = target_cpu
52  current_os = host_os
53} else {
54  print("unknown platform " + target_os)
55  exit(-1)
56}
57
58if (target == "wasm") {
59  use_wasm = true
60} else if (target == "test") {
61  is_test = true
62  testonly = true
63} else if (target == "fuzz") {
64  is_fuzz = true
65  testonly = true
66} else if (target == "protoc") {
67  is_protoc = true
68} else if (target == "sdkdemo") {
69  is_sdkdemo = true
70  use_wasm = true
71} else if (target == "sdkdemotest") {
72  is_sdkdemo_test = true
73  testonly = true
74} else if (target == "trace_streamer" || target == "streamer") {
75  print("build " + target)
76} else if (target == "spb") {
77  is_linux = true
78  is_spb = true
79} else {
80  print("unknown target " + target_os)
81  exit(-1)
82}
83
84trace_cfg_path = "//gn:trace_cfg"
85print("platform " + target_os)
86default_configs = [
87  "//gn:symbols",
88  "//gn:default",
89  trace_cfg_path,
90]
91hiperf_default_configs = [
92  "//gn:symbols",
93  "//gn:default",
94  "//gn:hiperf_trace_cfg",
95]
96
97if (!is_debug) {
98  default_configs -= [ "//gn:symbols" ]
99  default_configs += [ "//gn:release" ]
100  hiperf_default_configs -= [ "//gn:symbols" ]
101  hiperf_default_configs += [ "//gn:release" ]
102}
103
104llvm_include_configs = []
105if (enable_addr2line) {
106  llvm_include_configs += [ "//llvm/utils/gn/build:llvm_code" ]
107}
108
109set_defaults("static_library") {
110  configs = default_configs
111  configs += llvm_include_configs
112}
113
114set_defaults("ohos_source_set") {
115  configs = default_configs
116}
117
118set_defaults("ohos_shared_library") {
119  configs = default_configs
120}
121set_defaults("executable") {
122  configs = default_configs
123  configs += llvm_include_configs
124  configs += [ "//gn:executable" ]
125}
126if (use_wasm) {
127  set_default_toolchain("//gn/toolchain:wasm")
128} else {
129  set_default_toolchain("//gn/toolchain:gcc_like")
130}
131
132host_toolchain = "//gn/toolchain:gcc_like"
133