• 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
14template("ohos_executable") {
15  executable(target_name) {
16    forward_variables_from(invoker,
17                           "*",
18                           [
19                             "configs",
20                             "remove_configs",
21                             "subsystem_name",
22                             "install_enable",
23                             "part_name",
24                             "use_exceptions",
25                             "static_link",
26                             "output_dir",
27                           ])
28    if (defined(invoker.subsystem_name) && defined(invoker.part_name)) {
29      subsystem_name = invoker.subsystem_name
30      part_name = invoker.part_name
31    } else if (defined(invoker.subsystem_name)) {
32      subsystem_name = invoker.subsystem_name
33      part_name = subsystem_name
34    } else {
35      subsystem_name = "arkcompiler"
36      part_name = "common"
37    }
38    if (is_standard_system) {
39      output_dir = "${root_out_dir}/${subsystem_name}/${part_name}"
40    } else {
41      output_dir = "${root_out_dir}"
42    }
43    if (defined(invoker.configs)) {
44      configs += invoker.configs
45    }
46
47    if (defined(invoker.remove_configs)) {
48      configs -= invoker.remove_configs
49    }
50
51    if (defined(invoker.use_exceptions) && invoker.use_exceptions) {
52      configs += [ "//toolchain/build/config/compiler:exceptions" ]
53    }
54  }
55}
56template("ohos_static_library") {
57  static_library(target_name) {
58    forward_variables_from(invoker,
59                           "*",
60                           [
61                             "configs",
62                             "remove_configs",
63                             "subsystem_name",
64                             "part_name",
65                             "use_exceptions",
66                             "external_deps",
67                           ])
68    if (defined(invoker.configs)) {
69      configs += invoker.configs
70    }
71
72    if (defined(invoker.remove_configs)) {
73      configs -= invoker.remove_configs
74    }
75
76    if (defined(invoker.use_exceptions) && invoker.use_exceptions) {
77      configs += [ "//toolchain/build/config/compiler:exceptions" ]
78    }
79  }
80}
81template("ohos_shared_library") {
82  shared_library(target_name) {
83    forward_variables_from(invoker,
84                           "*",
85                           [
86                             "relative_install_dir",
87                             "subsystem_name",
88                             "install_enable",
89                             "part_name",
90                             "install_images",
91                             "use_exceptions",
92                             "external_deps",
93                           ])
94    if (defined(invoker.subsystem_name) && defined(invoker.part_name)) {
95      subsystem_name = invoker.subsystem_name
96      part_name = invoker.part_name
97    } else if (defined(invoker.subsystem_name)) {
98      subsystem_name = invoker.subsystem_name
99      part_name = subsystem_name
100    } else {
101      subsystem_name = "arkcompiler"
102      part_name = "common"
103    }
104    if (is_standard_system) {
105      output_dir = "${root_out_dir}/${subsystem_name}/${part_name}"
106    } else {
107      output_dir = "${root_out_dir}"
108    }
109  }
110}
111
112template("ohos_copy") {
113  copy(target_name) {
114    forward_variables_from(invoker,
115                           "*",
116                           [
117                             "module_source_dir",
118                             "module_install_name",
119                           ])
120  }
121}
122
123template("ohos_source_set") {
124  source_set(target_name) {
125    forward_variables_from(invoker,
126                           "*",
127                           [
128                             "configs",
129                             "remove_configs",
130                             "no_default_deps",
131                             "external_deps",
132                             "license_file",
133                             "license_as_sources",
134                             "use_exceptions",
135                           ])
136  }
137}
138