|
21 | 21 | "@rules_cc//cc/private/rules_impl:objc_compilation_support.bzl", |
22 | 22 | objc_compilation_support = "compilation_support", |
23 | 23 | ) # buildifier: disable=bzl-visibility |
24 | | -load( |
25 | | - "//apple/internal:cc_toolchain_info_support.bzl", |
26 | | - "cc_toolchain_info_support", |
27 | | -) |
28 | 24 | load( |
29 | 25 | "//apple/internal:compilation_support.bzl", |
30 | 26 | "compilation_support", |
@@ -681,139 +677,8 @@ def _lipo_or_symlink_inputs(*, actions, inputs, output, apple_fragment, xcode_co |
681 | 677 | # Symlink if there was only a single architecture created; it's faster. |
682 | 678 | actions.symlink(target_file = inputs[0], output = output) |
683 | 679 |
|
684 | | -# TODO: Delete when we take https://github.com/bazelbuild/rules_apple/commit/29eb94cbc9b1a898582e1e238cc2551ddbeaa58b |
685 | | -def _legacy_link_multi_arch_binary( |
686 | | - *, |
687 | | - actions, |
688 | | - additional_inputs = [], |
689 | | - cc_toolchains, |
690 | | - ctx, |
691 | | - deps, |
692 | | - disabled_features, |
693 | | - features, |
694 | | - label, |
695 | | - stamp = -1, |
696 | | - user_link_flags = []): |
697 | | - """Experimental Starlark version of multiple architecture binary linking action. |
698 | | -
|
699 | | - This Stalark version is an experimental re-write of the apple_common.link_multi_arch_binary API |
700 | | - with minimal support for linking multiple architecture binaries from split dependencies. |
701 | | -
|
702 | | - Specifically, this lacks support for: |
703 | | - - Generating Apple dSYM binaries. |
704 | | - - Generating Objective-C linkmaps. |
705 | | - - Avoid linking symbols from Objective-C(++) dependencies (i.e. avoid_deps). |
706 | | -
|
707 | | - Args: |
708 | | - actions: The actions provider from `ctx.actions`. |
709 | | - additional_inputs: List of additional `File`s required for the C++ linking action (e.g. |
710 | | - linking scripts). |
711 | | - cc_toolchains: Dictionary of targets (`ctx.split_attr`) containing CcToolchainInfo |
712 | | - providers to use for C++ actions. |
713 | | - ctx: The Starlark context for a rule target being built. |
714 | | - deps: Dictionary of targets (`ctx.split_attr`) referencing dependencies for a given target |
715 | | - to retrieve transitive CcInfo providers for C++ linking action. |
716 | | - disabled_features: List of features to be disabled for C++ actions. |
717 | | - features: List of features to be enabled for C++ actions. |
718 | | - label: Label for the current target (`ctx.label`). |
719 | | - stamp: Boolean to indicate whether to include build information in the linked binary. |
720 | | - If 1, build information is always included. |
721 | | - If 0, the default build information is always excluded. |
722 | | - If -1, uses the default behavior, which may be overridden by the --[no]stamp flag. |
723 | | - This should be set to 0 when generating the executable output for test rules. |
724 | | - user_link_flags: List of `str` user link flags to add to the C++ linking action. |
725 | | - Returns: |
726 | | - A struct containing the following information: |
727 | | - - cc_info: Merged CcInfo providers from each linked binary CcInfo provider. |
728 | | - - output_groups: OutputGroupInfo provider with CcInfo validation artifacts. |
729 | | - - outputs: List of `struct`s containing the linking output information below. |
730 | | - - architecture: The target Apple architecture. |
731 | | - - binary: `File` referencing the linked binary. |
732 | | - - environment: The target Apple environment. |
733 | | - - platform: The target Apple platform/os. |
734 | | - """ |
735 | | - if type(deps) != "dict" or type(cc_toolchains) != "dict": |
736 | | - fail( |
737 | | - "Expected deps and cc_toolchains to be split attributes (dictionaries).\n", |
738 | | - "deps: %s\n" % deps, |
739 | | - "cc_toolchains: %s" % cc_toolchains, |
740 | | - ) |
741 | | - |
742 | | - if deps.keys() != cc_toolchains.keys(): |
743 | | - fail( |
744 | | - "Expected deps and cc_toolchains split attribute keys to match", |
745 | | - "deps: %s\n" % deps.keys(), |
746 | | - "cc_toolchains: %s\n" % cc_toolchains.keys(), |
747 | | - ) |
748 | | - |
749 | | - all_cc_infos = [] |
750 | | - linking_outputs = [] |
751 | | - validation_artifacts = [] |
752 | | - for split_attr_key, cc_toolchain_target in cc_toolchains.items(): |
753 | | - cc_toolchain = cc_toolchain_target[cc_common.CcToolchainInfo] |
754 | | - target_triple = cc_toolchain_info_support.get_apple_clang_triplet(cc_toolchain) |
755 | | - |
756 | | - feature_configuration = cc_common.configure_features( |
757 | | - cc_toolchain = cc_toolchain, |
758 | | - ctx = ctx, |
759 | | - language = "objc", |
760 | | - requested_features = features, |
761 | | - unsupported_features = disabled_features, |
762 | | - ) |
763 | | - |
764 | | - cc_infos = [ |
765 | | - dep[CcInfo] |
766 | | - for dep in deps[split_attr_key] |
767 | | - if CcInfo in dep |
768 | | - ] |
769 | | - all_cc_infos.extend(cc_infos) |
770 | | - |
771 | | - cc_linking_contexts = [cc_info.linking_context for cc_info in cc_infos] |
772 | | - output_name = "{label}_{os}_{architecture}_bin".format( |
773 | | - architecture = target_triple.architecture, |
774 | | - label = label.name, |
775 | | - os = target_triple.os, |
776 | | - ) |
777 | | - linking_output = cc_common.link( |
778 | | - actions = actions, |
779 | | - additional_inputs = additional_inputs, |
780 | | - cc_toolchain = cc_toolchain, |
781 | | - feature_configuration = feature_configuration, |
782 | | - linking_contexts = cc_linking_contexts, |
783 | | - name = output_name, |
784 | | - stamp = stamp, |
785 | | - user_link_flags = user_link_flags, |
786 | | - ) |
787 | | - |
788 | | - validation_artifacts.extend([ |
789 | | - cc_info.compilation_context.validation_artifacts |
790 | | - for cc_info in cc_infos |
791 | | - ]) |
792 | | - |
793 | | - linking_outputs.append( |
794 | | - struct( |
795 | | - architecture = target_triple.architecture, |
796 | | - binary = linking_output.executable, |
797 | | - environment = target_triple.environment, |
798 | | - platform = target_triple.os, |
799 | | - ), |
800 | | - ) |
801 | | - |
802 | | - return struct( |
803 | | - cc_info = cc_common.merge_cc_infos( |
804 | | - cc_infos = all_cc_infos, |
805 | | - ), |
806 | | - output_groups = { |
807 | | - "_validation": depset( |
808 | | - transitive = validation_artifacts, |
809 | | - ), |
810 | | - }, |
811 | | - outputs = linking_outputs, |
812 | | - ) |
813 | | - |
814 | 680 | linking_support = struct( |
815 | 681 | debug_outputs_by_architecture = _debug_outputs_by_architecture, |
816 | | - legacy_link_multi_arch_binary = _legacy_link_multi_arch_binary, |
817 | 682 | link_multi_arch_binary = _link_multi_arch_binary, |
818 | 683 | lipo_or_symlink_inputs = _lipo_or_symlink_inputs, |
819 | 684 | register_binary_linking_action = _register_binary_linking_action, |
|
0 commit comments