• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2022 Huawei Device Co., Ltd.
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.
13
14declare_args() {
15  another_path = true
16  ark_standalone_build = true
17  use_musl = false
18  build_root = "//toolchain/build"
19}
20
21if (target_os == "") {
22  target_os = "ohos"  #host_os#
23}
24
25if (target_cpu == "") {
26  if (target_os == "ohos") {
27    target_cpu = "x64"
28  } else {
29    target_cpu = host_cpu
30  }
31}
32
33if (current_cpu == "") {
34  current_cpu = host_cpu
35}
36if (current_os == "") {
37  current_os = host_os
38}
39
40# different host platform tools directory.
41if (host_os == "linux") {
42  host_platform_dir = "linux-x86_64"
43} else {
44  assert(false, "Unsupported host_os: $host_os")
45}
46
47declare_args() {
48  # Debug build. Enabling official builds automatically sets is_debug to false.
49  is_debug = false
50}
51
52declare_args() {
53  host_toolchain = ""
54  custom_toolchain = ""
55  is_standard_system = false
56
57  is_clang = current_os != "linux" ||
58             (current_cpu != "s390x" && current_cpu != "s390" &&
59              current_cpu != "ppc64" && current_cpu != "ppc" &&
60              current_cpu != "mips" && current_cpu != "mips64")
61}
62
63if (current_os == "ohos") {
64  is_ohos = true
65  is_linux = false
66  is_mac = false
67  is_posix = true
68  is_win = false
69  is_mingw = false
70} else if (current_os == "linux") {
71  is_ohos = false
72  is_linux = true
73  is_mac = false
74  is_posix = true
75  is_win = false
76  is_mingw = false
77} else if (current_os == "mingw") {
78  is_ohos = false
79  is_linux = false
80  is_mac = false
81  is_posix = true
82  is_win = false
83  is_mingw = true
84}
85
86if (host_toolchain == "") {
87  # This should only happen in the top-level context.
88  # In a specific toolchain context, the toolchain_args()
89  # block should have propagated a value down.
90
91  if (host_os == "linux") {
92    if (target_os != "linux") {
93      host_toolchain = "$build_root/toolchain/linux:clang_$host_cpu"
94    } else if (is_clang) {
95      host_toolchain = "$build_root/toolchain/linux:clang_$host_cpu"
96    } else {
97      host_toolchain = "$build_root/toolchain/linux:$host_cpu"
98    }
99  } else {
100    assert(false, "Unsupported host_os: $host_os")
101  }
102}
103
104_default_toolchain = ""
105
106if (target_os == "ohos") {
107  assert(host_os == "linux" || host_os == "mac",
108         "ohos builds are only supported on Linux and Mac hosts.")
109  _default_toolchain = "$build_root/toolchain/ark:ark_clang_$target_cpu"
110} else if (target_os == "linux") {
111  if (is_clang) {
112    _default_toolchain = "$build_root/toolchain/linux:clang_$target_cpu"
113  } else {
114    _default_toolchain = "$build_root/toolchain/linux:$target_cpu"
115  }
116} else {
117  assert(false, "Unsupported target_os: $target_os")
118}
119
120# If a custom toolchain has been set in the args, set it as default. Otherwise,
121# set the default toolchain for the platform (if any).
122if (custom_toolchain != "") {
123  set_default_toolchain(custom_toolchain)
124} else if (_default_toolchain != "") {
125  set_default_toolchain(_default_toolchain)
126}
127
128_shared_binary_target_configs = [ "$build_root/config:complier_defaults" ]
129
130default_compiler_configs = []
131
132set_defaults("executable") {
133  configs = _shared_binary_target_configs
134  configs += [ "$build_root/config:executable_ldconfig" ]
135}
136
137set_defaults("static_library") {
138  configs = _shared_binary_target_configs
139}
140
141set_defaults("shared_library") {
142  configs = _shared_binary_target_configs
143}
144
145set_defaults("source_set") {
146  configs = default_compiler_configs
147}
148