@@ -100,6 +100,7 @@ load(
100100 "new_iosframeworkbundleinfo" ,
101101 "new_iosimessageapplicationbundleinfo" ,
102102 "new_iosimessageextensionbundleinfo" ,
103+ "new_ioskernelextensionbundleinfo" ,
103104 "new_iosstaticframeworkbundleinfo" ,
104105)
105106load (
@@ -2569,6 +2570,225 @@ def _ios_sticker_pack_extension_impl(ctx):
25692570 OutputGroupInfo (** processor_result .output_groups ),
25702571 ] + processor_result .providers
25712572
2573+ def _ios_kernel_extension_impl (ctx ):
2574+ """Implementation of ios_kernel_extension."""
2575+ rule_descriptor = rule_support .rule_descriptor (
2576+ platform_type = "ios" ,
2577+ product_type = apple_product_type .kernel_extension ,
2578+ )
2579+
2580+ actions = ctx .actions
2581+ apple_mac_toolchain_info = ctx .attr ._mac_toolchain [AppleMacToolsToolchainInfo ]
2582+ apple_xplat_toolchain_info = ctx .attr ._xplat_toolchain [AppleXPlatToolsToolchainInfo ]
2583+ bundle_name , bundle_extension = bundling_support .bundle_full_name (
2584+ custom_bundle_name = ctx .attr .bundle_name ,
2585+ label_name = ctx .label .name ,
2586+ rule_descriptor = rule_descriptor ,
2587+ )
2588+ bundle_id = bundling_support .bundle_full_id (
2589+ bundle_id = ctx .attr .bundle_id ,
2590+ bundle_id_suffix = ctx .attr .bundle_id_suffix ,
2591+ bundle_name = bundle_name ,
2592+ suffix_default = ctx .attr ._bundle_id_suffix_default ,
2593+ shared_capabilities = ctx .attr .shared_capabilities ,
2594+ )
2595+ cc_toolchain_forwarder = ctx .split_attr ._cc_toolchain_forwarder
2596+ executable_name = ctx .attr .executable_name
2597+ features = features_support .compute_enabled_features (
2598+ requested_features = ctx .features ,
2599+ unsupported_features = ctx .disabled_features ,
2600+ )
2601+ label = ctx .label
2602+ platform_prerequisites = platform_support .platform_prerequisites (
2603+ apple_fragment = ctx .fragments .apple ,
2604+ apple_platform_info = platform_support .apple_platform_info_from_rule_ctx (ctx ),
2605+ build_settings = apple_xplat_toolchain_info .build_settings ,
2606+ config_vars = ctx .var ,
2607+ cpp_fragment = ctx .fragments .cpp ,
2608+ device_families = ctx .attr .families ,
2609+ explicit_minimum_deployment_os = ctx .attr .minimum_deployment_os_version ,
2610+ explicit_minimum_os = ctx .attr .minimum_os_version ,
2611+ features = features ,
2612+ objc_fragment = ctx .fragments .objc ,
2613+ uses_swift = swift_support .uses_swift (ctx .attr .deps ),
2614+ xcode_version_config = ctx .attr ._xcode_config [apple_common .XcodeVersionConfig ],
2615+ )
2616+ predeclared_outputs = ctx .outputs
2617+ provisioning_profile = ctx .file .provisioning_profile
2618+ resource_deps = ctx .attr .deps + ctx .attr .resources
2619+ top_level_infoplists = resources .collect (
2620+ attr = ctx .attr ,
2621+ res_attrs = ["infoplists" ],
2622+ )
2623+ top_level_resources = resources .collect (
2624+ attr = ctx .attr ,
2625+ res_attrs = ["resources" ],
2626+ )
2627+
2628+ entitlements = entitlements_support .process_entitlements (
2629+ actions = actions ,
2630+ apple_mac_toolchain_info = apple_mac_toolchain_info ,
2631+ bundle_id = bundle_id ,
2632+ entitlements_file = ctx .file .entitlements ,
2633+ platform_prerequisites = platform_prerequisites ,
2634+ product_type = rule_descriptor .product_type ,
2635+ provisioning_profile = provisioning_profile ,
2636+ rule_label = label ,
2637+ validation_mode = ctx .attr .entitlements_validation ,
2638+ )
2639+
2640+ # This was added for b/122473338, and should be removed eventually once symbol stripping is
2641+ # better-handled. It's redundant with an option added in the CROSSTOOL for the
2642+ # "kernel_extension" feature, but for now it's necessary to detect kext linking so
2643+ # CompilationSupport.java can apply the correct type of symbol stripping.
2644+ extra_linkopts = [
2645+ "-Wl,-kext" ,
2646+ ]
2647+
2648+ link_result = linking_support .register_binary_linking_action (
2649+ ctx ,
2650+ cc_toolchains = cc_toolchain_forwarder ,
2651+ entitlements = entitlements .linking ,
2652+ exported_symbols_lists = ctx .files .exported_symbols_lists ,
2653+ extra_linkopts = extra_linkopts ,
2654+ extra_requested_features = ["kernel_extension" ],
2655+ platform_prerequisites = platform_prerequisites ,
2656+ rule_descriptor = rule_descriptor ,
2657+ stamp = ctx .attr .stamp ,
2658+ )
2659+ binary_artifact = link_result .binary
2660+ debug_outputs = linking_support .debug_outputs_by_architecture (link_result .outputs )
2661+
2662+ processor_partials = [
2663+ partials .apple_bundle_info_partial (
2664+ actions = actions ,
2665+ bundle_extension = bundle_extension ,
2666+ bundle_id = bundle_id ,
2667+ bundle_name = bundle_name ,
2668+ executable_name = executable_name ,
2669+ entitlements = entitlements .bundle ,
2670+ label_name = label .name ,
2671+ platform_prerequisites = platform_prerequisites ,
2672+ predeclared_outputs = predeclared_outputs ,
2673+ product_type = rule_descriptor .product_type ,
2674+ rule_descriptor = rule_descriptor ,
2675+ ),
2676+ partials .binary_partial (
2677+ actions = actions ,
2678+ binary_artifact = binary_artifact ,
2679+ bundle_name = bundle_name ,
2680+ executable_name = executable_name ,
2681+ label_name = label .name ,
2682+ ),
2683+ partials .codesigning_dossier_partial (
2684+ actions = actions ,
2685+ apple_mac_toolchain_info = apple_mac_toolchain_info ,
2686+ apple_xplat_toolchain_info = apple_xplat_toolchain_info ,
2687+ bundle_extension = bundle_extension ,
2688+ bundle_name = bundle_name ,
2689+ entitlements = entitlements .codesigning ,
2690+ label_name = label .name ,
2691+ platform_prerequisites = platform_prerequisites ,
2692+ predeclared_outputs = predeclared_outputs ,
2693+ provisioning_profile = provisioning_profile ,
2694+ rule_descriptor = rule_descriptor ,
2695+ ),
2696+ partials .debug_symbols_partial (
2697+ actions = actions ,
2698+ bundle_extension = bundle_extension ,
2699+ bundle_name = bundle_name ,
2700+ debug_dependencies = ctx .attr .deps ,
2701+ dsym_binaries = debug_outputs .dsym_binaries ,
2702+ dsym_info_plist_template = apple_mac_toolchain_info .dsym_info_plist_template ,
2703+ executable_name = executable_name ,
2704+ label_name = label .name ,
2705+ linkmaps = debug_outputs .linkmaps ,
2706+ platform_prerequisites = platform_prerequisites ,
2707+ plisttool = apple_mac_toolchain_info .plisttool ,
2708+ rule_label = label ,
2709+ version = ctx .attr .version ,
2710+ ),
2711+ partials .resources_partial (
2712+ actions = actions ,
2713+ apple_mac_toolchain_info = apple_mac_toolchain_info ,
2714+ bundle_extension = bundle_extension ,
2715+ bundle_id = bundle_id ,
2716+ bundle_name = bundle_name ,
2717+ executable_name = executable_name ,
2718+ environment_plist = ctx .file ._environment_plist ,
2719+ launch_storyboard = None ,
2720+ platform_prerequisites = platform_prerequisites ,
2721+ resource_deps = resource_deps ,
2722+ rule_descriptor = rule_descriptor ,
2723+ rule_label = label ,
2724+ top_level_infoplists = top_level_infoplists ,
2725+ top_level_resources = top_level_resources ,
2726+ version = ctx .attr .version ,
2727+ ),
2728+ partials .swift_dylibs_partial (
2729+ actions = actions ,
2730+ apple_mac_toolchain_info = apple_mac_toolchain_info ,
2731+ binary_artifact = binary_artifact ,
2732+ label_name = label .name ,
2733+ platform_prerequisites = platform_prerequisites ,
2734+ ),
2735+ partials .apple_symbols_file_partial (
2736+ actions = actions ,
2737+ binary_artifact = binary_artifact ,
2738+ dependency_targets = [],
2739+ dsym_binaries = debug_outputs .dsym_binaries ,
2740+ label_name = label .name ,
2741+ include_symbols_in_bundle = False ,
2742+ platform_prerequisites = platform_prerequisites ,
2743+ ),
2744+ ]
2745+
2746+ if platform_prerequisites .platform .is_device :
2747+ processor_partials .append (
2748+ partials .provisioning_profile_partial (
2749+ actions = actions ,
2750+ profile_artifact = provisioning_profile ,
2751+ rule_label = label ,
2752+ ),
2753+ )
2754+
2755+ processor_result = processor .process (
2756+ actions = actions ,
2757+ apple_mac_toolchain_info = apple_mac_toolchain_info ,
2758+ apple_xplat_toolchain_info = apple_xplat_toolchain_info ,
2759+ bundle_extension = bundle_extension ,
2760+ bundle_name = bundle_name ,
2761+ entitlements = entitlements .codesigning ,
2762+ features = features ,
2763+ ipa_post_processor = ctx .executable .ipa_post_processor ,
2764+ partials = processor_partials ,
2765+ platform_prerequisites = platform_prerequisites ,
2766+ predeclared_outputs = predeclared_outputs ,
2767+ process_and_sign_template = apple_mac_toolchain_info .process_and_sign_template ,
2768+ provisioning_profile = provisioning_profile ,
2769+ rule_descriptor = rule_descriptor ,
2770+ rule_label = label ,
2771+ )
2772+
2773+ return [
2774+ DefaultInfo (
2775+ files = processor_result .output_files ,
2776+ ),
2777+ OutputGroupInfo (
2778+ ** outputs .merge_output_groups (
2779+ link_result .output_groups ,
2780+ processor_result .output_groups ,
2781+ )
2782+ ),
2783+ new_appleexecutablebinaryinfo (
2784+ binary = binary_artifact ,
2785+ cc_info = link_result .cc_info ,
2786+ ),
2787+ new_ioskernelextensionbundleinfo (),
2788+ # TODO(b/228856372): Remove when downstream users are migrated off this provider.
2789+ link_result .debug_outputs_provider ,
2790+ ] + processor_result .providers
2791+
25722792ios_application = rule_factory .create_apple_rule (
25732793 doc = "Builds and bundles an iOS Application." ,
25742794 implementation = _ios_application_impl ,
@@ -3199,3 +3419,37 @@ for the stickers should all be in Sticker Pack directories, so `*.stickerpack/*.
31993419 },
32003420 ],
32013421)
3422+
3423+ ios_kernel_extension = rule_factory .create_apple_rule (
3424+ cfg = transition_support .apple_rule_arm64_as_arm64e_transition ,
3425+ doc = "Builds and bundles an iOS Kernel Extension." ,
3426+ implementation = _ios_kernel_extension_impl ,
3427+ predeclared_outputs = {"archive" : "%{name}.zip" },
3428+ attrs = [
3429+ apple_support .platform_constraint_attrs (),
3430+ rule_attrs .binary_linking_attrs (
3431+ deps_cfg = transition_support .apple_platform_split_transition ,
3432+ extra_deps_aspects = [
3433+ apple_resource_aspect ,
3434+ framework_provider_aspect ,
3435+ ],
3436+ is_test_supporting_rule = False ,
3437+ requires_legacy_cc_toolchain = True ,
3438+ ),
3439+ rule_attrs .common_bundle_attrs (
3440+ deps_cfg = transition_support .apple_platform_split_transition ,
3441+ ),
3442+ rule_attrs .common_tool_attrs (),
3443+ rule_attrs .device_family_attrs (
3444+ allowed_families = rule_attrs .defaults .allowed_families .ios ,
3445+ is_mandatory = False ,
3446+ ),
3447+ rule_attrs .infoplist_attrs (),
3448+ rule_attrs .ipa_post_processor_attrs (),
3449+ rule_attrs .platform_attrs (
3450+ add_environment_plist = True ,
3451+ platform_type = "ios" ,
3452+ ),
3453+ rule_attrs .signing_attrs (),
3454+ ],
3455+ )
0 commit comments