From 147a5a4a86a62fb9ef16af848601549751dcfcdd Mon Sep 17 00:00:00 2001 From: wangmeng Date: Fri, 12 Sep 2025 16:02:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E3=80=81=E5=85=A8=E9=87=8F=E6=BA=90=E7=A0=81=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=BD=92=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb/indep_component_whitelist.json | 626 +++++++++++++++++++++++ hb/main.py | 9 +- hb/resolver/judge_indep_args_resolver.py | 167 ++++++ hb/services/indep_build.py | 16 +- indep_configs/build_indep.sh | 14 + 5 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 hb/indep_component_whitelist.json create mode 100644 hb/resolver/judge_indep_args_resolver.py diff --git a/hb/indep_component_whitelist.json b/hb/indep_component_whitelist.json new file mode 100644 index 0000000000..0c58361e6c --- /dev/null +++ b/hb/indep_component_whitelist.json @@ -0,0 +1,626 @@ +{ + "product-name": ["rk3568"], + "components": [ + "eventhandler", + "device_manager", + "exfatprogs", + "libnl", + "libevdev", + "libsnd", + "video_processing_engine", + "jsvm", + "libffi", + "iptables", + "hilog", + "hicollie", + "hichecker", + "hisysevent", + "memmgr", + "crypto_framework", + "access_token", + "huks", + "device_auth", + "nghttp2", + "cares", + "lzma", + "libfuse", + "libdrm", + "memory_utils", + "config_policy", + "bluetooth", + "selinux", + "selinux_adapter", + "pcre2", + "mbedtls", + "libcoap", + "lz4", + "bzip2", + "libxml2", + "icu", + "jsoncpp", + "libuv", + "cJSON", + "json", + "libunwind", + "e2fsprogs", + "bounds_checking_function", + "toybox", + "ril_adapter", + "zlib", + "syscap_codec", + "qos_manager", + "device_security_level", + "soc_perf", + "ffmpeg", + "libexif", + "init", + "sqlite", + "miscdevice", + "sensor", + "code_signature", + "dataclassification", + "ecological_rule_manager", + "fsverity-utils", + "f2fs-tools", + "libjpeg-turbo", + "idl_tool", + "tzdata", + "os_account", + "curl", + "start", + "dcts", + "certificate_framework", + "vulkan-headers", + "bytrace", + "tee_client", + "dlp_permission_service", + "frame_aware_sched", + "jerryscript", + "vixl", + "unity", + "opengles", + "app_domain_verify", + "cellular_call", + "update_service", + "vulkan-loader", + "c_utils", + "device_standby", + "certificate_manager", + "display_manager", + "distributed_audio", + "distributed_camera", + "storage_service", + "security_guard", + "ui_appearance", + "distributed_input", + "face_auth", + "security_component_manager", + "fingerprint_auth", + "battery_statistics", + "media_foundation", + "distributed_screen", + "ylong_runtime", + "ylong_json", + "pin_auth", + "netmanager_base", + "ffrt", + "audio_framework", + "ability_base", + "graphic_surface", + "power_manager", + "thermal_manager", + "appspawn", + "player_framework", + "battery_manager", + "input", + "napi", + "sms_mms", + "user_auth_framework", + "sandbox_manager", + "appverify", + "dsoftbus", + "distributed_bundle_framework", + "window_manager", + "device_usage_statistics", + "packing_tool", + "resource_schedule_service", + "ability_runtime", + "background_task_mgr", + "oaid", + "advertising", + "work_scheduler", + "bundle_tool", + "form_fwk", + "bundle_framework", + "pasteboard", + "hiprofiler", + "decimal.js", + "typescript", + "toolchain", + "drivers_interface_distributed_camera", + "drivers_interface_fingerprint_auth", + "drivers_interface_distributed_audio", + "device_info_manager", + "distributed_hardware_fwk", + "ace_engine", + "dmsfwk", + "drivers_peripheral_distributed_audio", + "drivers_peripheral_distributed_camera", + "ets_utils", + "av_codec", + "accessibility", + "faultloggerd", + "egl", + "wallpaper_mgr", + "astc-encoder", + "graphics_effect", + "opencl-headers", + "mindspore", + "flatbuffers", + "intelligent_voice_framework", + "drivers_interface_nnrt", + "drivers_peripheral_intelligent_voice", + "drivers_interface_intelligent_voice", + "neural_network_runtime", + "tex-hyphen", + "common_event_service", + "distributed_notification_service", + "app_file_service", + "dfs_service", + "drivers_peripheral_thermal", + "usb_manager", + "time_service", + "drivers_interface_face_auth", + "drivers_interface_pin_auth", + "drivers_interface_user_auth", + "drivers_peripheral_face_auth", + "drivers_peripheral_fingerprint_auth", + "drivers_peripheral_pin_auth", + "drivers_peripheral_user_auth", + "auth_widget", + "imf", + "drivers_interface_audio", + "drivers_interface_codec", + "drivers_interface_display", + "drivers_interface_input", + "drivers_interface_light", + "drivers_interface_motion", + "drivers_interface_sensor", + "drivers_interface_vibrator", + "drivers_peripheral_audio", + "drivers_peripheral_codec", + "drivers_peripheral_display", + "drivers_peripheral_input", + "drivers_peripheral_light", + "drivers_peripheral_motion", + "drivers_peripheral_sensor", + "drivers_peripheral_vibrator", + "hdf_core", + "alsa-lib", + "alsa-utils", + "openmax", + "drivers_interface_camera", + "device_status", + "enterprise_device_management", + "drivers_peripheral_usb", + "css-what", + "external_device_manager", + "hiappevent", + "hiview", + "drivers_interface_huks", + "request", + "openssl", + "asset", + "graphic_2d", + "drivers_peripheral_wlan", + "mtdev", + "libinput", + "samgr", + "safwk", + "user_file_service", + "gptfdisk", + "ntfs-3g", + "drivers_interface_usb", + "drivers_peripheral_battery", + "drivers_peripheral_power", + "drivers_peripheral_camera", + "drivers_interface_wlan", + "data_object", + "kv_store", + "datamgr_service", + "udmf", + "preferences", + "data_share", + "file_api", + "relational_store", + "drivers_interface_thermal", + "drivers_interface_battery", + "drivers_interface_power", + "drivers_interface_partitionslot", + "drivers_peripheral_partitionslot", + "graphic_3d", + "hdc", + "libusb", + "location", + "screenlock_mgr", + "libwebsockets", + "brotli", + "elfio", + "lwip", + "wpa_supplicant", + "global_resource_tool", + "resource_management", + "system_resources", + "noto-cjk", + "notofonts", + "libphonenumber", + "timezone", + "i18n", + "font_manager", + "re2", + "libbpf", + "protobuf", + "abseil-cpp", + "hiperf", + "grpc", + "hitrace", + "hidumper", + "updater", + "sys_installer", + "elfutils", + "packaging_tools", + "libabigail", + "PyYAML", + "lame", + "ringtone_library", + "camera_framework", + "opensles", + "pulseaudio", + "drm_framework", + "drivers_interface_drm", + "drivers_peripheral_clearplay", + "image_framework", + "drivers_peripheral_location_agnss", + "drivers_interface_location_agnss", + "drivers_peripheral_location_gnss", + "drivers_interface_location_gnss", + "drivers_peripheral_location_geofence", + "drivers_interface_location_geofence", + "drivers_interface_act_recg", + "drivers_interface_lpfence", + "dhcp", + "drivers_interface_bluetooth", + "permission_manager", + "dlp_manager", + "media_library", + "av_session", + "user_certificate_manager", + "popt", + "liburing", + "backends", + "drivers_peripheral_huks", + "drivers_peripheral_memorytracker", + "drivers_interface_memorytracker", + "webview", + "wifi", + "image_effect", + "netstack", + "netmanager_ext", + "node", + "harfbuzz", + "rust_libc", + "vk-gl-cts", + "spirv-tools", + "freetype", + "ipc", + "telephony_data", + "print_fwk", + "cups", + "cups-filters", + "libpng", + "qrcodegen", + "cast_engine", + "calendar_data", + "skia", + "settings", + "drivers_peripheral_ril", + "drivers_interface_ril", + "bluetooth_service", + "drivers_peripheral_bluetooth", + "ylong_http", + "core_service", + "cellular_data", + "call_manager", + "state_registry", + "contacts_data", + "sharing_framework", + "ets_runtime", + "ets_frontend", + "runtime_ocre", + "third_party_exfatprogs", + "third_party_libnl", + "third_party_libevdev", + "third_party_libsnd", + "third_party_libffi", + "third_party_nghttp2", + "third_party_cares", + "third_party_lzma", + "third_party_libfuse", + "third_party_selinux", + "third_party_pcre2", + "third_party_mbedtls", + "third_party_lz4", + "third_party_libcoap", + "third_party_icu", + "third_party_libuv", + "third_party_json", + "third_party_iptables", + "third_party_toybox", + "multimedia_video_processing_engine", + "third_party_sqlite", + "third_party_bounds_checking_function", + "tee_tee_client", + "sensors_start", + "third_party_libunwind", + "third_party_jsoncpp", + "third_party_libxml2", + "third_party_bzip2", + "third_party_vulkan-loader", + "third_party_zlib", + "third_party_vulkan-headers", + "third_party_unity", + "third_party_opengles", + "third_party_vixl", + "third_party_ffmpeg", + "third_party_libexif", + "third_party_cJSON", + "third_party_libdrm", + "commonlibrary_rust_ylong_json", + "third_party_curl", + "developtools_syscap_codec", + "hiviewdfx_hichecker", + "bundlemanager_ecological_rule_manager", + "arkui_ui_appearance", + "update_update_service", + "linux_frame_aware_sched", + "developtools_bytrace", + "resourceschedule_ffrt", + "commonlibrary_memory_utils", + "customization_config_policy", + "security_selinux_adapter", + "security_certificate_framework", + "security_device_security_level", + "security_dataclassification", + "distributedhardware_distributed_camera", + "third_party_e2fsprogs", + "third_party_fsverity-utils", + "third_party_f2fs-tools", + "third_party_libjpeg-turbo", + "third_party_tzdata", + "third_party_jerryscript", + "telephony_ril_adapter", + "security_appverify", + "ability_idl_tool", + "bundlemanager_app_domain_verify", + "ability_ability_base", + "bundlemanager_distributed_bundle_framework", + "developtools_packing_tool", + "advertising_ads_framework", + "commonlibrary_rust_ylong_runtime", + "advertising_oaid", + "resourceschedule_resource_schedule_service", + "resourceschedule_device_usage_statistics", + "resourceschedule_background_task_mgr", + "resourceschedule_work_scheduler", + "bundlemanager_bundle_tool", + "ability_form_fwk", + "ability_ability_runtime", + "bundlemanager_bundle_framework", + "distributeddatamgr_pasteboard", + "developtools_profiler", + "commonlibrary_c_utils", + "third_party_decimal.js", + "third_party_typescript", + "communication_dsoftbus", + "arkcompiler_toolchain", + "drivers_interface", + "drivers_peripheral", + "arkui_napi", + "resourceschedule_soc_perf", + "distributedhardware_device_manager", + "commonlibrary_ets_utils", + "multimedia_av_codec", + "resourceschedule_qos_manager", + "hiviewdfx_faultloggerd", + "third_party_egl", + "theme_wallpaper_mgr", + "graphic_graphic_surface", + "third_party_astc-encoder", + "hiviewdfx_hicollie", + "graphic_graphics_effect", + "third_party_opencl-headers", + "third_party_mindspore", + "third_party_flatbuffers", + "ai_intellogent_voice_framework", + "ai_neural_network_runtime", + "third_party_tex-hyphen", + "notification_common_event_service", + "notification_eventhandler", + "filemanagement_storage_service", + "notification_distributed_notification_service", + "filemanagement_app_file_service", + "account_os_account", + "filemanagement_dfs_service", + "startup_appspawn", + "usb_usb_manager", + "time_time_service", + "security_security_guard", + "useriam_face_auth", + "useriam_user_auth_framework", + "useriam_fingerprint_auth", + "useriam_pin_auth", + "applications_auth_widget", + "inputmethod_imf", + "drivers_hdf_core", + "third_party_alsa-lib", + "third_party_openmax", + "msdp_device_status", + "sensors_miscdevice", + "sensors_sensor", + "customization_enterprise_device_management", + "third_party_css-what", + "drivers_external_device_manager", + "hiviewdfx_hilog", + "security_crypto_framework", + "security_certificate_manager", + "hiviewdfx_hiappevent", + "accesscontrol_sandbox_manager", + "requests_request", + "third_party_openssl", + "security_asset", + "graphic_graphic_d", + "third_party_mtdev", + "third_party_libinput", + "systemabilitymgr_samgr", + "systemabilitymgr_safwk", + "filemanagement_user_file_service", + "powermgr_battery_statistics", + "powermgr_power_manager", + "powermgr_thermal_manager", + "third_party_gptfdisk", + "third_party_ntfs-3g", + "startup_init", + "powermgr_battery_manager", + "powermgr_display_manager", + "distributeddatamgr_data_object", + "distributeddatamgr_kv_store", + "distributeddatamgr_datamgr_service", + "distributeddatamgr_udmf", + "distributeddatamgr_preferences", + "distributeddatamgr_data_share", + "filemanagement_file_api", + "multimodalinput_input", + "distributeddatamgr_relational_store", + "graphic_graphic_3d", + "developtools_hdc", + "third_party_libusb", + "base_location", + "theme_screenlock_mgr", + "third_party_libwebsockets", + "third_party_brotli", + "third_party_elfio", + "third_party_lwip", + "third_party_wpa_supplicant", + "developtools_global_resource_tool", + "global_resource_management", + "global_system_resources", + "third_party_noto-cjk", + "third_party_notofonts", + "third_party_libphonenumber", + "global_timezone", + "global_i18n", + "global_font_manager", + "third_party_re2", + "thirtd_party_libbpf", + "third_party_protobuf", + "third_party_abseil-cpp", + "developtools_hiperf", + "third_party_grpc", + "hiviewdfx_hitrace", + "hiviewdfx_hidumper", + "update_updater", + "update_sys_installer", + "third_party_elfutils", + "update_packaging_tools", + "third_party_libabigail", + "web_webview", + "third_party_pyyaml", + "third_party_lame", + "multimedia_ringtone_library", + "multimedia_camera_framework", + "third_party_opensles", + "third_party_pulseaudio", + "multimedia_drm_framework", + "multimedia_image_framework", + "multimedia_player_framework", + "multimedia_media_foundation", + "communication_dhcp", + "applications_permission_manager", + "applications_dlp_manager", + "security_code_signature", + "multimedia_av_session", + "multimedia_media_library", + "applications_user_certificate_manager", + "third_party_popt", + "third_party_liburing", + "third_party_backends", + "communication_wifi", + "communication_bluetooth", + "multimedia_image_effect", + "communication_netstack", + "communication_netmanager_ext", + "third_party_node", + "third_party_harfbuzz", + "third_party_rust_libc", + "third_party_vk-gl-cts", + "third_party_spirv-tools", + "third_party_freetype", + "communication_ipc", + "telephony_telephony_data", + "print_print_fwk", + "third_party_cups", + "third_party_cups-filters", + "third_party_libpng", + "third_party_qrcodegen", + "castengine_cast_framework", + "applications_calendar_data", + "third_party_skia", + "applications_settings", + "telephony_sms_mms", + "window_window_manager", + "multimedia_audio_framework", + "communication_bluetooth_service", + "commonlibrary_rust_ylong_http", + "telephony_core_service", + "telephony_cellular_data", + "telephony_call_manager", + "telephony_state_registry", + "applications_contacts_data", + "castengine_wifi_display", + "arkcompiler_ets_runtime", + "arkcompiler_ets_frontend", + "arkcompiler_runtime_core" + ], + "unsupport-args": [ + "--runtime-mode", + "--build-only-gn", + "--build-type", + "--build-platform-name", + "--rename-last-log", + "--log-mode", + "--precise-branch", + "--full-compilation", + "--strict-mode", + "--scalable-build", + "--build-examle", + "--build-xts", + "--ignore-api-check", + "--skip-partlist-check", + "--log-level", + "--test", + "--root-perf-main", + "--build-variant", + "--device-image", + "--patch", + "--rom-size-statistics", + "--stat-ccache", + "--get-warning-list", + "--generate-ninja-trace", + "--compute-overlap-rate", + "--clean-args", + "--deps-guard", + "--acache", + "--enable-pycache", + "--load-test-config" + ] +} \ No newline at end of file diff --git a/hb/main.py b/hb/main.py index 668e35934b..acfc825c66 100755 --- a/hb/main.py +++ b/hb/main.py @@ -19,7 +19,7 @@ import os import sys -import subprocess +import subprocess9 import json sys.path.append(os.path.dirname(os.path.abspath(__file__))) # ohos/build/hb dir @@ -89,6 +89,13 @@ class Main(): @throw_exception def main(): main = Main() + + if len(sys.argv) > 1 and sys.argv[1] == 'build': + is_indep_args, component_name_list = ArgsResolver.is_indep_args(sys.argv[2:]) + # 将源码编译的命令转成独立编译 + if is_indep_args: + sys.argv[2:] = ArgsResolver.get_indep_args(sys.argv[2:], component_name_list) + module_initializers = { 'build': main._init_indep_build_module if main._is_indep_build() else main._init_build_module, 'init': main._init_hb_init_module, diff --git a/hb/resolver/judge_indep_args_resolver.py b/hb/resolver/judge_indep_args_resolver.py new file mode 100644 index 0000000000..a40d9673d2 --- /dev/null +++ b/hb/resolver/judge_indep_args_resolver.py @@ -0,0 +1,167 @@ +import os +from resolver.interface.args_resolver_interface import ArgsResolverInterface +from util.io_util import IoUtil +from resources.global_var import CURRENT_BUILD_DIR, CURRENT_OHOS_ROOT + +class ArgsResolver(ArgsResolverInterface): + @staticmethod + def parse_command_args(input_args) -> dict: + parsed = {} + i = 0 + while i < len(input_args): + if input_args[i].startswith('--'): + key = input_args[i] + if i + 1 < len(input_args) and not input_args[i+1].startswith('--'): + value = input_args[i+1] + if key in parsed: + if not isinstance(parsed[key], list): + parsed[key] = [parsed[key]] + parsed[key].append(value) + else: + parsed[key] = value + i += 2 + else: + parsed[key] = True + i += 1 + else: + if 'positional_input_args' not in parsed: + parsed['positional_input_args'] = [] + parsed['positional_input_args'].append(input_args[i]) + i += 1 + return parsed + + @staticmethod + def read_indep_whitelist() -> dict: + indep_whitelist_path = os.path.join(CURRENT_BUILD_DIR, 'indep_component_whitelist.json') + return IoUtil.read_json_file(indep_whitelist_path) + + @staticmethod + def is_indep_args(input_args) -> tuple[bool, list]: + try: + build_indep_whitelist = ArgsResolver.read_indep_whitelist() + except Exception as e: + print(f"读取白名单失败: {e}") + return False, [] # 异常时返回空列表 + + input_args_dict = ArgsResolver.parse_command_args(input_args) + + # 检查产品名称 + product_name = input_args_dict.get('--product-name') + if not product_name or product_name not in build_indep_whitelist.get('product-name', []): + return False, [] # 产品名不匹配时返回空列表 + + # 检查构建目标组件(处理解析失败的情况) + build_target = input_args_dict.get('--build-target') + component_result = ArgsResolver.parse_component_name(build_target) + + # 组件解析失败(返回False) + if component_result is False: + return False, [] # 解析失败时返回空列表 + + # 组件解析成功但列表为空 + if not component_result: + return False, [] + + # 检查组件是否都在白名单中 + whitelist_components = build_indep_whitelist.get('components', []) + if not all(comp in whitelist_components for comp in component_result): + return False, component_result + + # 检查不支持的参数 + unsupported_args = build_indep_whitelist.get('unsupport-args', []) + for arg in input_args_dict: + if arg == 'positional_input_args': + continue + if arg in unsupported_args: + return False, component_result + + # 所有条件都满足 + return True, component_result + + + @staticmethod + def parse_component_name(build_targets): + component_name_list = [] + + # 标准化输入为列表类型 + if isinstance(build_targets, str): + targets = [build_targets] + elif isinstance(build_targets, list): + targets = build_targets + else: + return False # 输入类型无效时返回False + + for build_target in targets: + bundle_rel_path = ArgsResolver.find_deepest_bundle_json(build_target) + if not bundle_rel_path: + print(f"未找到{build_target}对应的bundle.json文件") + return False # 未找到json文件,直接返回False + + bundle_path = os.path.join(CURRENT_OHOS_ROOT, bundle_rel_path) + + try: + bundle_json = IoUtil.read_json_file(bundle_path) + component_name = bundle_json.get("component", {}).get("name") + if component_name: + component_name_list.append(component_name) + else: + print(f"{bundle_path}中未找到component.name配置") + return False # 未找到component.name,直接返回False + except Exception as e: + print(f"读取{bundle_path}失败: {e}") + return False # 读取文件失败,直接返回False + + return component_name_list if component_name_list else False + + + @staticmethod + def find_deepest_bundle_json(build_str): + base_path = build_str.split(':')[0] + deepest_bundle = None + current_path = "" + path_parts = base_path.split(os.sep) + + for part in path_parts: + current_path = os.path.join(current_path, part) + if os.path.isdir(current_path): + bundle_json_path = os.path.join(current_path, 'bundle.json') + if os.path.isfile(bundle_json_path): + deepest_bundle = bundle_json_path + + return deepest_bundle + + @staticmethod + def get_indep_args(sys_argv, component_name_list): + new_args = [] # 保留初始build命令 + i = 0 + added_components = False # 标记组件是否已添加 + added_i = False # 标记-i是否已添加 + + while i < len(sys_argv): + arg = sys_argv[i] + + # 移除--product-name及其值 + if arg == '--product-name': + i += 2 + continue + + # 处理所有--build-target:只添加一次组件列表和-i + elif arg == '--build-target': + # 仅在第一次遇到--build-target时添加组件列表 + if not added_components: + new_args.extend(component_name_list) # 添加['request', 'print_fwk'] + added_components = True + + # 仅添加一次-i + if not added_i: + new_args.append('-i') + added_i = True + + i += 2 # 跳过当前--build-target及其值,不重复添加组件 + continue + + # 保留其他参数 + else: + new_args.append(arg) + i += 1 + return new_args diff --git a/hb/services/indep_build.py b/hb/services/indep_build.py index 6695012e87..7cedbe542e 100644 --- a/hb/services/indep_build.py +++ b/hb/services/indep_build.py @@ -23,6 +23,7 @@ import os from util.log_util import LogUtil import json import shutil +import sys class IndepBuild(BuildFileGeneratorInterface): @@ -34,6 +35,10 @@ class IndepBuild(BuildFileGeneratorInterface): flags_list = self._convert_flags() cmd = ["/bin/bash", "build/indep_configs/build_indep.sh"] cmd.extend(flags_list) + product_name = self._get_product_name() + if product_name != None: + cmd.append("--product-name") + cmd.append(product_name) variant = self.flags_dict["variant"] logpath = os.path.join('out', variant, 'build.log') SystemUtil.exec_command(cmd, log_path=logpath, pre_msg="run indep build", @@ -124,4 +129,13 @@ class IndepBuild(BuildFileGeneratorInterface): relative_path = os.path.relpath(root, local_binarys) dependences_dict[component_name] = { "installPath": "/" + relative_path - } \ No newline at end of file + } + + def _get_product_name(self): + orig_argv = sys.orig_argv + for i in range(len(orig_argv)): + if orig_argv[i] == '--product-name': + if i + 1 < len(orig_argv): + return orig_argv[i + 1] + return None + return None \ No newline at end of file diff --git a/indep_configs/build_indep.sh b/indep_configs/build_indep.sh index 3c36c23258..9e39fc46d7 100755 --- a/indep_configs/build_indep.sh +++ b/indep_configs/build_indep.sh @@ -115,6 +115,20 @@ ${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/variants_info_handler. # gn and ninja command ${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/gn_ninja_cmd.py -rp ${SOURCE_ROOT_DIR} -v ${VARIANTS} -out ${OUT_DIR} -t ${TEST_FILTER} +if [[ "$@" =~ "--product-name" ]]; then + for ((i=1; i<=$#; i++)); do + if [[ "${!i}" == "--product-name" ]]; then + next_index=$((i + 1)) + if [[ $next_index -le $# ]]; then + cp -r out/$VARIANTS/$OUT_DIR out/${!next_index} + exit 0 + fi + fi + done +else + exit 0 +fi + if [ $? -ne 0 ]; then exit 1 fi -- Gitee From e36f6326e36c1b16a212ef3ffcd5bd5d7513223f Mon Sep 17 00:00:00 2001 From: wangmeng Date: Fri, 12 Sep 2025 16:02:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E3=80=81=E5=85=A8=E9=87=8F=E6=BA=90=E7=A0=81=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=BD=92=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangmeng --- hb/indep_component_whitelist.json | 626 +++++++++++++++++++++++ hb/main.py | 9 +- hb/resolver/judge_indep_args_resolver.py | 167 ++++++ hb/services/indep_build.py | 16 +- indep_configs/build_indep.sh | 14 + 5 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 hb/indep_component_whitelist.json create mode 100644 hb/resolver/judge_indep_args_resolver.py diff --git a/hb/indep_component_whitelist.json b/hb/indep_component_whitelist.json new file mode 100644 index 0000000000..0c58361e6c --- /dev/null +++ b/hb/indep_component_whitelist.json @@ -0,0 +1,626 @@ +{ + "product-name": ["rk3568"], + "components": [ + "eventhandler", + "device_manager", + "exfatprogs", + "libnl", + "libevdev", + "libsnd", + "video_processing_engine", + "jsvm", + "libffi", + "iptables", + "hilog", + "hicollie", + "hichecker", + "hisysevent", + "memmgr", + "crypto_framework", + "access_token", + "huks", + "device_auth", + "nghttp2", + "cares", + "lzma", + "libfuse", + "libdrm", + "memory_utils", + "config_policy", + "bluetooth", + "selinux", + "selinux_adapter", + "pcre2", + "mbedtls", + "libcoap", + "lz4", + "bzip2", + "libxml2", + "icu", + "jsoncpp", + "libuv", + "cJSON", + "json", + "libunwind", + "e2fsprogs", + "bounds_checking_function", + "toybox", + "ril_adapter", + "zlib", + "syscap_codec", + "qos_manager", + "device_security_level", + "soc_perf", + "ffmpeg", + "libexif", + "init", + "sqlite", + "miscdevice", + "sensor", + "code_signature", + "dataclassification", + "ecological_rule_manager", + "fsverity-utils", + "f2fs-tools", + "libjpeg-turbo", + "idl_tool", + "tzdata", + "os_account", + "curl", + "start", + "dcts", + "certificate_framework", + "vulkan-headers", + "bytrace", + "tee_client", + "dlp_permission_service", + "frame_aware_sched", + "jerryscript", + "vixl", + "unity", + "opengles", + "app_domain_verify", + "cellular_call", + "update_service", + "vulkan-loader", + "c_utils", + "device_standby", + "certificate_manager", + "display_manager", + "distributed_audio", + "distributed_camera", + "storage_service", + "security_guard", + "ui_appearance", + "distributed_input", + "face_auth", + "security_component_manager", + "fingerprint_auth", + "battery_statistics", + "media_foundation", + "distributed_screen", + "ylong_runtime", + "ylong_json", + "pin_auth", + "netmanager_base", + "ffrt", + "audio_framework", + "ability_base", + "graphic_surface", + "power_manager", + "thermal_manager", + "appspawn", + "player_framework", + "battery_manager", + "input", + "napi", + "sms_mms", + "user_auth_framework", + "sandbox_manager", + "appverify", + "dsoftbus", + "distributed_bundle_framework", + "window_manager", + "device_usage_statistics", + "packing_tool", + "resource_schedule_service", + "ability_runtime", + "background_task_mgr", + "oaid", + "advertising", + "work_scheduler", + "bundle_tool", + "form_fwk", + "bundle_framework", + "pasteboard", + "hiprofiler", + "decimal.js", + "typescript", + "toolchain", + "drivers_interface_distributed_camera", + "drivers_interface_fingerprint_auth", + "drivers_interface_distributed_audio", + "device_info_manager", + "distributed_hardware_fwk", + "ace_engine", + "dmsfwk", + "drivers_peripheral_distributed_audio", + "drivers_peripheral_distributed_camera", + "ets_utils", + "av_codec", + "accessibility", + "faultloggerd", + "egl", + "wallpaper_mgr", + "astc-encoder", + "graphics_effect", + "opencl-headers", + "mindspore", + "flatbuffers", + "intelligent_voice_framework", + "drivers_interface_nnrt", + "drivers_peripheral_intelligent_voice", + "drivers_interface_intelligent_voice", + "neural_network_runtime", + "tex-hyphen", + "common_event_service", + "distributed_notification_service", + "app_file_service", + "dfs_service", + "drivers_peripheral_thermal", + "usb_manager", + "time_service", + "drivers_interface_face_auth", + "drivers_interface_pin_auth", + "drivers_interface_user_auth", + "drivers_peripheral_face_auth", + "drivers_peripheral_fingerprint_auth", + "drivers_peripheral_pin_auth", + "drivers_peripheral_user_auth", + "auth_widget", + "imf", + "drivers_interface_audio", + "drivers_interface_codec", + "drivers_interface_display", + "drivers_interface_input", + "drivers_interface_light", + "drivers_interface_motion", + "drivers_interface_sensor", + "drivers_interface_vibrator", + "drivers_peripheral_audio", + "drivers_peripheral_codec", + "drivers_peripheral_display", + "drivers_peripheral_input", + "drivers_peripheral_light", + "drivers_peripheral_motion", + "drivers_peripheral_sensor", + "drivers_peripheral_vibrator", + "hdf_core", + "alsa-lib", + "alsa-utils", + "openmax", + "drivers_interface_camera", + "device_status", + "enterprise_device_management", + "drivers_peripheral_usb", + "css-what", + "external_device_manager", + "hiappevent", + "hiview", + "drivers_interface_huks", + "request", + "openssl", + "asset", + "graphic_2d", + "drivers_peripheral_wlan", + "mtdev", + "libinput", + "samgr", + "safwk", + "user_file_service", + "gptfdisk", + "ntfs-3g", + "drivers_interface_usb", + "drivers_peripheral_battery", + "drivers_peripheral_power", + "drivers_peripheral_camera", + "drivers_interface_wlan", + "data_object", + "kv_store", + "datamgr_service", + "udmf", + "preferences", + "data_share", + "file_api", + "relational_store", + "drivers_interface_thermal", + "drivers_interface_battery", + "drivers_interface_power", + "drivers_interface_partitionslot", + "drivers_peripheral_partitionslot", + "graphic_3d", + "hdc", + "libusb", + "location", + "screenlock_mgr", + "libwebsockets", + "brotli", + "elfio", + "lwip", + "wpa_supplicant", + "global_resource_tool", + "resource_management", + "system_resources", + "noto-cjk", + "notofonts", + "libphonenumber", + "timezone", + "i18n", + "font_manager", + "re2", + "libbpf", + "protobuf", + "abseil-cpp", + "hiperf", + "grpc", + "hitrace", + "hidumper", + "updater", + "sys_installer", + "elfutils", + "packaging_tools", + "libabigail", + "PyYAML", + "lame", + "ringtone_library", + "camera_framework", + "opensles", + "pulseaudio", + "drm_framework", + "drivers_interface_drm", + "drivers_peripheral_clearplay", + "image_framework", + "drivers_peripheral_location_agnss", + "drivers_interface_location_agnss", + "drivers_peripheral_location_gnss", + "drivers_interface_location_gnss", + "drivers_peripheral_location_geofence", + "drivers_interface_location_geofence", + "drivers_interface_act_recg", + "drivers_interface_lpfence", + "dhcp", + "drivers_interface_bluetooth", + "permission_manager", + "dlp_manager", + "media_library", + "av_session", + "user_certificate_manager", + "popt", + "liburing", + "backends", + "drivers_peripheral_huks", + "drivers_peripheral_memorytracker", + "drivers_interface_memorytracker", + "webview", + "wifi", + "image_effect", + "netstack", + "netmanager_ext", + "node", + "harfbuzz", + "rust_libc", + "vk-gl-cts", + "spirv-tools", + "freetype", + "ipc", + "telephony_data", + "print_fwk", + "cups", + "cups-filters", + "libpng", + "qrcodegen", + "cast_engine", + "calendar_data", + "skia", + "settings", + "drivers_peripheral_ril", + "drivers_interface_ril", + "bluetooth_service", + "drivers_peripheral_bluetooth", + "ylong_http", + "core_service", + "cellular_data", + "call_manager", + "state_registry", + "contacts_data", + "sharing_framework", + "ets_runtime", + "ets_frontend", + "runtime_ocre", + "third_party_exfatprogs", + "third_party_libnl", + "third_party_libevdev", + "third_party_libsnd", + "third_party_libffi", + "third_party_nghttp2", + "third_party_cares", + "third_party_lzma", + "third_party_libfuse", + "third_party_selinux", + "third_party_pcre2", + "third_party_mbedtls", + "third_party_lz4", + "third_party_libcoap", + "third_party_icu", + "third_party_libuv", + "third_party_json", + "third_party_iptables", + "third_party_toybox", + "multimedia_video_processing_engine", + "third_party_sqlite", + "third_party_bounds_checking_function", + "tee_tee_client", + "sensors_start", + "third_party_libunwind", + "third_party_jsoncpp", + "third_party_libxml2", + "third_party_bzip2", + "third_party_vulkan-loader", + "third_party_zlib", + "third_party_vulkan-headers", + "third_party_unity", + "third_party_opengles", + "third_party_vixl", + "third_party_ffmpeg", + "third_party_libexif", + "third_party_cJSON", + "third_party_libdrm", + "commonlibrary_rust_ylong_json", + "third_party_curl", + "developtools_syscap_codec", + "hiviewdfx_hichecker", + "bundlemanager_ecological_rule_manager", + "arkui_ui_appearance", + "update_update_service", + "linux_frame_aware_sched", + "developtools_bytrace", + "resourceschedule_ffrt", + "commonlibrary_memory_utils", + "customization_config_policy", + "security_selinux_adapter", + "security_certificate_framework", + "security_device_security_level", + "security_dataclassification", + "distributedhardware_distributed_camera", + "third_party_e2fsprogs", + "third_party_fsverity-utils", + "third_party_f2fs-tools", + "third_party_libjpeg-turbo", + "third_party_tzdata", + "third_party_jerryscript", + "telephony_ril_adapter", + "security_appverify", + "ability_idl_tool", + "bundlemanager_app_domain_verify", + "ability_ability_base", + "bundlemanager_distributed_bundle_framework", + "developtools_packing_tool", + "advertising_ads_framework", + "commonlibrary_rust_ylong_runtime", + "advertising_oaid", + "resourceschedule_resource_schedule_service", + "resourceschedule_device_usage_statistics", + "resourceschedule_background_task_mgr", + "resourceschedule_work_scheduler", + "bundlemanager_bundle_tool", + "ability_form_fwk", + "ability_ability_runtime", + "bundlemanager_bundle_framework", + "distributeddatamgr_pasteboard", + "developtools_profiler", + "commonlibrary_c_utils", + "third_party_decimal.js", + "third_party_typescript", + "communication_dsoftbus", + "arkcompiler_toolchain", + "drivers_interface", + "drivers_peripheral", + "arkui_napi", + "resourceschedule_soc_perf", + "distributedhardware_device_manager", + "commonlibrary_ets_utils", + "multimedia_av_codec", + "resourceschedule_qos_manager", + "hiviewdfx_faultloggerd", + "third_party_egl", + "theme_wallpaper_mgr", + "graphic_graphic_surface", + "third_party_astc-encoder", + "hiviewdfx_hicollie", + "graphic_graphics_effect", + "third_party_opencl-headers", + "third_party_mindspore", + "third_party_flatbuffers", + "ai_intellogent_voice_framework", + "ai_neural_network_runtime", + "third_party_tex-hyphen", + "notification_common_event_service", + "notification_eventhandler", + "filemanagement_storage_service", + "notification_distributed_notification_service", + "filemanagement_app_file_service", + "account_os_account", + "filemanagement_dfs_service", + "startup_appspawn", + "usb_usb_manager", + "time_time_service", + "security_security_guard", + "useriam_face_auth", + "useriam_user_auth_framework", + "useriam_fingerprint_auth", + "useriam_pin_auth", + "applications_auth_widget", + "inputmethod_imf", + "drivers_hdf_core", + "third_party_alsa-lib", + "third_party_openmax", + "msdp_device_status", + "sensors_miscdevice", + "sensors_sensor", + "customization_enterprise_device_management", + "third_party_css-what", + "drivers_external_device_manager", + "hiviewdfx_hilog", + "security_crypto_framework", + "security_certificate_manager", + "hiviewdfx_hiappevent", + "accesscontrol_sandbox_manager", + "requests_request", + "third_party_openssl", + "security_asset", + "graphic_graphic_d", + "third_party_mtdev", + "third_party_libinput", + "systemabilitymgr_samgr", + "systemabilitymgr_safwk", + "filemanagement_user_file_service", + "powermgr_battery_statistics", + "powermgr_power_manager", + "powermgr_thermal_manager", + "third_party_gptfdisk", + "third_party_ntfs-3g", + "startup_init", + "powermgr_battery_manager", + "powermgr_display_manager", + "distributeddatamgr_data_object", + "distributeddatamgr_kv_store", + "distributeddatamgr_datamgr_service", + "distributeddatamgr_udmf", + "distributeddatamgr_preferences", + "distributeddatamgr_data_share", + "filemanagement_file_api", + "multimodalinput_input", + "distributeddatamgr_relational_store", + "graphic_graphic_3d", + "developtools_hdc", + "third_party_libusb", + "base_location", + "theme_screenlock_mgr", + "third_party_libwebsockets", + "third_party_brotli", + "third_party_elfio", + "third_party_lwip", + "third_party_wpa_supplicant", + "developtools_global_resource_tool", + "global_resource_management", + "global_system_resources", + "third_party_noto-cjk", + "third_party_notofonts", + "third_party_libphonenumber", + "global_timezone", + "global_i18n", + "global_font_manager", + "third_party_re2", + "thirtd_party_libbpf", + "third_party_protobuf", + "third_party_abseil-cpp", + "developtools_hiperf", + "third_party_grpc", + "hiviewdfx_hitrace", + "hiviewdfx_hidumper", + "update_updater", + "update_sys_installer", + "third_party_elfutils", + "update_packaging_tools", + "third_party_libabigail", + "web_webview", + "third_party_pyyaml", + "third_party_lame", + "multimedia_ringtone_library", + "multimedia_camera_framework", + "third_party_opensles", + "third_party_pulseaudio", + "multimedia_drm_framework", + "multimedia_image_framework", + "multimedia_player_framework", + "multimedia_media_foundation", + "communication_dhcp", + "applications_permission_manager", + "applications_dlp_manager", + "security_code_signature", + "multimedia_av_session", + "multimedia_media_library", + "applications_user_certificate_manager", + "third_party_popt", + "third_party_liburing", + "third_party_backends", + "communication_wifi", + "communication_bluetooth", + "multimedia_image_effect", + "communication_netstack", + "communication_netmanager_ext", + "third_party_node", + "third_party_harfbuzz", + "third_party_rust_libc", + "third_party_vk-gl-cts", + "third_party_spirv-tools", + "third_party_freetype", + "communication_ipc", + "telephony_telephony_data", + "print_print_fwk", + "third_party_cups", + "third_party_cups-filters", + "third_party_libpng", + "third_party_qrcodegen", + "castengine_cast_framework", + "applications_calendar_data", + "third_party_skia", + "applications_settings", + "telephony_sms_mms", + "window_window_manager", + "multimedia_audio_framework", + "communication_bluetooth_service", + "commonlibrary_rust_ylong_http", + "telephony_core_service", + "telephony_cellular_data", + "telephony_call_manager", + "telephony_state_registry", + "applications_contacts_data", + "castengine_wifi_display", + "arkcompiler_ets_runtime", + "arkcompiler_ets_frontend", + "arkcompiler_runtime_core" + ], + "unsupport-args": [ + "--runtime-mode", + "--build-only-gn", + "--build-type", + "--build-platform-name", + "--rename-last-log", + "--log-mode", + "--precise-branch", + "--full-compilation", + "--strict-mode", + "--scalable-build", + "--build-examle", + "--build-xts", + "--ignore-api-check", + "--skip-partlist-check", + "--log-level", + "--test", + "--root-perf-main", + "--build-variant", + "--device-image", + "--patch", + "--rom-size-statistics", + "--stat-ccache", + "--get-warning-list", + "--generate-ninja-trace", + "--compute-overlap-rate", + "--clean-args", + "--deps-guard", + "--acache", + "--enable-pycache", + "--load-test-config" + ] +} \ No newline at end of file diff --git a/hb/main.py b/hb/main.py index 668e35934b..acfc825c66 100755 --- a/hb/main.py +++ b/hb/main.py @@ -19,7 +19,7 @@ import os import sys -import subprocess +import subprocess9 import json sys.path.append(os.path.dirname(os.path.abspath(__file__))) # ohos/build/hb dir @@ -89,6 +89,13 @@ class Main(): @throw_exception def main(): main = Main() + + if len(sys.argv) > 1 and sys.argv[1] == 'build': + is_indep_args, component_name_list = ArgsResolver.is_indep_args(sys.argv[2:]) + # 将源码编译的命令转成独立编译 + if is_indep_args: + sys.argv[2:] = ArgsResolver.get_indep_args(sys.argv[2:], component_name_list) + module_initializers = { 'build': main._init_indep_build_module if main._is_indep_build() else main._init_build_module, 'init': main._init_hb_init_module, diff --git a/hb/resolver/judge_indep_args_resolver.py b/hb/resolver/judge_indep_args_resolver.py new file mode 100644 index 0000000000..a40d9673d2 --- /dev/null +++ b/hb/resolver/judge_indep_args_resolver.py @@ -0,0 +1,167 @@ +import os +from resolver.interface.args_resolver_interface import ArgsResolverInterface +from util.io_util import IoUtil +from resources.global_var import CURRENT_BUILD_DIR, CURRENT_OHOS_ROOT + +class ArgsResolver(ArgsResolverInterface): + @staticmethod + def parse_command_args(input_args) -> dict: + parsed = {} + i = 0 + while i < len(input_args): + if input_args[i].startswith('--'): + key = input_args[i] + if i + 1 < len(input_args) and not input_args[i+1].startswith('--'): + value = input_args[i+1] + if key in parsed: + if not isinstance(parsed[key], list): + parsed[key] = [parsed[key]] + parsed[key].append(value) + else: + parsed[key] = value + i += 2 + else: + parsed[key] = True + i += 1 + else: + if 'positional_input_args' not in parsed: + parsed['positional_input_args'] = [] + parsed['positional_input_args'].append(input_args[i]) + i += 1 + return parsed + + @staticmethod + def read_indep_whitelist() -> dict: + indep_whitelist_path = os.path.join(CURRENT_BUILD_DIR, 'indep_component_whitelist.json') + return IoUtil.read_json_file(indep_whitelist_path) + + @staticmethod + def is_indep_args(input_args) -> tuple[bool, list]: + try: + build_indep_whitelist = ArgsResolver.read_indep_whitelist() + except Exception as e: + print(f"读取白名单失败: {e}") + return False, [] # 异常时返回空列表 + + input_args_dict = ArgsResolver.parse_command_args(input_args) + + # 检查产品名称 + product_name = input_args_dict.get('--product-name') + if not product_name or product_name not in build_indep_whitelist.get('product-name', []): + return False, [] # 产品名不匹配时返回空列表 + + # 检查构建目标组件(处理解析失败的情况) + build_target = input_args_dict.get('--build-target') + component_result = ArgsResolver.parse_component_name(build_target) + + # 组件解析失败(返回False) + if component_result is False: + return False, [] # 解析失败时返回空列表 + + # 组件解析成功但列表为空 + if not component_result: + return False, [] + + # 检查组件是否都在白名单中 + whitelist_components = build_indep_whitelist.get('components', []) + if not all(comp in whitelist_components for comp in component_result): + return False, component_result + + # 检查不支持的参数 + unsupported_args = build_indep_whitelist.get('unsupport-args', []) + for arg in input_args_dict: + if arg == 'positional_input_args': + continue + if arg in unsupported_args: + return False, component_result + + # 所有条件都满足 + return True, component_result + + + @staticmethod + def parse_component_name(build_targets): + component_name_list = [] + + # 标准化输入为列表类型 + if isinstance(build_targets, str): + targets = [build_targets] + elif isinstance(build_targets, list): + targets = build_targets + else: + return False # 输入类型无效时返回False + + for build_target in targets: + bundle_rel_path = ArgsResolver.find_deepest_bundle_json(build_target) + if not bundle_rel_path: + print(f"未找到{build_target}对应的bundle.json文件") + return False # 未找到json文件,直接返回False + + bundle_path = os.path.join(CURRENT_OHOS_ROOT, bundle_rel_path) + + try: + bundle_json = IoUtil.read_json_file(bundle_path) + component_name = bundle_json.get("component", {}).get("name") + if component_name: + component_name_list.append(component_name) + else: + print(f"{bundle_path}中未找到component.name配置") + return False # 未找到component.name,直接返回False + except Exception as e: + print(f"读取{bundle_path}失败: {e}") + return False # 读取文件失败,直接返回False + + return component_name_list if component_name_list else False + + + @staticmethod + def find_deepest_bundle_json(build_str): + base_path = build_str.split(':')[0] + deepest_bundle = None + current_path = "" + path_parts = base_path.split(os.sep) + + for part in path_parts: + current_path = os.path.join(current_path, part) + if os.path.isdir(current_path): + bundle_json_path = os.path.join(current_path, 'bundle.json') + if os.path.isfile(bundle_json_path): + deepest_bundle = bundle_json_path + + return deepest_bundle + + @staticmethod + def get_indep_args(sys_argv, component_name_list): + new_args = [] # 保留初始build命令 + i = 0 + added_components = False # 标记组件是否已添加 + added_i = False # 标记-i是否已添加 + + while i < len(sys_argv): + arg = sys_argv[i] + + # 移除--product-name及其值 + if arg == '--product-name': + i += 2 + continue + + # 处理所有--build-target:只添加一次组件列表和-i + elif arg == '--build-target': + # 仅在第一次遇到--build-target时添加组件列表 + if not added_components: + new_args.extend(component_name_list) # 添加['request', 'print_fwk'] + added_components = True + + # 仅添加一次-i + if not added_i: + new_args.append('-i') + added_i = True + + i += 2 # 跳过当前--build-target及其值,不重复添加组件 + continue + + # 保留其他参数 + else: + new_args.append(arg) + i += 1 + return new_args diff --git a/hb/services/indep_build.py b/hb/services/indep_build.py index 6695012e87..7cedbe542e 100644 --- a/hb/services/indep_build.py +++ b/hb/services/indep_build.py @@ -23,6 +23,7 @@ import os from util.log_util import LogUtil import json import shutil +import sys class IndepBuild(BuildFileGeneratorInterface): @@ -34,6 +35,10 @@ class IndepBuild(BuildFileGeneratorInterface): flags_list = self._convert_flags() cmd = ["/bin/bash", "build/indep_configs/build_indep.sh"] cmd.extend(flags_list) + product_name = self._get_product_name() + if product_name != None: + cmd.append("--product-name") + cmd.append(product_name) variant = self.flags_dict["variant"] logpath = os.path.join('out', variant, 'build.log') SystemUtil.exec_command(cmd, log_path=logpath, pre_msg="run indep build", @@ -124,4 +129,13 @@ class IndepBuild(BuildFileGeneratorInterface): relative_path = os.path.relpath(root, local_binarys) dependences_dict[component_name] = { "installPath": "/" + relative_path - } \ No newline at end of file + } + + def _get_product_name(self): + orig_argv = sys.orig_argv + for i in range(len(orig_argv)): + if orig_argv[i] == '--product-name': + if i + 1 < len(orig_argv): + return orig_argv[i + 1] + return None + return None \ No newline at end of file diff --git a/indep_configs/build_indep.sh b/indep_configs/build_indep.sh index 3c36c23258..9e39fc46d7 100755 --- a/indep_configs/build_indep.sh +++ b/indep_configs/build_indep.sh @@ -115,6 +115,20 @@ ${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/variants_info_handler. # gn and ninja command ${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/gn_ninja_cmd.py -rp ${SOURCE_ROOT_DIR} -v ${VARIANTS} -out ${OUT_DIR} -t ${TEST_FILTER} +if [[ "$@" =~ "--product-name" ]]; then + for ((i=1; i<=$#; i++)); do + if [[ "${!i}" == "--product-name" ]]; then + next_index=$((i + 1)) + if [[ $next_index -le $# ]]; then + cp -r out/$VARIANTS/$OUT_DIR out/${!next_index} + exit 0 + fi + fi + done +else + exit 0 +fi + if [ $? -ne 0 ]; then exit 1 fi -- Gitee From 3dbd26c25b4cdb9bf0a73e97db3a919129fe4bb9 Mon Sep 17 00:00:00 2001 From: wangmeng Date: Fri, 12 Sep 2025 16:02:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E3=80=81=E5=85=A8=E9=87=8F=E6=BA=90=E7=A0=81=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=BD=92=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangmeng --- hb/indep_component_whitelist.json | 626 +++++++++++++++++++++++ hb/main.py | 9 +- hb/resolver/judge_indep_args_resolver.py | 167 ++++++ hb/services/indep_build.py | 16 +- indep_configs/build_indep.sh | 14 + 5 files changed, 830 insertions(+), 2 deletions(-) create mode 100644 hb/indep_component_whitelist.json create mode 100644 hb/resolver/judge_indep_args_resolver.py diff --git a/hb/indep_component_whitelist.json b/hb/indep_component_whitelist.json new file mode 100644 index 0000000000..0c58361e6c --- /dev/null +++ b/hb/indep_component_whitelist.json @@ -0,0 +1,626 @@ +{ + "product-name": ["rk3568"], + "components": [ + "eventhandler", + "device_manager", + "exfatprogs", + "libnl", + "libevdev", + "libsnd", + "video_processing_engine", + "jsvm", + "libffi", + "iptables", + "hilog", + "hicollie", + "hichecker", + "hisysevent", + "memmgr", + "crypto_framework", + "access_token", + "huks", + "device_auth", + "nghttp2", + "cares", + "lzma", + "libfuse", + "libdrm", + "memory_utils", + "config_policy", + "bluetooth", + "selinux", + "selinux_adapter", + "pcre2", + "mbedtls", + "libcoap", + "lz4", + "bzip2", + "libxml2", + "icu", + "jsoncpp", + "libuv", + "cJSON", + "json", + "libunwind", + "e2fsprogs", + "bounds_checking_function", + "toybox", + "ril_adapter", + "zlib", + "syscap_codec", + "qos_manager", + "device_security_level", + "soc_perf", + "ffmpeg", + "libexif", + "init", + "sqlite", + "miscdevice", + "sensor", + "code_signature", + "dataclassification", + "ecological_rule_manager", + "fsverity-utils", + "f2fs-tools", + "libjpeg-turbo", + "idl_tool", + "tzdata", + "os_account", + "curl", + "start", + "dcts", + "certificate_framework", + "vulkan-headers", + "bytrace", + "tee_client", + "dlp_permission_service", + "frame_aware_sched", + "jerryscript", + "vixl", + "unity", + "opengles", + "app_domain_verify", + "cellular_call", + "update_service", + "vulkan-loader", + "c_utils", + "device_standby", + "certificate_manager", + "display_manager", + "distributed_audio", + "distributed_camera", + "storage_service", + "security_guard", + "ui_appearance", + "distributed_input", + "face_auth", + "security_component_manager", + "fingerprint_auth", + "battery_statistics", + "media_foundation", + "distributed_screen", + "ylong_runtime", + "ylong_json", + "pin_auth", + "netmanager_base", + "ffrt", + "audio_framework", + "ability_base", + "graphic_surface", + "power_manager", + "thermal_manager", + "appspawn", + "player_framework", + "battery_manager", + "input", + "napi", + "sms_mms", + "user_auth_framework", + "sandbox_manager", + "appverify", + "dsoftbus", + "distributed_bundle_framework", + "window_manager", + "device_usage_statistics", + "packing_tool", + "resource_schedule_service", + "ability_runtime", + "background_task_mgr", + "oaid", + "advertising", + "work_scheduler", + "bundle_tool", + "form_fwk", + "bundle_framework", + "pasteboard", + "hiprofiler", + "decimal.js", + "typescript", + "toolchain", + "drivers_interface_distributed_camera", + "drivers_interface_fingerprint_auth", + "drivers_interface_distributed_audio", + "device_info_manager", + "distributed_hardware_fwk", + "ace_engine", + "dmsfwk", + "drivers_peripheral_distributed_audio", + "drivers_peripheral_distributed_camera", + "ets_utils", + "av_codec", + "accessibility", + "faultloggerd", + "egl", + "wallpaper_mgr", + "astc-encoder", + "graphics_effect", + "opencl-headers", + "mindspore", + "flatbuffers", + "intelligent_voice_framework", + "drivers_interface_nnrt", + "drivers_peripheral_intelligent_voice", + "drivers_interface_intelligent_voice", + "neural_network_runtime", + "tex-hyphen", + "common_event_service", + "distributed_notification_service", + "app_file_service", + "dfs_service", + "drivers_peripheral_thermal", + "usb_manager", + "time_service", + "drivers_interface_face_auth", + "drivers_interface_pin_auth", + "drivers_interface_user_auth", + "drivers_peripheral_face_auth", + "drivers_peripheral_fingerprint_auth", + "drivers_peripheral_pin_auth", + "drivers_peripheral_user_auth", + "auth_widget", + "imf", + "drivers_interface_audio", + "drivers_interface_codec", + "drivers_interface_display", + "drivers_interface_input", + "drivers_interface_light", + "drivers_interface_motion", + "drivers_interface_sensor", + "drivers_interface_vibrator", + "drivers_peripheral_audio", + "drivers_peripheral_codec", + "drivers_peripheral_display", + "drivers_peripheral_input", + "drivers_peripheral_light", + "drivers_peripheral_motion", + "drivers_peripheral_sensor", + "drivers_peripheral_vibrator", + "hdf_core", + "alsa-lib", + "alsa-utils", + "openmax", + "drivers_interface_camera", + "device_status", + "enterprise_device_management", + "drivers_peripheral_usb", + "css-what", + "external_device_manager", + "hiappevent", + "hiview", + "drivers_interface_huks", + "request", + "openssl", + "asset", + "graphic_2d", + "drivers_peripheral_wlan", + "mtdev", + "libinput", + "samgr", + "safwk", + "user_file_service", + "gptfdisk", + "ntfs-3g", + "drivers_interface_usb", + "drivers_peripheral_battery", + "drivers_peripheral_power", + "drivers_peripheral_camera", + "drivers_interface_wlan", + "data_object", + "kv_store", + "datamgr_service", + "udmf", + "preferences", + "data_share", + "file_api", + "relational_store", + "drivers_interface_thermal", + "drivers_interface_battery", + "drivers_interface_power", + "drivers_interface_partitionslot", + "drivers_peripheral_partitionslot", + "graphic_3d", + "hdc", + "libusb", + "location", + "screenlock_mgr", + "libwebsockets", + "brotli", + "elfio", + "lwip", + "wpa_supplicant", + "global_resource_tool", + "resource_management", + "system_resources", + "noto-cjk", + "notofonts", + "libphonenumber", + "timezone", + "i18n", + "font_manager", + "re2", + "libbpf", + "protobuf", + "abseil-cpp", + "hiperf", + "grpc", + "hitrace", + "hidumper", + "updater", + "sys_installer", + "elfutils", + "packaging_tools", + "libabigail", + "PyYAML", + "lame", + "ringtone_library", + "camera_framework", + "opensles", + "pulseaudio", + "drm_framework", + "drivers_interface_drm", + "drivers_peripheral_clearplay", + "image_framework", + "drivers_peripheral_location_agnss", + "drivers_interface_location_agnss", + "drivers_peripheral_location_gnss", + "drivers_interface_location_gnss", + "drivers_peripheral_location_geofence", + "drivers_interface_location_geofence", + "drivers_interface_act_recg", + "drivers_interface_lpfence", + "dhcp", + "drivers_interface_bluetooth", + "permission_manager", + "dlp_manager", + "media_library", + "av_session", + "user_certificate_manager", + "popt", + "liburing", + "backends", + "drivers_peripheral_huks", + "drivers_peripheral_memorytracker", + "drivers_interface_memorytracker", + "webview", + "wifi", + "image_effect", + "netstack", + "netmanager_ext", + "node", + "harfbuzz", + "rust_libc", + "vk-gl-cts", + "spirv-tools", + "freetype", + "ipc", + "telephony_data", + "print_fwk", + "cups", + "cups-filters", + "libpng", + "qrcodegen", + "cast_engine", + "calendar_data", + "skia", + "settings", + "drivers_peripheral_ril", + "drivers_interface_ril", + "bluetooth_service", + "drivers_peripheral_bluetooth", + "ylong_http", + "core_service", + "cellular_data", + "call_manager", + "state_registry", + "contacts_data", + "sharing_framework", + "ets_runtime", + "ets_frontend", + "runtime_ocre", + "third_party_exfatprogs", + "third_party_libnl", + "third_party_libevdev", + "third_party_libsnd", + "third_party_libffi", + "third_party_nghttp2", + "third_party_cares", + "third_party_lzma", + "third_party_libfuse", + "third_party_selinux", + "third_party_pcre2", + "third_party_mbedtls", + "third_party_lz4", + "third_party_libcoap", + "third_party_icu", + "third_party_libuv", + "third_party_json", + "third_party_iptables", + "third_party_toybox", + "multimedia_video_processing_engine", + "third_party_sqlite", + "third_party_bounds_checking_function", + "tee_tee_client", + "sensors_start", + "third_party_libunwind", + "third_party_jsoncpp", + "third_party_libxml2", + "third_party_bzip2", + "third_party_vulkan-loader", + "third_party_zlib", + "third_party_vulkan-headers", + "third_party_unity", + "third_party_opengles", + "third_party_vixl", + "third_party_ffmpeg", + "third_party_libexif", + "third_party_cJSON", + "third_party_libdrm", + "commonlibrary_rust_ylong_json", + "third_party_curl", + "developtools_syscap_codec", + "hiviewdfx_hichecker", + "bundlemanager_ecological_rule_manager", + "arkui_ui_appearance", + "update_update_service", + "linux_frame_aware_sched", + "developtools_bytrace", + "resourceschedule_ffrt", + "commonlibrary_memory_utils", + "customization_config_policy", + "security_selinux_adapter", + "security_certificate_framework", + "security_device_security_level", + "security_dataclassification", + "distributedhardware_distributed_camera", + "third_party_e2fsprogs", + "third_party_fsverity-utils", + "third_party_f2fs-tools", + "third_party_libjpeg-turbo", + "third_party_tzdata", + "third_party_jerryscript", + "telephony_ril_adapter", + "security_appverify", + "ability_idl_tool", + "bundlemanager_app_domain_verify", + "ability_ability_base", + "bundlemanager_distributed_bundle_framework", + "developtools_packing_tool", + "advertising_ads_framework", + "commonlibrary_rust_ylong_runtime", + "advertising_oaid", + "resourceschedule_resource_schedule_service", + "resourceschedule_device_usage_statistics", + "resourceschedule_background_task_mgr", + "resourceschedule_work_scheduler", + "bundlemanager_bundle_tool", + "ability_form_fwk", + "ability_ability_runtime", + "bundlemanager_bundle_framework", + "distributeddatamgr_pasteboard", + "developtools_profiler", + "commonlibrary_c_utils", + "third_party_decimal.js", + "third_party_typescript", + "communication_dsoftbus", + "arkcompiler_toolchain", + "drivers_interface", + "drivers_peripheral", + "arkui_napi", + "resourceschedule_soc_perf", + "distributedhardware_device_manager", + "commonlibrary_ets_utils", + "multimedia_av_codec", + "resourceschedule_qos_manager", + "hiviewdfx_faultloggerd", + "third_party_egl", + "theme_wallpaper_mgr", + "graphic_graphic_surface", + "third_party_astc-encoder", + "hiviewdfx_hicollie", + "graphic_graphics_effect", + "third_party_opencl-headers", + "third_party_mindspore", + "third_party_flatbuffers", + "ai_intellogent_voice_framework", + "ai_neural_network_runtime", + "third_party_tex-hyphen", + "notification_common_event_service", + "notification_eventhandler", + "filemanagement_storage_service", + "notification_distributed_notification_service", + "filemanagement_app_file_service", + "account_os_account", + "filemanagement_dfs_service", + "startup_appspawn", + "usb_usb_manager", + "time_time_service", + "security_security_guard", + "useriam_face_auth", + "useriam_user_auth_framework", + "useriam_fingerprint_auth", + "useriam_pin_auth", + "applications_auth_widget", + "inputmethod_imf", + "drivers_hdf_core", + "third_party_alsa-lib", + "third_party_openmax", + "msdp_device_status", + "sensors_miscdevice", + "sensors_sensor", + "customization_enterprise_device_management", + "third_party_css-what", + "drivers_external_device_manager", + "hiviewdfx_hilog", + "security_crypto_framework", + "security_certificate_manager", + "hiviewdfx_hiappevent", + "accesscontrol_sandbox_manager", + "requests_request", + "third_party_openssl", + "security_asset", + "graphic_graphic_d", + "third_party_mtdev", + "third_party_libinput", + "systemabilitymgr_samgr", + "systemabilitymgr_safwk", + "filemanagement_user_file_service", + "powermgr_battery_statistics", + "powermgr_power_manager", + "powermgr_thermal_manager", + "third_party_gptfdisk", + "third_party_ntfs-3g", + "startup_init", + "powermgr_battery_manager", + "powermgr_display_manager", + "distributeddatamgr_data_object", + "distributeddatamgr_kv_store", + "distributeddatamgr_datamgr_service", + "distributeddatamgr_udmf", + "distributeddatamgr_preferences", + "distributeddatamgr_data_share", + "filemanagement_file_api", + "multimodalinput_input", + "distributeddatamgr_relational_store", + "graphic_graphic_3d", + "developtools_hdc", + "third_party_libusb", + "base_location", + "theme_screenlock_mgr", + "third_party_libwebsockets", + "third_party_brotli", + "third_party_elfio", + "third_party_lwip", + "third_party_wpa_supplicant", + "developtools_global_resource_tool", + "global_resource_management", + "global_system_resources", + "third_party_noto-cjk", + "third_party_notofonts", + "third_party_libphonenumber", + "global_timezone", + "global_i18n", + "global_font_manager", + "third_party_re2", + "thirtd_party_libbpf", + "third_party_protobuf", + "third_party_abseil-cpp", + "developtools_hiperf", + "third_party_grpc", + "hiviewdfx_hitrace", + "hiviewdfx_hidumper", + "update_updater", + "update_sys_installer", + "third_party_elfutils", + "update_packaging_tools", + "third_party_libabigail", + "web_webview", + "third_party_pyyaml", + "third_party_lame", + "multimedia_ringtone_library", + "multimedia_camera_framework", + "third_party_opensles", + "third_party_pulseaudio", + "multimedia_drm_framework", + "multimedia_image_framework", + "multimedia_player_framework", + "multimedia_media_foundation", + "communication_dhcp", + "applications_permission_manager", + "applications_dlp_manager", + "security_code_signature", + "multimedia_av_session", + "multimedia_media_library", + "applications_user_certificate_manager", + "third_party_popt", + "third_party_liburing", + "third_party_backends", + "communication_wifi", + "communication_bluetooth", + "multimedia_image_effect", + "communication_netstack", + "communication_netmanager_ext", + "third_party_node", + "third_party_harfbuzz", + "third_party_rust_libc", + "third_party_vk-gl-cts", + "third_party_spirv-tools", + "third_party_freetype", + "communication_ipc", + "telephony_telephony_data", + "print_print_fwk", + "third_party_cups", + "third_party_cups-filters", + "third_party_libpng", + "third_party_qrcodegen", + "castengine_cast_framework", + "applications_calendar_data", + "third_party_skia", + "applications_settings", + "telephony_sms_mms", + "window_window_manager", + "multimedia_audio_framework", + "communication_bluetooth_service", + "commonlibrary_rust_ylong_http", + "telephony_core_service", + "telephony_cellular_data", + "telephony_call_manager", + "telephony_state_registry", + "applications_contacts_data", + "castengine_wifi_display", + "arkcompiler_ets_runtime", + "arkcompiler_ets_frontend", + "arkcompiler_runtime_core" + ], + "unsupport-args": [ + "--runtime-mode", + "--build-only-gn", + "--build-type", + "--build-platform-name", + "--rename-last-log", + "--log-mode", + "--precise-branch", + "--full-compilation", + "--strict-mode", + "--scalable-build", + "--build-examle", + "--build-xts", + "--ignore-api-check", + "--skip-partlist-check", + "--log-level", + "--test", + "--root-perf-main", + "--build-variant", + "--device-image", + "--patch", + "--rom-size-statistics", + "--stat-ccache", + "--get-warning-list", + "--generate-ninja-trace", + "--compute-overlap-rate", + "--clean-args", + "--deps-guard", + "--acache", + "--enable-pycache", + "--load-test-config" + ] +} \ No newline at end of file diff --git a/hb/main.py b/hb/main.py index 668e35934b..acfc825c66 100755 --- a/hb/main.py +++ b/hb/main.py @@ -19,7 +19,7 @@ import os import sys -import subprocess +import subprocess9 import json sys.path.append(os.path.dirname(os.path.abspath(__file__))) # ohos/build/hb dir @@ -89,6 +89,13 @@ class Main(): @throw_exception def main(): main = Main() + + if len(sys.argv) > 1 and sys.argv[1] == 'build': + is_indep_args, component_name_list = ArgsResolver.is_indep_args(sys.argv[2:]) + # 将源码编译的命令转成独立编译 + if is_indep_args: + sys.argv[2:] = ArgsResolver.get_indep_args(sys.argv[2:], component_name_list) + module_initializers = { 'build': main._init_indep_build_module if main._is_indep_build() else main._init_build_module, 'init': main._init_hb_init_module, diff --git a/hb/resolver/judge_indep_args_resolver.py b/hb/resolver/judge_indep_args_resolver.py new file mode 100644 index 0000000000..a40d9673d2 --- /dev/null +++ b/hb/resolver/judge_indep_args_resolver.py @@ -0,0 +1,167 @@ +import os +from resolver.interface.args_resolver_interface import ArgsResolverInterface +from util.io_util import IoUtil +from resources.global_var import CURRENT_BUILD_DIR, CURRENT_OHOS_ROOT + +class ArgsResolver(ArgsResolverInterface): + @staticmethod + def parse_command_args(input_args) -> dict: + parsed = {} + i = 0 + while i < len(input_args): + if input_args[i].startswith('--'): + key = input_args[i] + if i + 1 < len(input_args) and not input_args[i+1].startswith('--'): + value = input_args[i+1] + if key in parsed: + if not isinstance(parsed[key], list): + parsed[key] = [parsed[key]] + parsed[key].append(value) + else: + parsed[key] = value + i += 2 + else: + parsed[key] = True + i += 1 + else: + if 'positional_input_args' not in parsed: + parsed['positional_input_args'] = [] + parsed['positional_input_args'].append(input_args[i]) + i += 1 + return parsed + + @staticmethod + def read_indep_whitelist() -> dict: + indep_whitelist_path = os.path.join(CURRENT_BUILD_DIR, 'indep_component_whitelist.json') + return IoUtil.read_json_file(indep_whitelist_path) + + @staticmethod + def is_indep_args(input_args) -> tuple[bool, list]: + try: + build_indep_whitelist = ArgsResolver.read_indep_whitelist() + except Exception as e: + print(f"读取白名单失败: {e}") + return False, [] # 异常时返回空列表 + + input_args_dict = ArgsResolver.parse_command_args(input_args) + + # 检查产品名称 + product_name = input_args_dict.get('--product-name') + if not product_name or product_name not in build_indep_whitelist.get('product-name', []): + return False, [] # 产品名不匹配时返回空列表 + + # 检查构建目标组件(处理解析失败的情况) + build_target = input_args_dict.get('--build-target') + component_result = ArgsResolver.parse_component_name(build_target) + + # 组件解析失败(返回False) + if component_result is False: + return False, [] # 解析失败时返回空列表 + + # 组件解析成功但列表为空 + if not component_result: + return False, [] + + # 检查组件是否都在白名单中 + whitelist_components = build_indep_whitelist.get('components', []) + if not all(comp in whitelist_components for comp in component_result): + return False, component_result + + # 检查不支持的参数 + unsupported_args = build_indep_whitelist.get('unsupport-args', []) + for arg in input_args_dict: + if arg == 'positional_input_args': + continue + if arg in unsupported_args: + return False, component_result + + # 所有条件都满足 + return True, component_result + + + @staticmethod + def parse_component_name(build_targets): + component_name_list = [] + + # 标准化输入为列表类型 + if isinstance(build_targets, str): + targets = [build_targets] + elif isinstance(build_targets, list): + targets = build_targets + else: + return False # 输入类型无效时返回False + + for build_target in targets: + bundle_rel_path = ArgsResolver.find_deepest_bundle_json(build_target) + if not bundle_rel_path: + print(f"未找到{build_target}对应的bundle.json文件") + return False # 未找到json文件,直接返回False + + bundle_path = os.path.join(CURRENT_OHOS_ROOT, bundle_rel_path) + + try: + bundle_json = IoUtil.read_json_file(bundle_path) + component_name = bundle_json.get("component", {}).get("name") + if component_name: + component_name_list.append(component_name) + else: + print(f"{bundle_path}中未找到component.name配置") + return False # 未找到component.name,直接返回False + except Exception as e: + print(f"读取{bundle_path}失败: {e}") + return False # 读取文件失败,直接返回False + + return component_name_list if component_name_list else False + + + @staticmethod + def find_deepest_bundle_json(build_str): + base_path = build_str.split(':')[0] + deepest_bundle = None + current_path = "" + path_parts = base_path.split(os.sep) + + for part in path_parts: + current_path = os.path.join(current_path, part) + if os.path.isdir(current_path): + bundle_json_path = os.path.join(current_path, 'bundle.json') + if os.path.isfile(bundle_json_path): + deepest_bundle = bundle_json_path + + return deepest_bundle + + @staticmethod + def get_indep_args(sys_argv, component_name_list): + new_args = [] # 保留初始build命令 + i = 0 + added_components = False # 标记组件是否已添加 + added_i = False # 标记-i是否已添加 + + while i < len(sys_argv): + arg = sys_argv[i] + + # 移除--product-name及其值 + if arg == '--product-name': + i += 2 + continue + + # 处理所有--build-target:只添加一次组件列表和-i + elif arg == '--build-target': + # 仅在第一次遇到--build-target时添加组件列表 + if not added_components: + new_args.extend(component_name_list) # 添加['request', 'print_fwk'] + added_components = True + + # 仅添加一次-i + if not added_i: + new_args.append('-i') + added_i = True + + i += 2 # 跳过当前--build-target及其值,不重复添加组件 + continue + + # 保留其他参数 + else: + new_args.append(arg) + i += 1 + return new_args diff --git a/hb/services/indep_build.py b/hb/services/indep_build.py index 6695012e87..7cedbe542e 100644 --- a/hb/services/indep_build.py +++ b/hb/services/indep_build.py @@ -23,6 +23,7 @@ import os from util.log_util import LogUtil import json import shutil +import sys class IndepBuild(BuildFileGeneratorInterface): @@ -34,6 +35,10 @@ class IndepBuild(BuildFileGeneratorInterface): flags_list = self._convert_flags() cmd = ["/bin/bash", "build/indep_configs/build_indep.sh"] cmd.extend(flags_list) + product_name = self._get_product_name() + if product_name != None: + cmd.append("--product-name") + cmd.append(product_name) variant = self.flags_dict["variant"] logpath = os.path.join('out', variant, 'build.log') SystemUtil.exec_command(cmd, log_path=logpath, pre_msg="run indep build", @@ -124,4 +129,13 @@ class IndepBuild(BuildFileGeneratorInterface): relative_path = os.path.relpath(root, local_binarys) dependences_dict[component_name] = { "installPath": "/" + relative_path - } \ No newline at end of file + } + + def _get_product_name(self): + orig_argv = sys.orig_argv + for i in range(len(orig_argv)): + if orig_argv[i] == '--product-name': + if i + 1 < len(orig_argv): + return orig_argv[i + 1] + return None + return None \ No newline at end of file diff --git a/indep_configs/build_indep.sh b/indep_configs/build_indep.sh index 3c36c23258..9e39fc46d7 100755 --- a/indep_configs/build_indep.sh +++ b/indep_configs/build_indep.sh @@ -115,6 +115,20 @@ ${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/variants_info_handler. # gn and ninja command ${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/gn_ninja_cmd.py -rp ${SOURCE_ROOT_DIR} -v ${VARIANTS} -out ${OUT_DIR} -t ${TEST_FILTER} +if [[ "$@" =~ "--product-name" ]]; then + for ((i=1; i<=$#; i++)); do + if [[ "${!i}" == "--product-name" ]]; then + next_index=$((i + 1)) + if [[ $next_index -le $# ]]; then + cp -r out/$VARIANTS/$OUT_DIR out/${!next_index} + exit 0 + fi + fi + done +else + exit 0 +fi + if [ $? -ne 0 ]; then exit 1 fi -- Gitee