• 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    enable_strip = false
52    if (defined(invoker.enable_strip) && invoker.enable_strip) {
53      enable_strip = true
54    }
55    if (defined(invoker.install_enable)) {
56      install_enable = invoker.install_enable
57    }
58  }
59}
60
61template("ohos_prebuilt_shared_library") {
62  assert(defined(invoker.source), "source must be defined for ${target_name}.")
63
64  if (defined(invoker.output)) {
65    _copy_output = "${target_out_dir}/${invoker.output}"
66  } else {
67    _copy_output = "${target_out_dir}/${invoker.source}"
68  }
69  config("${target_name}__config") {
70    libs = [ _copy_output ]
71  }
72  ohos_copy(target_name) {
73    forward_variables_from(invoker,
74                           [
75                             "testonly",
76                             "visibility",
77
78                             "deps",
79                             "public_configs",
80                             "subsystem_name",
81                             "part_name",
82
83                             # For generate_module_info
84                             "install_images",
85                             "module_install_dir",
86                             "relative_install_dir",
87                             "symlink_target_name",
88
89                             # Open source license related
90                             "license_file",
91                             "license_as_sources",
92                           ])
93    set_sources_assignment_filter([])
94    sources = [ invoker.source ]
95    outputs = [ _copy_output ]
96    module_type = "lib"
97    prebuilt = true
98    install_enable = true
99    enable_strip = false
100    if (defined(invoker.enable_strip) && invoker.enable_strip) {
101      enable_strip = true
102    }
103    if (defined(invoker.install_enable)) {
104      install_enable = invoker.install_enable
105    }
106    if (!defined(public_configs)) {
107      public_configs = []
108    }
109    public_configs += [ ":${target_name}__config" ]
110  }
111}
112
113template("ohos_prebuilt_static_library") {
114  assert(defined(invoker.source), "source must be defined for ${target_name}.")
115
116  if (defined(invoker.output)) {
117    _copy_output = "${target_out_dir}/${invoker.output}"
118  } else {
119    _copy_output = "${target_out_dir}/${invoker.source}"
120  }
121  config("${target_name}__config") {
122    libs = [ _copy_output ]
123  }
124  ohos_copy(target_name) {
125    forward_variables_from(invoker,
126                           [
127                             "testonly",
128                             "visibility",
129
130                             "deps",
131                             "public_configs",
132                             "subsystem_name",
133                             "part_name",
134
135                             # Open source license related
136                             "license_file",
137                             "license_as_sources",
138                           ])
139    set_sources_assignment_filter([])
140    sources = [ invoker.source ]
141    outputs = [ _copy_output ]
142    bypass_module_info_generation = true
143    if (!defined(public_configs)) {
144      public_configs = []
145    }
146    public_configs += [ ":${target_name}__config" ]
147  }
148}
149
150template("ohos_prebuilt_etc") {
151  assert(defined(invoker.source), "source must be defined for ${target_name}.")
152
153  if (defined(invoker.output)) {
154    _copy_output = "${target_out_dir}/${invoker.output}"
155  } else {
156    _copy_output = "${target_out_dir}/${invoker.source}"
157  }
158  ohos_copy(target_name) {
159    forward_variables_from(invoker,
160                           [
161                             "testonly",
162                             "visibility",
163
164                             "deps",
165                             "public_configs",
166                             "subsystem_name",
167                             "part_name",
168
169                             # For generate_module_info
170                             "install_images",
171                             "module_install_dir",
172                             "relative_install_dir",
173                             "symlink_target_name",
174
175                             # Open source license related
176                             "license_file",
177                             "license_as_sources",
178                           ])
179    set_sources_assignment_filter([])
180    sources = [ invoker.source ]
181    outputs = [ _copy_output ]
182    module_type = "etc"
183    prebuilt = true
184    install_enable = true
185    if (defined(invoker.install_enable)) {
186      install_enable = invoker.install_enable
187    }
188  }
189}
190