• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2022 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.gni")
15import("//build/ohos/notice/notice.gni")
16import("//build/ohos_var.gni")
17import("//build/templates/metadata/module_info.gni")
18import("interface_config.gni")
19
20# 全局变量方法见 https://gitee.com/openharmony/build/blob/master/docs/cmake%E8%BD%ACgn%E6%8C%87%E5%AF%BC%E6%96%87%E6%A1%A3.md#gn%E5%B8%B8%E7%94%A8%E7%9A%84%E5%86%85%E7%BD%AE%E5%8F%98%E9%87%8F
21
22template("ohos_copy_internal") {
23  forward_variables_from(invoker, "*")
24  iv_input = invoker.iv_input
25
26  # 调用build/templates/common/copy.gni中的ohos_copy方法
27  # 将处理完成的文件输出到中间产物对应位置 out/sdk/obj/interface/sdk-js/$target_name
28  ohos_copy(target_name) {
29    # 该脚本根据传入的remove文件进行input文件规则检查,过滤不需要的文件
30    # remove文件没有对应$target_name的属性  则全部输出
31    # remove文件有对应$target_name的属性    保留base中的文件;
32    #                                      删除global_remove中的文件;
33    #                                     ispublic为真,删除sdk_build_public_remove文件。
34    process_script = "//interface/sdk-js/process_internal.py"
35    process_arguments = [
36      "--input",
37      rebase_path(iv_input, root_build_dir),
38      "--remove",
39      rebase_path("//interface/sdk-js/remove_list.json", root_build_dir),
40      "--ispublic",
41      "${sdk_build_public}",
42      "--name",
43      "$target_name",
44    ]
45
46    # 执行脚本
47    sources = exec_script(process_script, process_arguments, "value")
48    outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
49    module_source_dir = target_out_dir + "/$target_name"
50    module_install_name = ""
51  }
52}
53
54# 主要api处理template
55template("ohos_declaration_template") {
56  forward_variables_from(invoker, "*")
57  _module_info_target = "/ohos_declaration/${target_name}_info"
58
59  action_with_pydeps(target_name) {
60    inputs = [ "//interface/sdk-js/api" ]
61    outputs = [ root_out_dir + "/ohos_declaration/$target_name" ]
62
63    # 处理api文件下全部文件,过滤特定文件
64    script = "//interface/sdk-js/remove_internal.py"
65
66    # fullSDK中api路径
67    input_api_dir = "//interface/sdk-js/api"
68    if (sdk_build_public || product_name == "ohos-sdk") {
69      script = "//out/sdk-public/public_interface/sdk-js/remove_internal.py"
70
71      # publicSDK中api路径,经过./build-tools/delete_systemapi_plugin.js脚本处理过systemapi的接口
72      input_api_dir = "//out/sdk-public/public_interface/sdk-js/api"
73    }
74    args = [
75      "--input",
76      rebase_path(input_api_dir, root_build_dir),
77      "--output",
78      rebase_path(root_out_dir + "/ohos_declaration/$target_name/",
79                  root_build_dir),
80    ]
81    if (defined(deps)) {
82      deps += [ ":$_module_info_target" ]
83    } else {
84      deps = [ ":$_module_info_target" ]
85    }
86  }
87  _target_name = target_name
88  generate_module_info(_module_info_target) {
89    module_type = "jsdoc"
90    module_install_name = ""
91    module_name = _target_name
92    module_source_dir = root_out_dir + "/ohos_declaration/$_target_name"
93    install_enable = false
94  }
95}
96
97# ets/api执行脚本
98ohos_declaration_template("ohos_declaration_ets") {
99}
100
101# ets/api执行脚本
102ohos_copy("common_api") {
103  sources = common_api_src
104  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
105  module_source_dir = target_out_dir + "/$target_name"
106  module_install_name = ""
107}
108
109# ets/api/@internal/full执行脚本
110ohos_copy_internal("ets_internal_api") {
111  iv_input = "//interface/sdk-js/api/@internal/ets"
112}
113
114# ets/arkts执行脚本
115ohos_copy("bundle_arkts") {
116  sources = [ "//interface/sdk-js/arkts" ]
117  outputs = [ target_out_dir + "/$target_name" ]
118  module_source_dir = target_out_dir + "/$target_name"
119  module_install_name = ""
120  license_file = "./LICENCE.md"
121}
122
123if (!sdk_build_public) {
124  # ets/build-tools/ets-loader/declarations脚本
125  ohos_copy("bundle_api") {
126    sources = [ "api/bundle/bundleStatusCallback.d.ts" ]
127    outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
128    module_source_dir = target_out_dir + "/$target_name"
129    module_install_name = ""
130  }
131}
132
133# ets/component执行脚本
134ohos_copy_internal("ets_component") {
135  iv_input = "//interface/sdk-js/api/@internal/component/ets"
136}
137
138# ets/kits执行脚本
139ohos_copy("bundle_kits") {
140  if (sdk_build_public || product_name == "ohos-sdk") {
141    sources = [ "//out/sdk-public/public_interface/sdk-js/kits" ]
142  } else {
143    sources = [ "//interface/sdk-js/kits" ]
144  }
145  outputs = [ target_out_dir + "/$target_name" ]
146  module_source_dir = target_out_dir + "/$target_name"
147  module_install_name = ""
148}
149
150# js/api执行脚本
151ohos_declaration_template("ohos_declaration_common") {
152}
153
154# js/api/@internal/full执行脚本
155ohos_copy_internal("internal_full") {
156  iv_input = "//interface/sdk-js/api/common/full"
157}
158
159# js/api/@internal/lite执行脚本呢
160ohos_copy_internal("internal_lite") {
161  iv_input = "//interface/sdk-js/api/common/lite"
162}
163
164# js/api/config执行脚本
165ohos_copy("config") {
166  sources = [
167    "api/config/css",
168    "api/config/hml",
169  ]
170  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
171  module_source_dir = target_out_dir + "/$target_name"
172  module_install_name = ""
173}
174
175# js/form执行脚本
176ohos_copy("form_declaration") {
177  sources = [
178    "api/form/action",
179    "api/form/css",
180    "api/form/hml",
181  ]
182  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
183  module_source_dir = target_out_dir + "/$target_name"
184  module_install_name = ""
185}
186
187# toolchains/syscapcheck执行脚本
188ohos_copy("syscap_check") {
189  sources = [ "api/syscapCheck/sysCapSchema.json" ]
190  outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
191  module_source_dir = target_out_dir + "/$target_name"
192  module_install_name = ""
193}
194