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