From 2f837e4166b2f2e99f7c1983a48875c671d12f57 Mon Sep 17 00:00:00 2001 From: wangcaoyu Date: Tue, 17 Jun 2025 21:20:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9interface=5Fsdk=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E4=BA=A7=E7=89=A9=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangcaoyu --- BUILD.gn | 58 ++++++++++++++++++++--------------------- process_internal.py | 7 ++++- process_internal.pydeps | 3 +++ 3 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 process_internal.pydeps diff --git a/BUILD.gn b/BUILD.gn index 0b89c4eb31..6fc0f303ab 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -21,18 +21,10 @@ import("interface_config.gni") # 全局变量方法见 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 # 特殊场景没有拷贝interface接口信息,强基之后源码仓api不能直接使用,需要进行处理 -exists_path_tools = "//interface/sdk-js/exists_path.py" -exists_path_args = [ - "--path", - rebase_path(interface_sdk_path_ets1, root_build_dir), -] -has_interface_file = - exec_script(exists_path_tools, exists_path_args, "trim string") - -if (has_interface_file != "True") { - arkts_sdk_config_parser = "//build/ohos/sdk/parse_interface_sdk.py" +action("ohos_base_split") { + script = "//build/ohos/sdk/parse_interface_sdk.py" ohos_sdk_arkts_description_file = - "//out/sdk-interface/ohos_sdk_pub_description_std.json" + "${interface_sdk_path}/ohos_sdk_pub_description_std.json" if (host_os == "mac") { node_path = "//prebuilts/build-tools/common/nodejs/node-v16.20.2-darwin-x64/bin/node" npm_path = @@ -43,7 +35,7 @@ if (has_interface_file != "True") { npm_path = "//prebuilts/build-tools/common/nodejs/node-v16.20.2-linux-x64/bin/npm" } - arkts_sdk_args = [ + args = [ "--sdk-description-file", rebase_path("//build/ohos/sdk/ohos_sdk_description_std.json", root_build_dir), @@ -59,13 +51,16 @@ if (has_interface_file != "True") { "${sdk_build_arkts}", "--npm-path", rebase_path(npm_path, root_build_dir), + "--output-interface-sdk", + rebase_path(interface_sdk_path, root_build_dir), ] - exec_script(arkts_sdk_config_parser, arkts_sdk_args) + outputs = [ "${root_out_dir}/sdk-interface" ] } template("ohos_copy_internal") { forward_variables_from(invoker, "*") iv_input = invoker.iv_input + _module_info_target = "${target_name}_info" # fullSDK中api路径 input_project_dir = interface_sdk_path_ets1 @@ -75,14 +70,18 @@ template("ohos_copy_internal") { # 调用build/templates/common/copy.gni中的ohos_copy方法 # 将处理完成的文件输出到中间产物对应位置 out/sdk/obj/interface/sdk-js/${target_name} - ohos_copy(target_name) { + action_with_pydeps(target_name) { # 该脚本根据传入的remove文件进行input文件规则检查,过滤不需要的文件 # remove文件没有对应$target_name的属性 则全部输出 # remove文件有对应$target_name的属性 保留base中的文件; # 删除global_remove中的文件; # ispublic为真,删除sdk_build_public_remove文件。 - process_script = "//interface/sdk-js/process_internal.py" - process_arguments = [ + deps = [ ":ohos_base_split" ] + deps += [ ":$_module_info_target" ] + inputs = [] + outputs = [ target_out_dir + "/${sdk_type}/${target_name}" ] + script = "//interface/sdk-js/process_internal.py" + args = [ "--input", rebase_path(iv_input, root_build_dir), "--project-dir", @@ -95,14 +94,18 @@ template("ohos_copy_internal") { "${sdk_build_public}", "--name", "${target_name}", + "--output", + rebase_path(target_out_dir + "/${sdk_type}/${target_name}", + root_build_dir), ] - - # 执行脚本 - sources = exec_script(process_script, process_arguments, "value") - outputs = - [ target_out_dir + "/${sdk_type}/${target_name}/{{source_file_part}}" ] - module_source_dir = target_out_dir + "/${sdk_type}/${target_name}" + } + _target_name = target_name + generate_module_info(_module_info_target) { + module_type = "jsdoc" module_install_name = "" + module_name = _target_name + module_source_dir = target_out_dir + "/${sdk_type}/${_target_name}" + install_enable = false } } @@ -119,7 +122,9 @@ template("ohos_declaration_template") { input_api_dir = input_project_dir + "/api" action_with_pydeps(target_name) { - inputs = [ input_project_dir + "/api" ] + deps = [ ":ohos_base_split" ] + deps += [ ":$_module_info_target" ] + inputs = [] outputs = [ root_out_dir + "/ohos_declaration/${sdk_type}/${target_name}" ] # 处理api文件下全部文件,过滤特定文件 @@ -132,11 +137,6 @@ template("ohos_declaration_template") { root_out_dir + "/ohos_declaration/${sdk_type}/${target_name}/", root_build_dir), ] - if (defined(deps)) { - deps += [ ":$_module_info_target" ] - } else { - deps = [ ":$_module_info_target" ] - } } _target_name = target_name generate_module_info(_module_info_target) { @@ -203,7 +203,7 @@ ohos_copy_internal("ets_component") { # ets1.2/arkui/component执行脚本 ohos_copy_internal("ets_component2") { sdk_type = "ets2" - iv_input = "//out/arkui_transformer_api" + iv_input = interface_sdk_path + "/arkui_transformer_api" } # ets/kits执行脚本 diff --git a/process_internal.py b/process_internal.py index f34172db46..9e172fe7e0 100755 --- a/process_internal.py +++ b/process_internal.py @@ -15,6 +15,7 @@ import os import sys +import shutil import optparse import json @@ -76,6 +77,7 @@ def parse_args(args): parser.add_option('--project-dir', help='current project dir path') parser.add_option('--ispublic', help='whether or not sdk build public') parser.add_option('--name', help='module label name') + parser.add_option('--output', help='output path') options, _ = parser.parse_args(args) options.input = os.path.realpath(options.input) return options @@ -84,8 +86,11 @@ def parse_args(args): def main(argv): '''main函数入口''' options = parse_args(argv) + if not os.path.exists(options.output): + os.makedirs(options.output) result = copy_files(options) - print(json.dumps(result)) + for file_path in result: + shutil.copy(file_path, options.output) return 0 diff --git a/process_internal.pydeps b/process_internal.pydeps new file mode 100644 index 0000000000..f1dd75ee8e --- /dev/null +++ b/process_internal.pydeps @@ -0,0 +1,3 @@ +# Generated by running: +# build/print_python_deps.py --root interface/sdk-js --output interface/sdk-js/process_internal.pydeps interface/sdk-js/process_internal.py +process_internal.py -- Gitee