• 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/config/python.gni")
15import("//build/ohos/ndk/ndk.gni")
16import("//build/ohos/sdk/sdk.gni")
17
18package_info_name = "oh-uni-package"
19if (defined(ext_ndk_config_file) && ext_ndk_config_file != "") {
20  ext_ndk_target = rebase_path(ext_ndk_config_file)
21  import(ext_ndk_target)
22  package_info_name = "uni-package"
23} else {
24  import("//build/ohos/ndk/ndk_targets.gni")
25}
26
27package_info_file = "$ndk_os_irrelevant_out_dir/$package_info_name.json"
28
29package_info = {
30  path = "native"
31  displayName = "Native"
32  version = current_ndk_version
33  if (release_type != "") {
34    releaseType = release_type
35  }
36  if (meta_version != "") {
37    meta = {
38      metaVersion = meta_version
39    }
40  }
41  if (defined(ext_ndk_config_file) && ext_ndk_config_file != "") {
42    platformVersion = platform_version
43  }
44  apiVersion = api_version
45}
46write_file(package_info_file, package_info, "json")
47
48action_with_pydeps("_collect_ndk_syscap") {
49  deps = all_ndk_targets_list
50  script = "//build/ohos/ndk/collect_ndk_syscap.py"
51  depfile = "$target_gen_dir/$target_name.d"
52  _ndk_syscap_desc_file =
53      "${ndk_os_irrelevant_out_dir}/ndk_system_capability.json"
54  _native_syscap_config_file =
55      "${ndk_os_irrelevant_out_dir}/nativeapi_syscap_config.json"
56  outputs = [ _ndk_syscap_desc_file ]
57  args = [
58    "--depfile",
59    rebase_path(depfile, root_build_dir),
60    "--system-capability-file",
61    rebase_path(_ndk_syscap_desc_file, root_build_dir),
62    "--system-capability-header-config",
63    rebase_path(_native_syscap_config_file, root_build_dir),
64    "--targets-build-config",
65  ]
66  foreach(_ndk_target, all_ndk_targets_list) {
67    _target_bc_file = get_label_info(_ndk_target, "target_gen_dir") + "/" +
68                      get_label_info(_ndk_target, "name") + ".build_config"
69    args += [ rebase_path(_target_bc_file, root_build_dir) ]
70  }
71}
72
73group("all_ndk_targets") {
74  deps = [ ":_collect_ndk_syscap" ]
75}
76
77ndk_targets = [
78  ":ndk_doxygen",
79  ":all_ndk_targets",
80  ":merge_ndk_notice",
81  ":verify_ndk_notice_file",
82]
83
84group("ohos_ndk") {
85  deps = ndk_targets
86  if (archive_ndk) {
87    deps += [ ":archive_ndk" ]
88  }
89}
90
91group("ndk_doxygen") {
92  deps = [
93    ":create_docs_portal_and_archive",
94    ":generate_ndk_docs",
95  ]
96}
97
98# doxygen always generates index.html
99ndk_doxygen_output = "$ndk_docs_out_dir/html"
100ndk_docs_portal = "$ndk_docs_out_dir/index.html"
101
102action_with_pydeps("generate_ndk_docs") {
103  deps = [ ":all_ndk_targets" ]
104  script = "//build/ohos/ndk/generate_ndk_docs.py"
105  depfile = "$target_gen_dir/$target_name.d"
106
107  doxygen_file = "//build/ohos/ndk/Doxyfile"
108  inputs = [ doxygen_file ]
109
110  version = current_ndk_version
111  working_dir = "$ndk_headers_out_dir"
112
113  outputs = [ ndk_doxygen_output ]
114
115  args = [
116    "--depfile",
117    rebase_path(depfile, root_build_dir),
118    "--working-dir",
119    rebase_path(working_dir, root_build_dir),
120    "--version",
121    version,
122    "--output",
123    rebase_path(ndk_doxygen_output, root_build_dir),
124    "--doxygen-file",
125    rebase_path(doxygen_file, root_build_dir),
126    "--record-path",
127    rebase_path("$target_gen_dir/" + get_path_info(ndk_doxygen_output, "file") +
128                    ".md5.stamp",
129                root_build_dir),
130  ]
131}
132
133action_with_pydeps("create_docs_portal_and_archive") {
134  deps = [ ":generate_ndk_docs" ]
135  script = "//build/ohos/ndk/create_ndk_docs_portal.py"
136  depfile = "$target_gen_dir/$target_name.d"
137  args = [
138    "--depfile",
139    rebase_path(depfile, root_build_dir),
140    "--doxygen-output",
141    rebase_path(ndk_doxygen_output + "/index.html", root_build_dir),
142    "--record-path",
143    rebase_path("$target_gen_dir/" + get_path_info(ndk_docs_portal, "file") +
144                    ".md5.stamp",
145                root_build_dir),
146    "--portal-path",
147    rebase_path(ndk_docs_portal, root_build_dir),
148  ]
149  outputs = [ ndk_docs_portal ]
150}
151
152ohos_ndk_copy("ndk_cmake_files") {
153  dest_dir = "$ndk_os_irrelevant_out_dir/build"
154  sources = [ "./cmake" ]
155}
156
157action("cmake_patch") {
158  if (host_os == "mac") {
159    deps = [ "//prebuilts/cmake/darwin-x86:darwin_cmake_copy" ]
160  } else {
161    deps = [
162      "//prebuilts/cmake/linux-x86:linux_cmake_copy",
163      "//prebuilts/cmake/windows-x86:windows_cmake_copy",
164    ]
165  }
166  script = "//build/ohos/ndk/cmake_patch.sh"
167  args = [
168    rebase_path("$ndk_linux_tools_out_dir/cmake/share/cmake-3.16/Modules"),
169    rebase_path("$ndk_windows_tools_out_dir/cmake/share/cmake-3.16/Modules"),
170    rebase_path("$ndk_darwin_tools_out_dir/cmake/share/cmake-3.16/Modules"),
171  ]
172  outputs = [ "${target_out_dir}/${target_name}.stamp" ]
173}
174
175action_with_pydeps("merge_ndk_notice") {
176  deps = [ ":all_ndk_targets" ]
177  script = "//build/ohos/notice/merge_notice_files.py"
178  depfile = "$target_gen_dir/$target_name.d"
179
180  outputs = [
181    ndk_notice_txt,
182    ndk_notice_gz,
183  ]
184
185  args = [
186    "--image-name",
187    "ndk",
188    "--notice-root-dir",
189    rebase_path(ndk_notice_dir, root_build_dir),
190    "--output-notice-txt",
191    rebase_path(ndk_notice_txt, root_build_dir),
192    "--output-notice-gz",
193    rebase_path(ndk_notice_gz, root_build_dir),
194    "--notice-title",
195    "Notices for files and software contained in sdk-native in this directory:",
196    "--static-library-notice-dir",
197    rebase_path(static_libraries_notice_dir, root_build_dir),
198    "--target-cpu",
199    target_cpu,
200    "--depfile",
201    rebase_path(depfile, root_build_dir),
202  ]
203}
204
205action("verify_ndk_notice_file") {
206  deps = [ ":merge_ndk_notice" ]
207
208  script = "//build/core/build_scripts/verify_notice.sh"
209  _verify_result = "${target_out_dir}/ndk_notice_verify_result.out"
210
211  outputs = [ _verify_result ]
212
213  args = [
214    rebase_path(ndk_notice_txt, root_build_dir),
215    rebase_path(_verify_result, root_build_dir),
216    rebase_path(target_out_dir, root_build_dir),
217  ]
218}
219
220group("archive_ndk") {
221  deps = []
222  if (ndk_platform == "default") {
223    if (host_os == "mac") {
224      deps += [ ":archive_darwin_ndk" ]
225    } else {
226      deps += [
227        ":archive_linux_ndk",
228        ":archive_windows_ndk",
229      ]
230    }
231  } else if (ndk_platform == "win") {
232    deps += [ ":archive_windows_ndk" ]
233  } else if (ndk_platform == "mac") {
234    deps += [ ":archive_darwin_ndk" ]
235  } else if (ndk_platform == "linux") {
236    deps += [ ":archive_linux_ndk" ]
237  }
238}
239
240action_with_pydeps("archive_windows_ndk") {
241  deps = ndk_targets
242  script = "//build/ohos/ndk/archive_ndk.py"
243  depfile = "$target_gen_dir/$target_name.d"
244  _output = "$ohos_sdk_out_dir/${windows_system}/${ndk_zip_prefix}-${windows_system}-${arch}-${current_ndk_version}"
245  if (release_type != "") {
246    _output += "-${release_type}.zip"
247  } else {
248    _output += ".zip"
249  }
250
251  args = [
252    "--os-irrelevant-dir",
253    rebase_path(ndk_os_irrelevant_out_dir, root_build_dir),
254    "--output",
255    rebase_path(_output, root_build_dir),
256    "--depfile",
257    rebase_path(depfile, root_build_dir),
258    "--os-specific-dir",
259    rebase_path("$ndk_windows_specific_out_dir", root_build_dir),
260    "--notice-file",
261    rebase_path(ndk_notice_txt, root_build_dir),
262    "--prefix",
263    ndk_zip_prefix,
264    "--record-path",
265    rebase_path(
266        "$target_gen_dir/" + get_path_info(_output, "file") + ".md5.stamp",
267        root_build_dir),
268    "--platform",
269    "windows",
270  ]
271  outputs = [ _output ]
272}
273
274action_with_pydeps("archive_linux_ndk") {
275  deps = ndk_targets
276  script = "//build/ohos/ndk/archive_ndk.py"
277  depfile = "$target_gen_dir/$target_name.d"
278  _output = "$ohos_sdk_out_dir/${linux_system}/${ndk_zip_prefix}-${linux_system}-${arch}-${current_ndk_version}"
279  if (release_type != "") {
280    _output += "-${release_type}.zip"
281  } else {
282    _output += ".zip"
283  }
284
285  args = [
286    "--os-irrelevant-dir",
287    rebase_path(ndk_os_irrelevant_out_dir, root_build_dir),
288    "--output",
289    rebase_path(_output, root_build_dir),
290    "--depfile",
291    rebase_path(depfile, root_build_dir),
292    "--notice-file",
293    rebase_path(ndk_notice_txt, root_build_dir),
294    "--os-specific-dir",
295    rebase_path("$ndk_linux_specific_out_dir", root_build_dir),
296    "--prefix",
297    ndk_zip_prefix,
298    "--record-path",
299    rebase_path(
300        "$target_gen_dir/" + get_path_info(_output, "file") + ".md5.stamp",
301        root_build_dir),
302  ]
303  outputs = [ _output ]
304}
305
306action_with_pydeps("archive_darwin_ndk") {
307  deps = ndk_targets
308  script = "//build/ohos/ndk/archive_ndk.py"
309  depfile = "$target_gen_dir/$target_name.d"
310  _output = "$ohos_sdk_out_dir/${darwin_system}/${ndk_zip_prefix}-${darwin_system}-${arch}-${current_ndk_version}"
311  if (release_type != "") {
312    _output += "-${release_type}.zip"
313  } else {
314    _output += ".zip"
315  }
316
317  args = [
318    "--os-irrelevant-dir",
319    rebase_path(ndk_os_irrelevant_out_dir, root_build_dir),
320    "--output",
321    rebase_path(_output, root_build_dir),
322    "--depfile",
323    rebase_path(depfile, root_build_dir),
324    "--notice-file",
325    rebase_path(ndk_notice_txt, root_build_dir),
326    "--os-specific-dir",
327    rebase_path("$ndk_darwin_specific_out_dir", root_build_dir),
328    "--prefix",
329    ndk_zip_prefix,
330    "--record-path",
331    rebase_path(
332        "$target_gen_dir/" + get_path_info(_output, "file") + ".md5.stamp",
333        root_build_dir),
334  ]
335  outputs = [ _output ]
336}
337