• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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
14import("//build/templates/common/copy.gni")
15
16template("ohos_prebuilt_executable") {
17  assert(defined(invoker.source), "source must be defined for ${target_name}.")
18
19  if (defined(invoker.output)) {
20    _copy_output = "${target_out_dir}/${invoker.output}"
21  } else {
22    _copy_output = "${target_out_dir}/${invoker.source}"
23  }
24  ohos_copy(target_name) {
25    forward_variables_from(invoker,
26                           [
27                             "testonly",
28                             "visibility",
29
30                             "deps",
31                             "public_configs",
32                             "subsystem_name",
33                             "part_name",
34
35                             # For generate_module_info
36                             "install_images",
37                             "module_install_dir",
38                             "relative_install_dir",
39                             "symlink_target_name",
40
41                             # Open source license related
42                             "license_file",
43                             "license_as_sources",
44                           ])
45    set_sources_assignment_filter([])
46    sources = [ invoker.source ]
47    outputs = [ _copy_output ]
48    module_type = "bin"
49    prebuilt = true
50    install_enable = false
51    if (defined(invoker.install_enable)) {
52      install_enable = invoker.install_enable
53    }
54  }
55}
56
57template("ohos_prebuilt_shared_library") {
58  assert(defined(invoker.source), "source must be defined for ${target_name}.")
59
60  if (defined(invoker.output)) {
61    _copy_output = "${target_out_dir}/${invoker.output}"
62  } else {
63    _copy_output = "${target_out_dir}/${invoker.source}"
64  }
65  config("${target_name}__config") {
66    libs = [ _copy_output ]
67  }
68  ohos_copy(target_name) {
69    forward_variables_from(invoker,
70                           [
71                             "testonly",
72                             "visibility",
73
74                             "deps",
75                             "public_configs",
76                             "subsystem_name",
77                             "part_name",
78
79                             # For generate_module_info
80                             "install_images",
81                             "module_install_dir",
82                             "relative_install_dir",
83                             "symlink_target_name",
84
85                             # Open source license related
86                             "license_file",
87                             "license_as_sources",
88                           ])
89    set_sources_assignment_filter([])
90    sources = [ invoker.source ]
91    outputs = [ _copy_output ]
92    module_type = "lib"
93    prebuilt = true
94    install_enable = true
95    if (defined(invoker.install_enable)) {
96      install_enable = invoker.install_enable
97    }
98    if (!defined(public_configs)) {
99      public_configs = []
100    }
101    public_configs += [ ":${target_name}__config" ]
102  }
103}
104
105template("ohos_prebuilt_static_library") {
106  assert(defined(invoker.source), "source must be defined for ${target_name}.")
107
108  if (defined(invoker.output)) {
109    _copy_output = "${target_out_dir}/${invoker.output}"
110  } else {
111    _copy_output = "${target_out_dir}/${invoker.source}"
112  }
113  config("${target_name}__config") {
114    libs = [ _copy_output ]
115  }
116  ohos_copy(target_name) {
117    forward_variables_from(invoker,
118                           [
119                             "testonly",
120                             "visibility",
121
122                             "deps",
123                             "public_configs",
124                             "subsystem_name",
125                             "part_name",
126
127                             # Open source license related
128                             "license_file",
129                             "license_as_sources",
130                           ])
131    set_sources_assignment_filter([])
132    sources = [ invoker.source ]
133    outputs = [ _copy_output ]
134    bypass_module_info_generation = true
135    if (!defined(public_configs)) {
136      public_configs = []
137    }
138    public_configs += [ ":${target_name}__config" ]
139  }
140}
141
142template("ohos_prebuilt_etc") {
143  assert(defined(invoker.source), "source must be defined for ${target_name}.")
144
145  if (defined(invoker.output)) {
146    _copy_output = "${target_out_dir}/${invoker.output}"
147  } else {
148    _copy_output = "${target_out_dir}/${invoker.source}"
149  }
150  ohos_copy(target_name) {
151    forward_variables_from(invoker,
152                           [
153                             "testonly",
154                             "visibility",
155
156                             "deps",
157                             "public_configs",
158                             "subsystem_name",
159                             "part_name",
160
161                             # For generate_module_info
162                             "install_images",
163                             "module_install_dir",
164                             "relative_install_dir",
165                             "symlink_target_name",
166
167                             # Open source license related
168                             "license_file",
169                             "license_as_sources",
170                           ])
171    set_sources_assignment_filter([])
172    sources = [ invoker.source ]
173    outputs = [ _copy_output ]
174    module_type = "etc"
175    prebuilt = true
176    install_enable = true
177    if (defined(invoker.install_enable)) {
178      install_enable = invoker.install_enable
179    }
180  }
181}
182