• 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/ohos/build_var.gni")
15import("//build/ohos/sdk/sdk.gni")
16import("//build/ohos_var.gni")
17import("${build_configs_path}/platforms_list.gni")
18
19parse_script = "//build/ohos/sdk/parse_sdk_description.py"
20ohos_sdk_description_file = "//build/ohos/sdk/ohos_sdk_description_std.json"
21if (defined(ext_sdk_config_file) && ext_sdk_config_file != "") {
22  ohos_sdk_description_file = ext_sdk_config_file
23}
24if (sdk_for_hap_build) {
25  hap_build_sdk_config_parser =
26      "//build/ohos/sdk/generate_hap_build_sdk_config.py"
27  hap_build_sdk_description_file = "//out/sdk/ohos_sdk_description_hap.json"
28  hap_build_sdk_args = [
29    "--sdk-description-file",
30    rebase_path(ohos_sdk_description_file, root_build_dir),
31    "--output-hap-build-sdk-desc-file",
32    rebase_path(hap_build_sdk_description_file, root_build_dir),
33  ]
34  exec_script(hap_build_sdk_config_parser, hap_build_sdk_args)
35  ohos_sdk_description_file = hap_build_sdk_description_file
36}
37
38if (sdk_build_public) {
39  public_sdk_config_parser = "//build/ohos/sdk/parse_public_sdk.py"
40  ohos_sdk_pub_description_file =
41      "//out/sdk-public/ohos_sdk_pub_description_std.json"
42  public_sdk_args = [
43    "--sdk-description-file",
44    rebase_path(ohos_sdk_description_file, root_build_dir),
45    "--root-build-dir",
46    rebase_path("//", root_build_dir),
47    "--node-js",
48    rebase_path(nodejs, root_build_dir),
49    "--output-pub-sdk-desc-file",
50    rebase_path(ohos_sdk_pub_description_file, root_build_dir),
51  ]
52  exec_script(public_sdk_config_parser, public_sdk_args)
53  ohos_sdk_description_file = ohos_sdk_pub_description_file
54}
55
56generated_sdk_modules_gni = "${generated_files_dir}/ohos_sdk_modules.gni"
57generated_sdk_types_file = "${generated_files_dir}/generated_sdk_types.txt"
58
59parse_args = [
60  "--sdk-description-file",
61  rebase_path(ohos_sdk_description_file, root_build_dir),
62  "--sdk-modules-gni",
63  rebase_path(generated_sdk_modules_gni, root_build_dir),
64  "--sdk-install-info-file",
65  rebase_path(generated_sdk_module_install_paths, root_build_dir),
66  "--sdk-types-file",
67  rebase_path(generated_sdk_types_file, root_build_dir),
68  "--base-platform",
69  "phone",
70  "--variant-to-product",
71  rebase_path("./variant_to_product.json", root_build_dir),
72  "--source-root-dir",
73  rebase_path("//", root_build_dir),
74  "--node-js",
75  rebase_path(nodejs, root_build_dir),
76]
77foreach(p, target_platform_list) {
78  parse_args += [
79    "--platforms",
80    p,
81  ]
82}
83
84exec_script(parse_script, parse_args)
85
86sdk_types = read_file(generated_sdk_types_file, "list lines")
87
88import("${generated_sdk_modules_gni}")
89
90generate_all_types_sdk_script = "//build/ohos/sdk/generate_all_types_sdk.py"
91generated_build_gn = "$generated_files_dir/BUILD.gn"
92generate_args = [
93  "--sdk-modules",
94  "ohos_sdk_modules",
95  "--output",
96  rebase_path(generated_build_gn, root_build_dir),
97  "--current-dir",
98  get_path_info(sdk_base_build_gn, "dir"),
99  "--generated-sdk-modules-gni",
100  generated_sdk_modules_gni,
101  "--type2displayname",
102  rebase_path("./type_to_display_name.json", root_build_dir),
103  "--api-version",
104  api_version,
105  "--release-type",
106  release_type,
107  "--meta-version",
108  meta_version,
109]
110
111foreach(os, sdk_systems) {
112  generate_args += [
113    "--sdk-systems",
114    os,
115  ]
116}
117
118foreach(sdk_type, sdk_types) {
119  generate_args += [
120    "--sdk-types",
121    sdk_type,
122  ]
123}
124
125exec_script(generate_all_types_sdk_script, generate_args)
126
127action_with_pydeps("generate_sdk_notice") {
128  deps = [ "${generated_files_dir}:generated_ohos_sdk" ]
129  inputs = []
130
131  script = "//build/ohos/notice/merge_notice_files.py"
132  depfile = "$target_gen_dir/$target_name.d"
133  _install_path = "${target_out_dir}/SDK_NOTICE_FILES/"
134
135  outputs = [
136    sdk_notice_txt,
137    sdk_notice_gz,
138  ]
139  args = [
140    "--image-name",
141    "sdk",
142    "--notice-root-dir",
143    rebase_path(sdk_notice_dir, root_build_dir),
144    "--output-notice-txt",
145    rebase_path(sdk_notice_txt, root_build_dir),
146    "--output-notice-gz",
147    rebase_path(sdk_notice_gz, root_build_dir),
148    "--notice-title",
149    "Notices for files contained in SDK in this directory:",
150    "--static-library-notice-dir",
151    rebase_path(static_libraries_notice_dir, root_build_dir),
152    "--target-cpu",
153    target_cpu,
154    "--depfile",
155    rebase_path(depfile, root_build_dir),
156  ]
157
158  foreach(type, sdk_types) {
159    foreach(os, sdk_systems) {
160      args += [
161        "--collected-notice-zipfile",
162        rebase_path("${sdk_notice_archive_dir}/${os}-${type}.zip",
163                    root_build_dir),
164      ]
165      inputs += [ "${sdk_notice_archive_dir}/${os}-${type}.zip" ]
166    }
167  }
168}
169
170action("verify_sdk_notice_file") {
171  deps = [ ":generate_sdk_notice" ]
172
173  script = "//build/core/build_scripts/verify_notice.sh"
174  _verify_result = "${target_out_dir}/sdk_notice_verify_result.out"
175
176  outputs = [ _verify_result ]
177
178  args = [
179    rebase_path(sdk_notice_txt, root_build_dir),
180    rebase_path(_verify_result, root_build_dir),
181    rebase_path("${product_output_dir}/${product_name}", root_build_dir),
182  ]
183}
184
185group("ohos_sdk_pre") {
186  deps = [
187    ":generate_sdk_notice",
188    ":verify_sdk_notice_file",
189    "${generated_files_dir}:generated_ohos_sdk",
190  ]
191}
192
193sdk_delivery_list = "//build/ohos/sdk/sdk_delivery_list.json"
194action("check_sdk_completeness") {
195  deps = [
196    ":ohos_sdk",
197    "//build/ohos/ndk:ohos_ndk",
198  ]
199  if (host_os == "mac" && enable_sign) {
200    deps += [ ":sign_sdk" ]
201  }
202
203  script = "//build/ohos/sdk/check_sdk_completeness.py"
204  _verify_result = "${target_out_dir}/check_sdk_completeness.txt"
205
206  outputs = [ _verify_result ]
207
208  args = [
209    "--sdk-delivery-list",
210    rebase_path(sdk_delivery_list, root_build_dir),
211    root_build_dir,
212    "--sdk-archive-dir",
213    rebase_path("${product_output_dir}/${product_name}", root_build_dir),
214    product_name,
215    sdk_version,
216    "--sdk-platform",
217    sdk_platform,
218  ]
219}
220
221action_with_pydeps("add_notice_file") {
222  deps = [
223    ":generate_sdk_notice",
224    ":ohos_sdk_pre",
225  ]
226  script = "//build/ohos/sdk/add_notice_file.py"
227  _output = target_gen_dir + "/$target_name.stamp"
228  depfile = "$target_gen_dir/$target_name.d"
229  args = [
230    "--sdk-notice-file",
231    rebase_path(sdk_notice_txt, root_build_dir),
232    "--sdk-archive-dir",
233    rebase_path("${product_output_dir}/${product_name}", root_build_dir),
234    "--output",
235    rebase_path(_output, root_build_dir),
236    "--depfile",
237    rebase_path(depfile, root_build_dir),
238    "--skip-pattern",
239    "native",
240  ]
241
242  inputs = [ sdk_notice_txt ]
243  outputs = [ _output ]
244}
245
246action("sign_sdk") {
247  deps = [
248    ":ohos_sdk",
249    "//build/ohos/ndk:ohos_ndk",
250  ]
251  script = "//build/scripts/sign_sdk.py"
252  args = [
253    "--sdk-out-dir",
254    rebase_path(ohos_sdk_out_dir, root_build_dir),
255  ]
256  outputs = [ "$target_out_dir/$target_name.stamp" ]
257}
258
259group("ohos_sdk") {
260  deps = [
261    ":add_notice_file",
262    ":ohos_sdk_pre",
263  ]
264}
265
266group("ohos_sdk_verify") {
267  deps = []
268
269  if (sdk_check_flag) {
270    deps += [ ":check_sdk_completeness" ]
271  }
272}
273