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