diff --git a/ohos/common/BUILD.gn b/ohos/common/BUILD.gn index e1608800150c8f6a48f91a7120f054aed41b2c30..1bf2a851e5cdf85c71a82333696e78ec2e19d97f 100755 --- a/ohos/common/BUILD.gn +++ b/ohos/common/BUILD.gn @@ -53,6 +53,18 @@ generated_file("generate_host_info") { output_conversion = "json" } +arm64e_file = "${root_build_dir}/all_arm64e_parts_host.json" + +generated_file("generate_arm64e_info") { + deps = [] + foreach(part_label, parts_list) { + deps += [ get_label_info(part_label, "label_with_toolchain") ] + } + outputs = [ arm64e_file ] + data_keys = [ "arm64e_install_modules" ] + output_conversion = "json" +} + action_with_pydeps("gen_binary_installed_info") { deps = [ ":generate_src_installed_info" ] script = "//build/ohos/common/binary_install_info.py" diff --git a/ohos/generate_part_info.py b/ohos/generate_part_info.py index 067eeb5a9970e06cada8c006fd3c741ef0e56dd9..3fab4ea8f10270039108583d3f537f4f98ce5b59 100755 --- a/ohos/generate_part_info.py +++ b/ohos/generate_part_info.py @@ -83,6 +83,8 @@ def gen_output_file(part_name: str, origin_part_name: str, all_modules_file: str toolchain = install_module.get('toolchain') if toolchain == '' or toolchain == current_toolchain: part_install_modules.append(install_module) + elif toolchain.endswith("ohos_clang_arm64e"): + part_install_modules.append(install_module) else: if toolchain == host_toolchain: part_host_modules.append(install_module) diff --git a/ohos/packages/BUILD.gn b/ohos/packages/BUILD.gn index a4a599b2a03c4c89b2ef0bdef51334143e277d5c..39e2a5e97013ae1d679dec51b427561add2fb09d 100644 --- a/ohos/packages/BUILD.gn +++ b/ohos/packages/BUILD.gn @@ -271,6 +271,7 @@ foreach(_platform, target_platform_list) { system_install_modules = "${current_platform_dir}/system_install_modules.json" system_module_info_list = "${current_platform_dir}/system_module_info.json" + system_pac_only_modules_info = "${current_platform_dir}/system_pac_only_module_info.json" system_modules_list = "${current_platform_dir}/system_modules_list.txt" _system_image_zipfile = "${current_platform_dir}/system.zip" _host_toolchain = "$host_toolchain" @@ -295,6 +296,7 @@ foreach(_platform, target_platform_list) { outputs = [ system_install_modules, system_module_info_list, + system_pac_only_modules_info, system_modules_list, _system_image_zipfile, ] @@ -306,6 +308,10 @@ foreach(_platform, target_platform_list) { rebase_path(system_install_modules, root_build_dir), "--modules-info-file", rebase_path(system_module_info_list, root_build_dir), + "--pac-only-modules-info-file", + rebase_path(system_pac_only_modules_info, root_build_dir), + "--pac-only-whitelist-file", + rebase_path("//build/system_pac_only_whitelist.json", root_build_dir), "--modules-list-file", rebase_path(system_modules_list, root_build_dir), "--platform-installed-path", diff --git a/ohos/packages/modules_install.py b/ohos/packages/modules_install.py index dc6708863982f833f61c33f328a14f0769ec2edc..5afb39f7a2f0b01ac5f2cf8f2a59f940d49ae684 100755 --- a/ohos/packages/modules_install.py +++ b/ohos/packages/modules_install.py @@ -66,10 +66,11 @@ def _get_post_process_modules_info(post_process_modules_info_files: list, depfil def copy_modules(system_install_info: dict, install_modules_info_file: str, - modules_info_file: str, module_list_file: str, - post_process_modules_info_files: list, platform_installed_path: str, + modules_info_file: str, module_list_file: str, pac_only_modules_info_file: str, + pac_only_whitelist_file: str, post_process_modules_info_files: list, platform_installed_path: str, host_toolchain, additional_system_files: dict, depfiles: list, categorized_libraries: dict): output_result = [] + pac_only_output_result = [] dest_list = [] symlink_dest = [] @@ -82,7 +83,13 @@ def copy_modules(system_install_info: dict, install_modules_info_file: str, if not install: continue update_module_info(module_info, categorized_libraries) - output_result.append(module_info) + pac_only_whitelist = read_json_file(pac_only_whitelist_file) + if "ohos_clang_arm64e" in module_info.get("label") and pac_only_whitelist: + for label in pac_only_whitelist: + if label in module_info.get('label'): + pac_only_output_result.append(module_info) + else: + output_result.append(module_info) # get post process modules info post_process_modules = _get_post_process_modules_info( @@ -95,9 +102,11 @@ def copy_modules(system_install_info: dict, install_modules_info_file: str, for source, system_path in additional_system_files: shutil.copy(source, os.path.join(platform_installed_path, system_path)) + + all_target_result = output_result + pac_only_output_result # copy modules - for module_info in output_result: + for module_info in all_target_result: if module_info.get('type') == 'none': continue # copy module lib @@ -196,12 +205,18 @@ def copy_modules(system_install_info: dict, install_modules_info_file: str, # output module list to file write_file(module_list_file, '\n'.join(dest_list)) + # write pac only module info file + if pac_only_output_result: + write_json_file(pac_only_modules_info_file, pac_only_output_result) + def main(): parser = argparse.ArgumentParser() parser.add_argument('--system-install-info-file', required=True) parser.add_argument('--install-modules-info-file', required=True) parser.add_argument('--modules-info-file', required=True) + parser.add_argument('--pac-only-modules-info-file', required=True) + parser.add_argument('--pac-only-whitelist-file', required=True) parser.add_argument('--modules-list-file', required=True) parser.add_argument('--platform-installed-path', required=True) parser.add_argument('--system-dir', required=True) @@ -298,10 +313,17 @@ def main(): shutil.rmtree(cloud_rom_install_base_dir) print('remove cloud_rom dir...') + arm64e_install_base_dir = os.path.join(args.platform_installed_path, + 'system_pac_only') + if os.path.exists(arm64e_install_base_dir): + shutil.rmtree(arm64e_install_base_dir) + print('remove system_pac_only dir...') + print('copy modules...') categorized_libraries = load_categorized_libraries(args.categorized_libraries) copy_modules(system_install_info, args.install_modules_info_file, args.modules_info_file, args.modules_list_file, + args.pac_only_modules_info_file, args.pac_only_whitelist_file, args.post_process_modules_info_files, args.platform_installed_path, args.host_toolchain, additional_system_files, depfiles, categorized_libraries) diff --git a/ohos_var.gni b/ohos_var.gni index 1397afc71b02bc9402135b84d990bf0c1dee82b2..fde0ecec404d49e23c588492822c2b807d905e9f 100755 --- a/ohos_var.gni +++ b/ohos_var.gni @@ -86,6 +86,9 @@ declare_args() { chipset_sdk_sp_dir = "chipset-sdk-sp" + # arm64e toolchain + arm64e_toolchain = "//build/toolchain/ohos:ohos_clang_arm64e" + # check sdk interface sdk_interface_check = true diff --git a/system_pac_only_whitelist.json b/system_pac_only_whitelist.json new file mode 100644 index 0000000000000000000000000000000000000000..1610ea14b3a2142f7d430b798050f49a9f2c7e41 --- /dev/null +++ b/system_pac_only_whitelist.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/templates/cxx/cxx.gni b/templates/cxx/cxx.gni index 3ea6c2f91b17c5af73d1a4ecf4dc767c49ecd3dc..66c06e9650b6991dd8cafb2d89c60d4f22cba41d 100644 --- a/templates/cxx/cxx.gni +++ b/templates/cxx/cxx.gni @@ -595,6 +595,11 @@ template("ohos_shared_library") { assert(subsystem_name != "") assert(part_name != "") + support_arm64e = false + if (defined(invoker.support_arm64e) && invoker.support_arm64e) { + support_arm64e = true + } + module_label = get_label_info(":${target_name}", "label_with_toolchain") _collect_target = "${target_name}__collect" collect_module_target(_collect_target) { @@ -828,6 +833,11 @@ template("ohos_shared_library") { module_install_images += invoker.install_images } + if (support_arm64e && current_toolchain == "$arm64e_toolchain") { + module_install_images = [] + module_install_images = [ "system_pac_only" ] + } + module_output_extension = shlib_extension if (defined(invoker.output_extension)) { module_output_extension = "." + invoker.output_extension @@ -985,7 +995,14 @@ template("ohos_shared_library") { "stack_protector_ret", "branch_protector_ret", "branch_protector_frt", + "support_arm64e", ]) + if (support_arm64e && current_toolchain == "//build/toolchain/ohos:ohos_clang_arm64") { + if (!defined(data_deps)) { + data_deps = [] + } + data_deps += [ ":${target_name}($arm64e_toolchain)" ] + } output_dir = output_dir if (!defined(inputs)) { @@ -1304,8 +1321,24 @@ template("ohos_shared_library") { toolchain = current_toolchain toolchain_out_dir = rebase_path(root_out_dir, root_build_dir) } + generate_arm64e_info = [] + if (support_arm64e && current_toolchain == "//build/toolchain/ohos:ohos_clang_arm64") { + arm64e_install_module_info = { + module_def = target_label + module_info_file = + rebase_path(get_label_info(module_def, "target_out_dir"), + root_build_dir) + "/${target_name}_module_info.json" + subsystem_name = subsystem_name + part_name = part_name + toolchain = current_toolchain + toolchain_out_dir = rebase_path(root_out_dir, root_build_dir) + } + generate_arm64e_info = [ arm64e_install_module_info ] + } + metadata = { install_modules = [ install_module_info ] + arm64e_install_modules = generate_arm64e_info } if (defined(is_debug) && !is_debug && enable_debug_components != "") { foreach(component_name, debug_components) { @@ -1428,6 +1461,11 @@ template("ohos_static_library") { assert(subsystem_name != "") assert(part_name != "") + support_arm64e = false + if (defined(invoker.support_arm64e) && invoker.support_arm64e) { + support_arm64e = true + } + if (is_use_check_deps && !_test_target) { _check_target = "${target_name}__check" target_path = get_label_info(":${target_name}", "label_no_toolchain") @@ -1526,7 +1564,15 @@ template("ohos_static_library") { "stack_protector_ret", "branch_protector_ret", "branch_protector_frt", + "support_arm64e", ]) + + if (support_arm64e && current_toolchain == "$arm64e_toolchain") { + if (!defined(data_deps)) { + data_deps = [] + } + data_deps += [ ":${target_name}($arm64e_toolchain)" ] + } if (defined(invoker.configs)) { configs += invoker.configs } diff --git a/templates/cxx/prebuilt.gni b/templates/cxx/prebuilt.gni index 60c2b2ad6725e1e1f2f6bde2dd0091bcba5243bf..d14831fc5fd8ae47e8de1a190a2521c538e15c8f 100644 --- a/templates/cxx/prebuilt.gni +++ b/templates/cxx/prebuilt.gni @@ -16,10 +16,29 @@ import("//build/templates/common/copy.gni") template("ohos_prebuilt_executable") { assert(defined(invoker.source), "source must be defined for ${target_name}.") + source = invoker.source + support_arm64e = (defined(invoker.support_arm64e) && invoker.support_arm64e) + if (defined(invoker.output)) { _copy_output = "${target_out_dir}/${invoker.output}" } else { - _copy_output = "${target_out_dir}/${invoker.source}" + if (support_arm64e && current_toolchain == "${arm64e_toolchain}") { + source_parts = string_split(invoker.source, "/") + length = 0 + foreach(i, source_parts) { + length += 1 + } + file_name = source_parts[length - 1] + source = string_replace(invoker.source, file_name, "arm64e/$file_name") + _copy_output = "${target_out_dir}/${source}" + + if (defined(invoker.install_images)) { + invoker.install_images = [] + invoker.install_images = [ "system_pac_only" ] + } + } else { + _copy_output = "${target_out_dir}/${invoker.source}" + } } if (!defined(invoker.deps)) { @@ -79,7 +98,7 @@ template("ohos_prebuilt_executable") { "license_file", "license_as_sources", ]) - sources = [ invoker.source ] + sources = [ source ] outputs = [ _copy_output ] module_type = "bin" prebuilt = true @@ -91,16 +110,40 @@ template("ohos_prebuilt_executable") { if (defined(invoker.install_enable)) { install_enable = invoker.install_enable } + + if (support_arm64e && current_toolchain == "//build/toolchain/ohos:ohos_clang_arm64") { + if (!defined(deps)) { + deps = [] + } + deps += [ ":${target_name}($arm64e_toolchain)" ] + } } } template("ohos_prebuilt_shared_library") { assert(defined(invoker.source), "source must be defined for ${target_name}.") + source = invoker.source + support_arm64e = (defined(invoker.support_arm64e) && invoker.support_arm64e) + if (current_toolchain == "${arm64e_toolchain}" && support_arm64e) { + source_parts = string_split(invoker.source, "/") + length = 0 + foreach(i, source_parts) { + length += 1 + } + file_name = source_parts[length - 1] + source = string_replace(invoker.source, file_name, "arm64e/$file_name") + + if (defined(invoker.install_images)) { + invoker.install_images = [] + invoker.install_images = [ "system_pac_only" ] + } + } + if (defined(invoker.output)) { _copy_output = "${target_out_dir}/${invoker.output}" } else { - _copy_output = "${target_out_dir}/${invoker.source}" + _copy_output = "${target_out_dir}/${source}" } config("${target_name}__config") { libs = [ _copy_output ] @@ -248,7 +291,7 @@ template("ohos_prebuilt_shared_library") { prebuilt = true stable = invoker.stable toolchain = get_label_info(":${target_name}", "toolchain") - source_path = rebase_path(invoker.source, root_build_dir) + source_path = rebase_path(source, root_build_dir) output_path = rebase_path(_copy_output, root_build_dir) } write_file("${target_out_dir}/${target_name}_deps_data.json", @@ -279,7 +322,7 @@ template("ohos_prebuilt_shared_library") { "license_file", "license_as_sources", ]) - sources = [ invoker.source ] + sources = [ source ] outputs = [ _copy_output ] module_type = "lib" prebuilt = true @@ -317,16 +360,35 @@ template("ohos_prebuilt_shared_library") { public_configs = [] } public_configs += [ ":${target_name}__config" ] + if (support_arm64e && current_toolchain == "//build/toolchain/ohos:ohos_clang_arm64") { + if (!defined(deps)) { + deps = [] + } + deps += [ ":${target_name}($arm64e_toolchain)" ] + } } } template("ohos_prebuilt_static_library") { assert(defined(invoker.source), "source must be defined for ${target_name}.") + source = invoker.source + support_arm64e = (defined(invoker.support_arm64e) && invoker.support_arm64e) if (defined(invoker.output)) { _copy_output = "${target_out_dir}/${invoker.output}" } else { - _copy_output = "${target_out_dir}/${invoker.source}" + if (support_arm64e && current_toolchain == "${arm64e_toolchain}") { + source_parts = string_split(invoker.source, "/") + length = 0 + foreach(i, source_parts) { + length += 1 + } + file_name = source_parts[length - 1] + source = string_replace(invoker.source, file_name, "arm64e/$file_name") + _copy_output = "${target_out_dir}/${source}" + } else { + _copy_output = "${target_out_dir}/${invoker.source}" + } } config("${target_name}__config") { libs = [ _copy_output ] @@ -349,13 +411,19 @@ template("ohos_prebuilt_static_library") { "license_file", "license_as_sources", ]) - sources = [ invoker.source ] + sources = [ source ] outputs = [ _copy_output ] bypass_module_info_generation = true if (!defined(public_configs)) { public_configs = [] } public_configs += [ ":${target_name}__config" ] + if (support_arm64e && current_toolchain == "//build/toolchain/ohos:ohos_clang_arm64") { + if (!defined(deps)) { + deps = [] + } + deps += [ ":${target_name}($arm64e_toolchain)" ] + } } } diff --git a/templates/metadata/gen_module_info.py b/templates/metadata/gen_module_info.py index 063a82b588fcc8cdcfb9447cb286de9ea3df5f6e..ffd8eeec8ac0cc1bed1570108cff3d752b34fb8f 100755 --- a/templates/metadata/gen_module_info.py +++ b/templates/metadata/gen_module_info.py @@ -99,6 +99,9 @@ def gen_install_dests(system_base_dir, ramdisk_base_dir, vendor_base_dir, update elif image == 'cloud_rom': dest = _gen_install_dest(cloud_rom_base_dir, module_install_dir, relative_install_dir, module_type) + elif image == 'system_pac_only': + dest = _gen_install_dest("system_pac_only", module_install_dir, + relative_install_dir, module_type) dests.append(os.path.join(dest, source_file_name)) return dests diff --git a/toolchain/ohos/BUILD.gn b/toolchain/ohos/BUILD.gn index 2d33c4775d6582e31e4194f833095332d6dc2b5d..5cb22f7210ad83c090ddd9e8e82527ca361f09a6 100755 --- a/toolchain/ohos/BUILD.gn +++ b/toolchain/ohos/BUILD.gn @@ -22,6 +22,15 @@ ohos_clang_toolchain("ohos_clang_arm64") { } } +ohos_clang_toolchain("ohos_clang_arm64e") { + sysroot = "${musl_sysroot}" + lib_dir = "usr/lib/aarch64-linux-ohos" + rust_abi_target = "aarch64-unknown-linux-ohos" + toolchain_args = { + current_cpu = "arm64" + } +} + ohos_clang_toolchain("ohos_clang_x86_64") { sysroot = "${musl_sysroot}" lib_dir = "usr/lib/x86_64-linux-ohos"