diff --git a/cangjie/cj_compiler.gni b/cangjie/cj_compiler.gni new file mode 100644 index 0000000000000000000000000000000000000000..53c514e0a60da2fac0e934a41ef992d3c7725af6 --- /dev/null +++ b/cangjie/cj_compiler.gni @@ -0,0 +1,288 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("cjc_toolchain.gni") +import("//build/config/ohos/musl.gni") + +declare_args() { + # Enable cjc Source-based Code Coverage. + use_cjc_coverage = false +} + +template("_cj_target") { + forward_variables_from(invoker, + [ + "cjc_args", + "cj_deps", + "cj_external_deps", + "sources", + "part_name", + "subsystem_name", + "enable_reflect", + ]) + if (!defined(invoker.output_type)) { + assert(false && "output_type is required") + } + + if (!defined(sources)) { + assert(false && "'sources' is required") + } + + output_type = invoker.output_type + if (output_type != "test" && output_type != "macro" && + output_type != "dylib" && output_type != "staticlib" && + output_type != "exe") { + assert(false && + "output_type must be one of [test, macro, dylib, staticlib, exe]") + } + + is_cj_test_ = output_type == "test" + if (!defined(cjc_args)) { + cjc_args = [] + } + + cjc_args_ = [] + if (output_type == "dylib") { + cjc_args_ += [ + "--dy-std", + "--dy-libs", + ] + } + if (!defined(enable_reflect) || enable_reflect == "false") { + cjc_args_ += [ "--disable-reflection" ] + } + + sources_ = sources + sources = [] + foreach(src, sources_) { + cjc_args_ += [ rebase_path(src) ] + } + + # coverage support + if (use_cjc_coverage) { + cjc_args_ += [ + "-O0", + "--coverage", + ] + } else { + trimpath = rebase_path(get_path_info(sources_[0], "dir")) + cjc_args_ += [ + "--trimpath", + trimpath, + ] + + cjc_args_ += [ "-O2" ] + + if (use_clang_coverage) { + cjc_args_ += [ "-lclang_rt.profile" ] + } + } + + outname_ = target_name + base_outdir = "${root_out_dir}/cangjie_libraries" + base_outdir_abs = rebase_path(base_outdir) + + outdir = base_outdir + if (outname_ != "ohos") { + module_name = string_split(outname_, ".") + outdir = "${base_outdir}/${module_name[0]}" + } + outdir_abs = rebase_path(outdir) + + is_library = false + if (output_type == "macro") { + cjc_args_ += [ "--compile-macro" ] + outfile_name = + "lib-macro_${outname_}${cjc_toolchain.dyn_extension}" + cjc_args_ += [ + "--output-dir", + outdir_abs, + ] + is_library = true + } else if (output_type == "test") { + cjc_args_ += [ "--test" ] + outfile_name = "${outname_}${cjc_toolchain.exe_extension}" + cjc_args_ += [ + "-o", + "${outdir_abs}/${outfile_name}", + ] + } else { + cjc_args_ += [ "--output-type=${output_type}" ] + if (output_type == "dylib") { + is_library = true + outfile_name = + "lib${outname_}${cjc_toolchain.dyn_extension}" + } else if (output_type == "staticlib") { + is_library = true + outfile_name = + "lib${outname_}${cjc_toolchain.static_extension}" + } else if (output_type == "exe") { + outfile_name = "${outname_}${cjc_toolchain.exe_extension}" + } + cjc_args_ += [ + "-o", + "${outdir_abs}/${outfile_name}", + ] + } + + outputs_ = [ "${outdir}/${outfile_name}" ] + if (is_library) { + outputs_ += [ "${outdir}/${outname_}.cjo" ] + } + + cjc_args_ += [ "--target=${cjc_toolchain.target_platform}" ] + if (defined(cjc_toolchain.cjc_args)) { + cjc_args_ += cjc_toolchain.cjc_args + } + deps_ = [] + external_deps_ = [] + if (defined(invoker.deps)) { + deps_ += invoker.deps + } + + if (!defined(cj_deps)) { + cj_deps = [] + } + + if (!defined(cj_external_deps)) { + cj_external_deps = [] + } + + # external_deps support + if (defined(invoker.external_deps)) { + external_deps_ += invoker.external_deps + } + + cjc_args_ += cjc_args + + save_config = { + outname = outname_ + output_type = output_type + outfile = "${outdir_abs}/${outfile_name}" + import_path = base_outdir_abs + args = cjc_args_ + native_deps = [] + foreach(dep, deps_) { + t_name = get_label_info(dep, "name") + t_out_dir = get_label_info(dep, "target_out_dir") + t_config = rebase_path("${t_out_dir}/${t_name}_module_info.json") + native_deps += [ t_config ] + } + if (external_deps_ != []) { + external_deps = external_deps_ + } + cjc_deps = [] + foreach(dep, cj_deps) { + t_name = get_label_info(dep, "name") + t_out_dir = get_label_info(dep, "target_out_dir") + t_config = rebase_path("${t_out_dir}/${t_name}_cjc_config.json") + cjc_deps += [ t_config ] + } + + foreach(dep, cj_external_deps) { + t_name = get_label_info(dep, "name") + t_out_dir = get_label_info(dep, "target_out_dir") + t_config = rebase_path("${t_out_dir}/${t_name}_cjc_config.json") + cjc_deps += [ t_config ] + } + } + + config_path = "${target_out_dir}/${target_name}_cjc_config.json" + config_path_abs = rebase_path(config_path) + write_file(config_path, save_config, "json") + + compile_target_name = "compile_cj_target_${target_name}" + + action(compile_target_name) { + sources = sources_ + script = cjc_wrapper + root_dir_abs = rebase_path(root_build_dir) + args = [ + "--config=${config_path_abs}", + "--cjc=${cjc_bin}", + "--root_out_dir=${root_dir_abs}", + ] + if (is_mac) { + args += [ "--is_mac=true" ] + } + outputs = outputs_ + deps = deps_ + external_deps = external_deps_ + deps += cj_deps + external_deps += cj_external_deps + } + + ohos_copy(target_name) { + deps = [ ":${compile_target_name}" ] + sources = [ outputs_[0] ] + + if (defined(invoker.part_name)) { + part_name = invoker.part_name + subsystem_name = invoker.subsystem_name + } + + prebuilt = true + install_enable = false + + if (!is_cj_test_) { + if (output_type == "dylib" || output_type == "exe") { + install_enable = true + } + if (output_type == "exe") { + module_type = "exe" + } else { + module_type = "lib" + } + } + + if (is_cj_test_) { + testonly = true + test_out_path = + "${root_out_dir}/tests/unittest/${subsystem_name}/${part_name}" + outputs = [ "${test_out_path}/${outfile_name}" ] + write_file("$test_out_path/${target_name}_path.txt", + get_label_info(":$target_name", "dir"), + "string") + bypass_module_info_generation = true + } else { + outputs = [ "${target_out_dir}/${outfile_name}" ] + } + if (install_enable) { + relative_install_dir = "platformsdk/cjsdk" + innerapi_tags = [ "platformsdk/cjsdk" ] + install_images = [ "system" ] + } + } + + if (is_library) { + ohos_copy("${target_name}_cjo") { + prebuilt = true + deps = [ ":${compile_target_name}" ] + sources = [ outputs_[1] ] + outputs = [ "${target_out_dir}/${outname_}.cjo" ] + } + } +} + +template("cj_target") { + target("_cj_target", target_name) { + forward_variables_from(invoker, "*", [ "no_default_deps" ]) + if (!defined(deps)) { + deps = [] + } + + if (is_ohos) { + deps += [ "//build/config:common_deps" ] + } + } +} \ No newline at end of file diff --git a/cangjie/cjc.gni b/cangjie/cjc.gni new file mode 100644 index 0000000000000000000000000000000000000000..cc0d881733d9ea4d63abcecc93ed27ea052f4ad7 --- /dev/null +++ b/cangjie/cjc.gni @@ -0,0 +1,132 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("cj_compiler.gni") + +template("ohos_cangjie_library") { + if (!defined(invoker.output_type)) { + assert(false && "output_type is required") + } + + cj_target(target_name) { + output_type = invoker.output_type + forward_variables_from(invoker, + [ + "deps", + "cj_deps", + "cj_external_deps", + "external_deps", + "cjc_args", + "part_name", + "subsystem_name", + "sources", + ]) + if (!defined(cjc_args)) { + cjc_args = [] + } + if (defined(invoker.compilation_config)) { + cjc_args += [ "--cfg=${invoker.compilation_config}" ] + } + } +} + +template("ohos_cangjie_shared_library") { + ohos_cangjie_library(target_name) { + output_type = "dylib" + forward_variables_from(invoker, + [ + "deps", + "external_deps", + "part_name", + "subsystem_name", + "cj_deps", + "cj_external_deps", + "sources", + "cjc_args", + "compilation_config" + ]) + + if (!defined(cjc_args)) { + cjc_args = [] + } + if (!(build_ohos_sdk && is_ohos) && !is_asan) { + cjc_args += [ "--link-options=--no-undefined" ] + } + } +} + +template("ohos_cangjie_static_library") { + ohos_cangjie_library(target_name) { + output_type = "staticlib" + forward_variables_from(invoker, + [ + "deps", + "cj_deps", + "cj_external_deps", + "external_deps", + "cjc_args", + "part_name", + "subsystem_name", + "sources", + "compilation_config" + ]) + } +} + +template("ohos_cangjie_macro_library") { + ohos_cangjie_library(target_name) { + output_type = "macro" + forward_variables_from(invoker, + [ + "deps", + "cj_deps", + "cj_external_deps", + "external_deps", + "cjc_args", + "part_name", + "subsystem_name", + "sources", + "compilation_config" + ]) + } +} + +template("ohos_cangjie_unittest") { + cj_target(target_name) { + output_type = "test" + forward_variables_from(invoker, + [ + "deps", + "cj_deps", + "cj_external_deps", + "external_deps", + "cjc_args", + "part_name", + "subsystem_name", + "sources", + ]) + if (!defined(cjc_args)) { + cjc_args = [] + } + + cjc_args += [ + "--dy-std", + "--dy-libs" + ] + + if (defined(invoker.compilation_config)) { + cjc_args += [ "--cfg=${invoker.compilation_config}" ] + } + } +} \ No newline at end of file diff --git a/cangjie/cjc_toolchain.gni b/cangjie/cjc_toolchain.gni new file mode 100644 index 0000000000000000000000000000000000000000..4c1f91f29506419a9a189bd6e78712dc252a0fb7 --- /dev/null +++ b/cangjie/cjc_toolchain.gni @@ -0,0 +1,149 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +if (host_os == "mac") { + if (host_cpu == "arm64") { + cjc_host_arch = "mac-aarch64" + build_tools_arch = "darwin_aarch64" + } else if (host_cpu == "x64") { + cjc_host_arch = "mac-x64" + build_tools_arch = "darwin_x86_64" + } else { + assert(false && "unsupported host ${host_os}-${host_cpu}") + } +} else if (host_os == "linux") { + if (host_cpu == "x64") { + cjc_host_arch = "linux-x64" + build_tools_arch = "linux_x86_64" + } else { + assert(false && "unsupported host ${host_os}-${host_cpu}") + } +} + +cjc_cangjie_sdk_path = "//prebuilts/cangjie_sdk" +cjc_cangjie_compiler_home_path = + "${cjc_cangjie_sdk_path}/${cjc_host_arch}/cangjie" # TODO + +cjc_wrapper = rebase_path("cjc_wrapper.py") +cjc_bin = rebase_path("${cjc_cangjie_compiler_home_path}/bin/cjc") + +cjc_toolchain_ohos_arm64 = { + target_platform = "aarch64-linux-ohos" + dyn_extension = ".so" + static_extension = ".a" + exe_extension = "" +} + +cjc_toolchain_ohos_x86_64 = { + target_platform = "x86_64-linux-ohos" + dyn_extension = ".so" + static_extension = ".a" + exe_extension = "" +} + +cjc_toolchain_mingw_x86_64 = { + target_platform = "x86_64-w64-mingw32" + dyn_extension = ".dll" + static_extension = ".a" + exe_extension = ".exe" + cjc_args = [ "--link-options=--no-insert-timestamp" ] +} + +cjc_toolchain_linux_x86_64 = { + target_platform = "x86_64-linux-gnu" + dyn_extension = ".so" + static_extension = ".a" + exe_extension = "" + cjc_args = [] +} + +cjc_toolchain_mac_arm64 = { + target_platform = "aarch64-apple-darwin" + dyn_extension = ".dylib" + static_extension = ".a" + exe_extension = "" + cjc_args = [] +} + +cjc_toolchain_mac_x86_64 = { + target_platform = "x86_64-apple-darwin" + dyn_extension = ".dylib" + static_extension = ".a" + exe_extension = "" + cjc_args = [] +} + +if (is_ohos) { + if (current_cpu == "arm64") { + cjc_toolchain = cjc_toolchain_ohos_arm64 + } else if (current_cpu == "x86_64") { + cjc_toolchain = cjc_toolchain_ohos_x86_64 + } else { + print("unsupported ohos platform ${current_cpu}") + assert(false) + } + + clang_abs = rebase_path(default_clang_base_path) + clang_lib_abs = rebase_path(clang_lib_path) + musl_abs = rebase_path("${root_build_dir}/obj/third_party/musl") + musl_lib_abs = "${musl_abs}/usr/lib/${cjc_toolchain.target_platform}" + + cjc_toolchain.cjc_args = [ + "-B", + "${clang_abs}/bin", + "-B", + "${musl_lib_abs}", + "-L", + "${musl_lib_abs}", + "-L", + "${clang_abs}/lib/${cjc_toolchain.target_platform}", + "-L", + "${clang_lib_abs}/${cjc_toolchain.target_platform}", + "--sysroot", + "${musl_lib_abs}", + ] +} else if (is_mingw) { + if (current_cpu == "x86_64") { + cjc_toolchain = cjc_toolchain_mingw_x86_64 + } else { + print("unsupported mingw platform ${current_cpu}") + assert(false) + } +} else if (host_os == "mac") { + if (host_cpu == "x64") { + cjc_toolchain = cjc_toolchain_mac_x86_64 + } else if (host_cpu == "arm64") { + cjc_toolchain = cjc_toolchain_mac_arm64 + } else { + print("unsupported mac platform ${host_cpu}") + assert(false) + } +} else if (is_linux) { + if (host_cpu == "x64") { + cjc_toolchain = cjc_toolchain_linux_x86_64 + } else { + print("unsupported linux platform ${host_cpu}") + assert(false) + } +} else { + assert(false && "unsupported platform") +} + +if (!is_mingw && !is_mac) { + cjc_toolchain.cjc_args += [ + "--link-options=-z now", + "-s", + ] +} diff --git a/cangjie/cjc_wrapper.py b/cangjie/cjc_wrapper.py new file mode 100755 index 0000000000000000000000000000000000000000..c3e264919da6005ff9ed4f29d037d17fefb5340a --- /dev/null +++ b/cangjie/cjc_wrapper.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import json +import os.path +import subprocess +import re + + +def find_mac_sdk_root(): + child = subprocess.Popen(["xcrun", "--sdk", "macosx", "--show-sdk-path"], stdout=subprocess.PIPE) + code = child.wait() + if code != 0: + raise Exception("failed to detect mac sdk root: 'xcrun --sdk macosx --show-sdk-path'") + output = child.stdout.read().decode("utf-8").replace("\n", "") + return output + + +def build_run_cjc_command(cmd_options): + config_file = cmd_options.config + with open(config_file, 'r') as file: + data = json.load(file) + (args, cwd) = build_args(data, cmd_options) + if cmd_options.is_mac: + macenv = os.environ.copy() + macenv["SDKROOT"] = find_mac_sdk_root() + child = subprocess.Popen(args, cwd=cwd, env=macenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + else: + child = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = child.communicate() + if child.returncode != 0: + print(stdout.decode(), stderr.decode()) + raise Exception("failed to run cjc: {}".format(" ".join(args))) + + +def get_all_components(cmd_options): + source_file = "{}/build_configs/parts_info/components.json".format(cmd_options.root_out_dir) + with open(source_file, 'r') as file: + data = json.load(file) + return data + + +def get_external_module_info(depname, part_configs, cmd_options): + part_component = depname.split(":") + part_name = part_component[0] + component_name = part_component[1] + if part_name in part_configs: + labels = part_configs[part_name]["innerapis"] + else: + labels = part_configs["{}_override".format(part_name)]["innerapis"] + target_label = "" + for label_data in labels: + if (component_name == label_data["name"]): + target_label = label_data["label"] + break + if target_label == "": + raise Exception("component :{}/{} not found".format(part_name, component_name)) + path_and_component = target_label.split(":") + pathname = path_and_component[0] + pathname = pathname.replace("//", ""); + target_outdir = "{}/obj/{}/{}_module_info.json".format(cmd_options.root_out_dir, pathname, path_and_component[1]) + return target_outdir + + +def build_args(config, options): + args = [options.cjc] + args += config["args"] + + if "external_deps" in config: + all_parts = get_all_components(options) + for external_dep in config["external_deps"]: + module_info_file = get_external_module_info(external_dep, all_parts, options) + if not os.path.exists(module_info_file): + continue + with open(module_info_file, 'r') as file: + # link c targets by full path, but cj targets are not, because full path targets must define 'SONAME', + # otherwise target so be linked by full path, and won't work once moved. + module_info = json.load(file) + source_file = "{}/{}".format(options.root_out_dir, module_info["source"]) + args.append("--link-options={}".format(source_file)) + + for module_info_file in config["native_deps"]: + if not os.path.exists(module_info_file): + continue + with open(module_info_file, 'r') as file: + # link c targets by full path, but cj targets are not, because full path targets must define 'SONAME', + # otherwise target so be linked by full path, and won't work once moved. + module_info = json.load(file) + source_file = "{}/{}".format(options.root_out_dir, module_info["source"]) + args.append("--link-options={}".format(source_file)) + for cj_config_file in config["cjc_deps"]: + with open(cj_config_file, 'r') as file: + target_config = json.load(file) + outtype = target_config["output_type"] + source_file = target_config["outfile"] + outdir = os.path.dirname(source_file) + outfile = re.sub(r'^lib', "", os.path.basename(source_file)) + outfile = re.sub(r'\.(so|a|dll)$', "", outfile) + args.append("--import-path={}".format(target_config["import_path"])) + if outtype != "macro" and outtype != "test" and outtype != "exe": + args.append("-L{}".format(outdir)) + args.append("-l{}".format(outfile)) + return (args, os.path.dirname(config["outfile"])) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--config", required=True, help="json config for cj target") + parser.add_argument("--cjc", required=True, help="cjc executable path") + parser.add_argument("--root_out_dir", required=True, help="gn root output dir") + parser.add_argument("--is_mac", required=False, type=bool, default=False, help="is build mac target") + options = parser.parse_args() + build_run_cjc_command(options) \ No newline at end of file diff --git a/cangjie/doc/cangjie_template.md b/cangjie/doc/cangjie_template.md new file mode 100644 index 0000000000000000000000000000000000000000..b6f71522a7692be1bdd44e76be5cc148de2b4f7b --- /dev/null +++ b/cangjie/doc/cangjie_template.md @@ -0,0 +1,35 @@ +# 仓颉gn模板介绍 + +## 模板 +仓颉目前常用的三个模板 +```gn +ohos_cangjie_shared_library # 动态库 +ohos_cangjie_static_library # 静态库 +ohos_cangjie_macro_library # 宏 +``` + +## 使用 + +```gn +ohos_cangjie_shared_library("ohos.xxx") { + sources = [ "xxx.cj" ] + + subsystem_name = "xxx" + part_name = "xxx" +} +``` +上面是最简单的cangjie 动态库配置,除sources, subsystem_name, part_name 必选项外,还有cj_deps, cj_external_deps, deps, external_deps,cjc_args等 + +| name | 是否可选 | 描述 | +| --- | --- | --- | +| sources | 必选 | 仓颉源文件 | +| subsystem_name | 必选 | 模块所属子系统名 | +| part_name | 必选 | 模块所属部件名 | +| cj_deps | 可选 | 依赖的本部件的仓颉模块,建议相对路径 | +| cj_external_deps | 可选 | 依赖的其他部件的仓颉模块 | +| deps | 可选 | 依赖的其他部件的非仓颉模块,建议相对路径 | +| external_deps | 可选 | 依赖的其他部件的非仓颉模块 | +| compilation_config | 可选 | 自定义条件宏选项 | +| cjc_args | 可选 | cjc编译选项 | + +注意:compilation_config = "pipeline=NG" 等价于 cjc_args = [ "--cfg=pipeline=NG" ] \ No newline at end of file diff --git a/ohos/sdk/copy_sdk_modules.py b/ohos/sdk/copy_sdk_modules.py index 5e31b0217fbaec24d8f817b3d6d59eccea6f2c11..d03e8468e5320d11f86e252a9f4a900f72893104 100755 --- a/ohos/sdk/copy_sdk_modules.py +++ b/ohos/sdk/copy_sdk_modules.py @@ -35,18 +35,30 @@ def get_source_from_module_info_file(module_info_file: str): return source, notice +def clear_copy_symlinks_dest_dir(copy_infos: dict): + for cp_info in copy_infos: + copy_with_symlinks = cp_info.get("copy_with_symlinks") + if copy_with_symlinks: + dest = cp_info.get('dest') + build_utils.delete_directory(dest) + build_utils.make_directory(dest) + + def do_copy_and_stamp(copy_infos: dict, options, depfile_deps: list): notice_tuples = [] + clear_copy_symlinks_dest_dir(copy_infos) + for cp_info in copy_infos: source = cp_info.get('source') dest = cp_info.get('dest') notice = cp_info.get('notice') install_dir = cp_info.get('install_dir') + copy_with_symlinks = cp_info.get("copy_with_symlinks") if os.path.isdir(source): if os.listdir(source): files = build_utils.get_all_files(source) if files: - shutil.copytree(source, dest, dirs_exist_ok=True) + shutil.copytree(source, dest, symlinks=copy_with_symlinks, dirs_exist_ok=True) depfile_deps.update(build_utils.get_all_files(source)) else: # Skip empty directories. @@ -125,8 +137,9 @@ def main(): os.path.basename(source)) copy_infos.append({'source': source, 'notice': notice, - 'dest': dest, - 'install_dir': item.get('install_dir')}) + 'dest': dest, + 'install_dir': item.get('install_dir'), + 'copy_with_symlinks': item.get('copy_with_symlinks')}) do_copy_and_stamp(copy_infos, options, depfile_deps) diff --git a/ohos/sdk/ohos_sdk_description_std.json b/ohos/sdk/ohos_sdk_description_std.json index 560e3a0a37c29a9bddbfb94350892f7b3f14907c..e6e8447d303f3d4ad9f33e77bc3feb8b11358788 100644 --- a/ohos/sdk/ohos_sdk_description_std.json +++ b/ohos/sdk/ohos_sdk_description_std.json @@ -1,4 +1,31 @@ [ + { + "install_dir": "cangjie/api", + "module_label": "//interface/sdk_cangjie:sdk_api", + "target_os": [ + "linux", + "windows", + "darwin" + ] + }, + { + "install_dir": "cangjie/build-tools", + "copy_with_symlinks": true, + "module_label": "//interface/sdk_cangjie:sdk_compiler", + "target_os": [ + "linux", + "windows", + "darwin" + ] + }, + { + "install_dir": "cangjie/build-tools/modules", + "module_label": "//interface/sdk_cangjie:sdk_compiler_modules", + "target_os": [ + "windows", + "darwin" + ] + }, { "install_dir": "toolchains", "module_label": "//developtools/syscap_codec:syscap_tool_bin", diff --git a/ohos/sdk/parse_sdk_description.py b/ohos/sdk/parse_sdk_description.py index d543f7d2f3639b4e6ad3df1cfe5df95bbc4a63f8..6a983fc6c56e9e9e1d6635740609edd26b00b8f0 100755 --- a/ohos/sdk/parse_sdk_description.py +++ b/ohos/sdk/parse_sdk_description.py @@ -33,7 +33,7 @@ sys.path.insert(1, os.path.join(os.path.abspath( '..', '..', '..')), 'third_party')) from jinja2 import Template # noqa: E402 # pylint: disable=F0401 -KEYS = ['target_os', 'install_dir', 'module_label', 'build_only'] +KEYS = ['target_os', 'install_dir', 'module_label', 'build_only', 'copy_with_symlinks'] class SdkTargets: @@ -188,6 +188,7 @@ def parse_description_file(options): label = d.get('module_label') install_dir = d.get('install_dir') build_only = d.get('build_only') + copy_with_symlinks = d.get('copy_with_symlinks', False) # skip labels that we cannot find. rebased_build_gn = build_utils.rebase_path( @@ -217,7 +218,8 @@ def parse_description_file(options): for label, install_dir in zip(module_labels, install_dirs): install_info = { 'label': label, - 'install_dir': install_dir + 'install_dir': install_dir, + 'copy_with_symlinks': copy_with_symlinks, } module_install_infos.append(install_info) diff --git a/ohos/sdk/sdk_delivery_list.json b/ohos/sdk/sdk_delivery_list.json index e16c0dd995b0f098d5c2dee2aa39754f4c117b0f..553f71798538065ed306ef0da172c082def53d6b 100644 --- a/ohos/sdk/sdk_delivery_list.json +++ b/ohos/sdk/sdk_delivery_list.json @@ -6,7 +6,8 @@ "darwin/js/", "darwin/native/", "darwin/previewer/", - "darwin/toolchains/" + "darwin/toolchains/", + "darwin/cangjie/" ] }, "linux": { @@ -16,7 +17,8 @@ "linux/js/", "linux/native/", "linux/previewer/", - "linux/toolchains/" + "linux/toolchains/", + "linux/cangjie/" ] }, "windows": { @@ -26,7 +28,8 @@ "windows/js/", "windows/native/", "windows/previewer/", - "windows/toolchains/" + "windows/toolchains/", + "windows/cangjie/" ] }, "ohos": { @@ -36,7 +39,8 @@ "ohos/js/", "ohos/native/", "ohos/previewer/", - "ohos/toolchains/" + "ohos/toolchains/", + "ohos/cangjie/" ] } } diff --git a/prebuilts_download_config.json b/prebuilts_download_config.json index deb15fe35bba62231ce70c5dab32aea44a3fc1f1..c885aac2cb2b05c31542a33bc330b6c24bf91c4c 100644 --- a/prebuilts_download_config.json +++ b/prebuilts_download_config.json @@ -491,6 +491,21 @@ "unzip_dir": "prebuilts/rustc", "file_path": "/openharmony/compiler/rust/1.72.0-20250515/rust-std-nightly-x86_64-pc-windows-gnullvm.tar.gz", "unzip_filename": "rustc-x86_64-windows-std" + }, + { + "unzip_dir": "prebuilts/cangjie_sdk/linux-x64", + "file_path": "/openharmony/compiler/cangjie/1.0.0/cangjie-linux-x64-1.0.0.zip", + "unzip_filename": "cangjie-linux-x64" + }, + { + "unzip_dir": "prebuilts/cangjie_sdk/windows-x64", + "file_path": "/openharmony/compiler/cangjie/1.0.0/cangjie-windows-x64-1.0.0.zip", + "unzip_filename": "cangjie-windows-x64" + }, + { + "unzip_dir": "prebuilts/cangjie_sdk/build-tools", + "file_path": "/openharmony/compiler/cangjie/1.0.0/cangjie-api-tools-1.0.0.zip", + "unzip_filename": "build-tools" }, { "unzip_dir": "prebuilts/python_llvm", @@ -638,6 +653,16 @@ "unzip_dir": "prebuilts/taihe/ohos/darwin-arm64", "file_path": "/openharmony/compiler/Taihe/0.34.1/taihe-darwin-arm64-v0.34.1-20250623.tar.gz", "unzip_filename": "taihe" + }, + { + "unzip_dir": "prebuilts/cangjie_sdk/mac-aarch64", + "file_path": "/openharmony/compiler/cangjie/1.0.0/cangjie-mac-aarch64-1.0.0.zip", + "unzip_filename": "cangjie-mac-aarch64" + }, + { + "unzip_dir": "prebuilts/cangjie_sdk/build-tools", + "file_path": "/openharmony/compiler/cangjie/1.0.0/cangjie-api-tools-1.0.0.zip", + "unzip_filename": "build-tools" } ], "install": [ @@ -711,6 +736,16 @@ "unzip_dir": "prebuilts/rustc", "file_path": "/openharmony/compiler/rust/1.72.0-20250515/rust-nightly-x86_64-apple-darwin.tar.gz", "unzip_filename": "rustc" + }, + { + "unzip_dir": "prebuilts/cangjie_sdk/mac-x64", + "file_path": "/openharmony/compiler/cangjie/1.0.0/cangjie-mac-x64-1.0.0.zip", + "unzip_filename": "cangjie-mac-x64" + }, + { + "unzip_dir": "prebuilts/cangjie_sdk/build-tools", + "file_path": "/openharmony/compiler/cangjie/1.0.0/cangjie-api-tools-1.0.0.zip", + "unzip_filename": "build-tools" } ], "install": [