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