diff --git a/.bazelrc b/.bazelrc index c7c023f77c..12fefa22ac 100644 --- a/.bazelrc +++ b/.bazelrc @@ -21,6 +21,12 @@ build --nocheck_visibility # dependencies cause us to use a newer version build --check_direct_dependencies=off +# This is needed for Bazel 6 compatibility. +# It's enabled (and can't be disabled) in Bazel 7. +# TODO: Remove this once we drop Bazel 6 support. +# See also: https://github.com/bazelbuild/bazel/issues/14327 +build --experimental_enable_aspect_hints + # Disable the worker, which has sandboxing disabled by default, which can hide # issues with non-hermetic bugs. build --spawn_strategy=sandboxed,local diff --git a/.github/generate-notes.sh b/.github/generate-notes.sh index 2cebc1bf58..38df1c8491 100755 --- a/.github/generate-notes.sh +++ b/.github/generate-notes.sh @@ -14,13 +14,13 @@ TODO This release is compatible with: TODO -### MODULE.bazel Snippet +## MODULE.bazel Snippet \`\`\`bzl bazel_dep(name = "rules_apple", version = "$new_version", repo_name = "build_bazel_rules_apple") \`\`\` -### Workspace Snippet +## Workspace Snippet \`\`\`bzl load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") diff --git a/MODULE.bazel b/MODULE.bazel index fb7ea26390..111321561a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,10 +6,15 @@ module( repo_name = "build_bazel_rules_apple", ) -bazel_dep(name = "apple_support", version = "1.14.0", repo_name = "build_bazel_apple_support") +bazel_dep(name = "apple_support", version = "1.15.1", repo_name = "build_bazel_apple_support") bazel_dep(name = "bazel_skylib", version = "1.3.0") -bazel_dep(name = "platforms", version = "0.0.7") -bazel_dep(name = "rules_swift", version = "1.17.0", repo_name = "build_bazel_rules_swift") +bazel_dep(name = "platforms", version = "0.0.9") +bazel_dep( + name = "rules_swift", + version = "1.18.0", + max_compatibility_level = 2, + repo_name = "build_bazel_rules_swift", +) bazel_dep( name = "stardoc", diff --git a/apple/internal/BUILD b/apple/internal/BUILD index 5ef390f8fc..15e1b3a8a5 100644 --- a/apple/internal/BUILD +++ b/apple/internal/BUILD @@ -424,6 +424,7 @@ bzl_library( "//apple/internal/partials:apple_bundle_info", "//apple/internal/partials:apple_symbols_file", "//apple/internal/partials:binary", + "//apple/internal/partials:cc_info_dylibs", "//apple/internal/partials:clang_rt_dylibs", "//apple/internal/partials:codesigning_dossier", "//apple/internal/partials:debug_symbols", diff --git a/apple/internal/apple_toolchains.bzl b/apple/internal/apple_toolchains.bzl index dfc6aa44e1..651f8d33ed 100644 --- a/apple/internal/apple_toolchains.bzl +++ b/apple/internal/apple_toolchains.bzl @@ -33,57 +33,57 @@ A `File` referencing a plist template for dSYM bundles. "process_and_sign_template": """\ A `File` referencing a template for a shell script to process and sign. """, - "resolved_alticonstool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to insert alternate icons entries in the app + "alticonstool": """\ +The files_to_run for a tool to insert alternate icons entries in the app bundle's `Info.plist`. """, - "resolved_bundletool_experimental": """\ -A `struct` from `ctx.resolve_tools` referencing an experimental tool to create an Apple bundle by + "bundletool_experimental": """\ +The files_to_run for an experimental tool to create an Apple bundle by combining the bundling, post-processing, and signing steps into a single action that eliminates the archiving step. """, - "resolved_clangrttool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to find all Clang runtime libs linked to a + "clangrttool": """\ +The files_to_run for a tool to find all Clang runtime libs linked to a binary. """, - "resolved_codesigningtool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to select the appropriate signing identity + "codesigningtool": """\ +The files_to_run for a tool to select the appropriate signing identity for Apple apps and Apple executable bundles. """, - "resolved_dossier_codesigningtool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to generate codesigning dossiers. + "dossier_codesigningtool": """\ +The files_to_run for a tool to generate codesigning dossiers. """, - "resolved_environment_plist_tool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool for collecting dev environment values. + "environment_plist_tool": """\ +The files_to_run for a tool for collecting dev environment values. """, - "resolved_imported_dynamic_framework_processor": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to process an imported dynamic framework + "imported_dynamic_framework_processor": """\ +The files_to_run for a tool to process an imported dynamic framework such that the given framework only contains the same slices as the app binary, every file belonging to the dynamic framework is copied to a temporary location, and the dynamic framework is codesigned and zipped as a cacheable artifact. """, - "resolved_main_thread_checker_tool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to find libMainThreadChecker.dylib linked to a + "main_thread_checker_tool": """\ +The files_to_run for a tool to find libMainThreadChecker.dylib linked to a binary. """, - "resolved_plisttool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to perform plist operations such as variable + "plisttool": """\ +The files_to_run for a tool to perform plist operations such as variable substitution, merging, and conversion of plist files to binary format. """, - "resolved_provisioning_profile_tool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool that extracts entitlements from a + "provisioning_profile_tool": """\ +The files_to_run for a tool that extracts entitlements from a provisioning profile. """, - "resolved_swift_stdlib_tool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool that copies and lipos Swift stdlibs required + "swift_stdlib_tool": """\ +The files_to_run for a tool that copies and lipos Swift stdlibs required for the target to run. """, - "resolved_xcframework_processor_tool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool that extracts and copies an XCFramework + "xcframework_processor_tool": """\ +The files_to_run for a tool that extracts and copies an XCFramework library for a target triplet. """, - "resolved_xctoolrunner": """\ -A `struct` from `ctx.resolve_tools` referencing a tool that acts as a wrapper for xcrun actions. + "xctoolrunner": """\ +The files_to_run for a tool that acts as a wrapper for xcrun actions. """, }, ) @@ -106,12 +106,12 @@ target name and values are retrieved from the BuildSettingInfo provider for each e.g. apple_xplat_tools_toolchaininfo.build_settings.signing_certificate_name """, - "resolved_bundletool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool to create an Apple bundle by taking a list of + "bundletool": """\ +A files_to_run for a tool to create an Apple bundle by taking a list of files/ZIPs and destinations paths to build the directory structure for those files. """, - "resolved_versiontool": """\ -A `struct` from `ctx.resolve_tools` referencing a tool that acts as a wrapper for xcrun actions. + "versiontool": """\ +A files_to_run for a tool that acts as a wrapper for xcrun actions. """, }, ) @@ -131,79 +131,24 @@ def _shared_attrs(): ), } -def _resolve_tools_for_executable(*, rule_ctx, attr_name): - """Helper macro to resolve executable runfile dependencies across the rule boundary.""" - - # TODO(b/111036105) Migrate away from this helper and its outputs once ctx.executable works - # across rule boundaries. - executable = getattr(rule_ctx.executable, attr_name) - target = getattr(rule_ctx.attr, attr_name) - files_to_run = target[DefaultInfo].files_to_run - inputs, input_manifests = rule_ctx.resolve_tools(tools = [target]) - return struct( - executable = executable, - files_to_run = files_to_run, - inputs = inputs, - input_manifests = input_manifests, - ) - def _apple_mac_tools_toolchain_impl(ctx): return [ AppleMacToolsToolchainInfo( dsym_info_plist_template = ctx.file.dsym_info_plist_template, process_and_sign_template = ctx.file.process_and_sign_template, - resolved_alticonstool = _resolve_tools_for_executable( - attr_name = "alticonstool", - rule_ctx = ctx, - ), - resolved_bundletool_experimental = _resolve_tools_for_executable( - attr_name = "bundletool_experimental", - rule_ctx = ctx, - ), - resolved_codesigningtool = _resolve_tools_for_executable( - attr_name = "codesigningtool", - rule_ctx = ctx, - ), - resolved_dossier_codesigningtool = _resolve_tools_for_executable( - attr_name = "dossier_codesigningtool", - rule_ctx = ctx, - ), - resolved_clangrttool = _resolve_tools_for_executable( - attr_name = "clangrttool", - rule_ctx = ctx, - ), - resolved_main_thread_checker_tool = _resolve_tools_for_executable( - attr_name = "main_thread_checker_tool", - rule_ctx = ctx, - ), - resolved_environment_plist_tool = _resolve_tools_for_executable( - attr_name = "environment_plist_tool", - rule_ctx = ctx, - ), - resolved_imported_dynamic_framework_processor = _resolve_tools_for_executable( - attr_name = "imported_dynamic_framework_processor", - rule_ctx = ctx, - ), - resolved_plisttool = _resolve_tools_for_executable( - attr_name = "plisttool", - rule_ctx = ctx, - ), - resolved_provisioning_profile_tool = _resolve_tools_for_executable( - attr_name = "provisioning_profile_tool", - rule_ctx = ctx, - ), - resolved_swift_stdlib_tool = _resolve_tools_for_executable( - attr_name = "swift_stdlib_tool", - rule_ctx = ctx, - ), - resolved_xcframework_processor_tool = _resolve_tools_for_executable( - attr_name = "xcframework_processor_tool", - rule_ctx = ctx, - ), - resolved_xctoolrunner = _resolve_tools_for_executable( - attr_name = "xctoolrunner", - rule_ctx = ctx, - ), + alticonstool = ctx.attr.alticonstool.files_to_run, + bundletool_experimental = ctx.attr.bundletool_experimental.files_to_run, + codesigningtool = ctx.attr.codesigningtool.files_to_run, + dossier_codesigningtool = ctx.attr.dossier_codesigningtool.files_to_run, + clangrttool = ctx.attr.clangrttool.files_to_run, + main_thread_checker_tool = ctx.attr.main_thread_checker_tool.files_to_run, + environment_plist_tool = ctx.attr.environment_plist_tool.files_to_run, + imported_dynamic_framework_processor = ctx.attr.imported_dynamic_framework_processor.files_to_run, + plisttool = ctx.attr.plisttool.files_to_run, + provisioning_profile_tool = ctx.attr.provisioning_profile_tool.files_to_run, + swift_stdlib_tool = ctx.attr.swift_stdlib_tool.files_to_run, + xcframework_processor_tool = ctx.attr.xcframework_processor_tool.files_to_run, + xctoolrunner = ctx.attr.xctoolrunner.files_to_run, ), DefaultInfo(), ] @@ -321,14 +266,8 @@ def _apple_xplat_tools_toolchain_impl(ctx): for build_setting in ctx.attr.build_settings } ), - resolved_bundletool = _resolve_tools_for_executable( - attr_name = "bundletool", - rule_ctx = ctx, - ), - resolved_versiontool = _resolve_tools_for_executable( - attr_name = "versiontool", - rule_ctx = ctx, - ), + bundletool = ctx.attr.bundletool.files_to_run, + versiontool = ctx.attr.versiontool.files_to_run, ), DefaultInfo(), ] diff --git a/apple/internal/apple_xcframework_import.bzl b/apple/internal/apple_xcframework_import.bzl index b9466c5593..e277994575 100644 --- a/apple/internal/apple_xcframework_import.bzl +++ b/apple/internal/apple_xcframework_import.bzl @@ -347,18 +347,14 @@ def _get_xcframework_library_with_xcframework_processor( ) outputs.append(swiftinterface_file) - xcframework_processor_tool = apple_mac_toolchain_info.resolved_xcframework_processor_tool + xcframework_processor_tool = apple_mac_toolchain_info.xcframework_processor_tool apple_support.run( actions = actions, apple_fragment = apple_fragment, arguments = [args], - executable = xcframework_processor_tool.files_to_run, - inputs = depset( - inputs, - transitive = [xcframework_processor_tool.inputs], - ), - input_manifests = xcframework_processor_tool.input_manifests, + executable = xcframework_processor_tool, + inputs = inputs, mnemonic = "ProcessXCFrameworkFiles", outputs = outputs, xcode_config = xcode_config, diff --git a/apple/internal/aspects/docc_archive_aspect.bzl b/apple/internal/aspects/docc_archive_aspect.bzl index cfeaa0ff7d..dcc63d4a18 100644 --- a/apple/internal/aspects/docc_archive_aspect.bzl +++ b/apple/internal/aspects/docc_archive_aspect.bzl @@ -79,7 +79,7 @@ def _docc_bundle_info_aspect_impl(target, ctx): first_docc_bundle = _first_docc_bundle(target, ctx) if first_docc_bundle: return [DocCBundleInfo(bundle = first_docc_bundle)] - elif hasattr(ctx.rule.attr, "deps"): + if hasattr(ctx.rule.attr, "deps"): # If this target has "deps", try to find a DocCBundleInfo provider in its deps. for dep in ctx.rule.attr.deps: if DocCBundleInfo in dep: diff --git a/apple/internal/codesigning_support.bzl b/apple/internal/codesigning_support.bzl index b6806a1f03..e825f7e93b 100644 --- a/apple/internal/codesigning_support.bzl +++ b/apple/internal/codesigning_support.bzl @@ -480,28 +480,28 @@ def _codesigning_command( def _generate_codesigning_dossier_action( actions, label_name, - resolved_codesigning_dossier_tool, + dossier_codesigningtool, + embedded_dossiers, + entitlements, output_discriminator, output_dossier, platform_prerequisites, - embedded_dossiers = [], - entitlements = None, - provisioning_profile = None): + provisioning_profile): """Generates a codesigning dossier based on parameters. Args: actions: The actions provider from `ctx.actions`. + label_name: Name of the target being built. + dossier_codesigningtool: The files_to_run for the code signing tool. embedded_dossiers: An optional List of Structs generated from `embedded_codesigning_dossier` that should also be included in this dossier. entitlements: Optional file representing the entitlements to sign with. - label_name: Name of the target being built. output_discriminator: A string to differentiate between different target intermediate files or `None`. output_dossier: The `File` representing the output dossier file - the zipped dossier will be placed here. platform_prerequisites: Struct containing information on the platform being targeted. provisioning_profile: The provisioning profile file. May be `None`. - resolved_codesigning_dossier_tool: The `struct` from resolve_tools representing the code signing tool. """ input_files = [x.dossier_file for x in embedded_dossiers] @@ -571,14 +571,12 @@ def _generate_codesigning_dossier_action( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = args, - executable = resolved_codesigning_dossier_tool.files_to_run, + executable = dossier_codesigningtool, execution_requirements = execution_requirements, - inputs = depset(input_files, transitive = [resolved_codesigning_dossier_tool.inputs]), - input_manifests = resolved_codesigning_dossier_tool.input_manifests, + inputs = input_files, mnemonic = mnemonic, outputs = [output_dossier], progress_message = progress_message, - tools = [resolved_codesigning_dossier_tool.executable], xcode_config = platform_prerequisites.xcode_version_config, ) @@ -587,6 +585,7 @@ def _post_process_and_sign_archive_action( actions, archive_codesigning_path, codesign_inputs, + codesigningtool, codesignopts, entitlements = None, features, @@ -600,7 +599,6 @@ def _post_process_and_sign_archive_action( platform_prerequisites, process_and_sign_template, provisioning_profile, - resolved_codesigningtool, rule_descriptor, signed_frameworks): """Post-processes and signs an archived bundle. @@ -609,6 +607,7 @@ def _post_process_and_sign_archive_action( actions: The actions provider from `ctx.actions`. archive_codesigning_path: The codesigning path relative to the archive. codesign_inputs: Extra inputs needed for the `codesign` tool. + codesigningtool: The files_to_run for the code signing tool. codesignopts: Extra options to pass to the `codesign` tool. entitlements: Optional file representing the entitlements to sign with. features: List of features enabled by the user. Typically from `ctx.features`. @@ -625,7 +624,6 @@ def _post_process_and_sign_archive_action( platform_prerequisites: Struct containing information on the platform being targeted. process_and_sign_template: A template for a shell script to process and sign as a file. provisioning_profile: The provisioning profile file. May be `None`. - resolved_codesigningtool: The `struct` from resolve_tools representing the code signing tool. rule_descriptor: A rule descriptor for platform and product types from the rule context. signed_frameworks: Depset containing each framework that has already been signed. """ @@ -640,7 +638,7 @@ def _post_process_and_sign_archive_action( signing_command_lines = _codesigning_command( bundle_path = archive_codesigning_path, - codesigningtool = resolved_codesigningtool.executable, + codesigningtool = codesigningtool.executable, codesignopts = codesignopts, entitlements = entitlements, features = features, @@ -651,7 +649,7 @@ def _post_process_and_sign_archive_action( signed_frameworks = signed_frameworks, ) if signing_command_lines: - processing_tools.append(resolved_codesigningtool.executable) + processing_tools.append(codesigningtool) if entitlements: input_files.append(entitlements) if provisioning_profile: @@ -735,11 +733,7 @@ def _post_process_and_sign_archive_action( arguments = arguments, executable = process_and_sign_expanded_template, execution_requirements = execution_requirements, - inputs = depset( - input_files + codesign_inputs, - transitive = [resolved_codesigningtool.inputs], - ), - input_manifests = resolved_codesigningtool.input_manifests, + inputs = input_files + codesign_inputs, mnemonic = mnemonic, outputs = [output_archive], progress_message = progress_message, @@ -760,24 +754,24 @@ def _sign_binary_action( *, actions, codesign_inputs, + codesigningtool, codesignopts, input_binary, output_binary, platform_prerequisites, provisioning_profile, - resolved_codesigningtool, rule_descriptor): """Signs the input binary file, copying it into the given output binary file. Args: actions: The actions provider from `ctx.actions`. codesign_inputs: Extra inputs needed for the `codesign` tool. + codesigningtool: The files_to_run for the code signing tool. codesignopts: Extra options to pass to the `codesign` tool. input_binary: The `File` representing the binary to be signed. output_binary: The `File` representing signed binary. platform_prerequisites: Struct containing information on the platform being targeted. provisioning_profile: The provisioning profile file. May be `None`. - resolved_codesigningtool: The `struct` from resolve_tools representing the code signing tool. rule_descriptor: A rule descriptor for platform and product types from the rule context. """ _validate_provisioning_profile( @@ -791,7 +785,7 @@ def _sign_binary_action( # code signing commands on that copy in the same action. path_to_sign = _path_to_sign(path = output_binary.path) signing_commands = _signing_command_lines( - codesigningtool = resolved_codesigningtool.executable, + codesigningtool = codesigningtool.executable, entitlements_file = None, paths_to_sign = [path_to_sign], platform_prerequisites = platform_prerequisites, @@ -818,14 +812,10 @@ def _sign_binary_action( output_binary = output_binary.path, ) + "\n" + signing_commands, execution_requirements = execution_requirements, - inputs = depset( - [input_binary] + codesign_inputs, - transitive = [resolved_codesigningtool.inputs], - ), - input_manifests = resolved_codesigningtool.input_manifests, + inputs = [input_binary] + codesign_inputs, mnemonic = "SignBinary", outputs = [output_binary], - tools = [resolved_codesigningtool.executable], + tools = [codesigningtool], xcode_config = platform_prerequisites.xcode_version_config, ) diff --git a/apple/internal/docc.bzl b/apple/internal/docc.bzl index 06f91a913a..022ce209d2 100644 --- a/apple/internal/docc.bzl +++ b/apple/internal/docc.bzl @@ -48,6 +48,7 @@ def _docc_archive_impl(ctx): fallback_bundle_identifier = ctx.attr.fallback_bundle_identifier fallback_bundle_version = ctx.attr.fallback_bundle_version fallback_display_name = ctx.attr.fallback_display_name + hosting_base_path = ctx.attr.hosting_base_path kinds = ctx.attr.kinds platform = ctx.fragments.apple.single_arch_platform transform_for_static_hosting = ctx.attr.transform_for_static_hosting @@ -91,6 +92,8 @@ def _docc_archive_impl(ctx): arguments.add_all("--kind", kinds) if transform_for_static_hosting: arguments.add("--transform-for-static-hosting") + if hosting_base_path: + arguments.add("--hosting-base-path", hosting_base_path) # Add symbol graphs if symbol_graphs_info: @@ -225,6 +228,10 @@ Must be one of "error", "warning", "information", or "hint" doc = "A fallback display name if no value is provided in the documentation bundle's Info.plist file.", mandatory = True, ), + "hosting_base_path": attr.string( + doc = "The base path your documentation website will be hosted at. For example, to deploy your site to 'example.com/my_name/my_project/documentation' instead of 'example.com/documentation', pass '/my_name/my_project' as the base path.", + mandatory = False, + ), "kinds": attr.string_list( doc = "The kinds of entities to filter generated documentation for.", ), diff --git a/apple/internal/entitlements_support.bzl b/apple/internal/entitlements_support.bzl index cffb359aee..cf3e7ef972 100644 --- a/apple/internal/entitlements_support.bzl +++ b/apple/internal/entitlements_support.bzl @@ -121,7 +121,7 @@ def _extract_signing_info( entitlements, platform_prerequisites, provisioning_profile, - resolved_provisioning_profile_tool, + provisioning_profile_tool, rule_label): """Inspects the current context and extracts the signing information. @@ -130,7 +130,8 @@ def _extract_signing_info( entitlements: The entitlements file to sign with. Can be `None` if one was not provided. platform_prerequisites: Struct containing information on the platform being targeted. provisioning_profile: File for the provisioning profile. - resolved_provisioning_profile_tool: A tool used to extract info from a provisioning profile. + provisioning_profile_tool: A files_to_run for a tool used to extract info from a provisioning + profile. rule_label: The label of the target being analyzed. Returns: @@ -175,15 +176,11 @@ def _extract_signing_info( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = [control_file.path], - executable = resolved_provisioning_profile_tool.files_to_run, + executable = provisioning_profile_tool, # Since the tools spawns openssl and/or security tool, it doesn't # support being sandboxed. execution_requirements = {"no-sandbox": "1"}, - inputs = depset( - [control_file, provisioning_profile], - transitive = [resolved_provisioning_profile_tool.inputs], - ), - input_manifests = resolved_provisioning_profile_tool.input_manifests, + inputs = [control_file, provisioning_profile], mnemonic = "ExtractFromProvisioningProfile", outputs = outputs, xcode_config = platform_prerequisites.xcode_version_config, @@ -253,9 +250,7 @@ def _process_entitlements( entitlements = entitlements_file, platform_prerequisites = platform_prerequisites, provisioning_profile = provisioning_profile, - resolved_provisioning_profile_tool = ( - apple_mac_toolchain_info.resolved_provisioning_profile_tool - ), + provisioning_profile_tool = apple_mac_toolchain_info.provisioning_profile_tool, rule_label = rule_label, ) plists = [] @@ -315,7 +310,7 @@ def _process_entitlements( mnemonic = "ProcessEntitlementsFiles", outputs = [final_entitlements], platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, ) if platform_prerequisites.platform.is_device: @@ -354,7 +349,7 @@ def _process_entitlements( mnemonic = "ProcessSimulatorEntitlementsFile", outputs = [simulator_entitlements], platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, ) return struct( diff --git a/apple/internal/environment_plist.bzl b/apple/internal/environment_plist.bzl index 0bc1c5500f..bcff459671 100644 --- a/apple/internal/environment_plist.bzl +++ b/apple/internal/environment_plist.bzl @@ -62,7 +62,7 @@ def _environment_plist_impl(ctx): uses_swift = False, xcode_version_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig], ) - resolved_environment_plist_tool = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo].resolved_environment_plist_tool + environment_plist_tool = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo].environment_plist_tool platform = platform_prerequisites.platform sdk_version = platform_prerequisites.sdk_version apple_support.run( @@ -74,9 +74,7 @@ def _environment_plist_impl(ctx): "--output", ctx.outputs.plist.path, ], - executable = resolved_environment_plist_tool.executable, - inputs = resolved_environment_plist_tool.inputs, - input_manifests = resolved_environment_plist_tool.input_manifests, + executable = environment_plist_tool, outputs = [ctx.outputs.plist], xcode_config = platform_prerequisites.xcode_version_config, ) diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index 8803a759ec..8e92e5673e 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -343,7 +343,7 @@ def _ios_application_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -686,7 +686,7 @@ def _ios_app_clip_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -992,7 +992,7 @@ def _ios_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1150,6 +1150,7 @@ def _ios_extension_impl(ctx): attr = ctx.attr, res_attrs = [ "app_icons", + "resources", "strings", ], ) @@ -1289,7 +1290,7 @@ def _ios_extension_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1571,7 +1572,7 @@ def _ios_dynamic_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1655,7 +1656,9 @@ def _ios_dynamic_framework_impl(ctx): additional_providers = [] for provider in providers: - if type(provider) == "AppleDynamicFramework": + # HACK: this should be updated so we do not need to dynamically check the provider instance. + # See: https://github.com/bazelbuild/bazel/issues/22095 + if hasattr(provider, "framework_files"): # Make the ObjC provider using the framework_files depset found # in the AppleDynamicFramework provider. This is to make the # ios_dynamic_framework usable as a dependency in swift_library @@ -2215,7 +2218,7 @@ def _ios_imessage_extension_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), diff --git a/apple/internal/macos_binary_support.bzl b/apple/internal/macos_binary_support.bzl index fd2f2c1cba..24ab2f3d82 100644 --- a/apple/internal/macos_binary_support.bzl +++ b/apple/internal/macos_binary_support.bzl @@ -152,7 +152,7 @@ def _macos_binary_infoplist_impl(ctx): output_pkginfo = None, output_plist = merged_infoplist, platform_prerequisites = platform_prerequisites, - resolved_plisttool = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo].resolved_plisttool, + plisttool = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo].plisttool, rule_descriptor = rule_descriptor, rule_label = rule_label, version = ctx.attr.version, @@ -246,7 +246,7 @@ def _macos_command_line_launchdplist_impl(ctx): output_discriminator = None, output_plist = merged_launchdplist, platform_prerequisites = platform_prerequisites, - resolved_plisttool = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo].resolved_plisttool, + plisttool = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo].plisttool, rule_label = rule_label, ) diff --git a/apple/internal/macos_rules.bzl b/apple/internal/macos_rules.bzl index be06aea35e..d803e39a38 100644 --- a/apple/internal/macos_rules.bzl +++ b/apple/internal/macos_rules.bzl @@ -318,7 +318,7 @@ def _macos_application_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -327,6 +327,9 @@ def _macos_application_impl(ctx): embeddable_targets = embedded_targets, platform_prerequisites = platform_prerequisites, ), + partials.cc_info_dylibs_partial( + embedded_targets = embedded_targets, + ), partials.framework_import_partial( actions = actions, apple_mac_toolchain_info = apple_mac_toolchain_info, @@ -620,7 +623,7 @@ def _macos_bundle_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -882,7 +885,7 @@ def _macos_extension_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1142,7 +1145,7 @@ def _macos_quick_look_plugin_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1392,7 +1395,7 @@ def _macos_kernel_extension_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1632,7 +1635,7 @@ def _macos_spotlight_importer_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1871,7 +1874,7 @@ def _macos_xpc_service_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -2020,7 +2023,7 @@ def _macos_command_line_application_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ) @@ -2047,12 +2050,12 @@ def _macos_command_line_application_impl(ctx): codesigning_support.sign_binary_action( actions = actions, codesign_inputs = ctx.files.codesign_inputs, + codesigningtool = apple_mac_toolchain_info.codesigningtool, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), input_binary = binary_artifact, output_binary = output_file, platform_prerequisites = platform_prerequisites, provisioning_profile = provisioning_profile, - resolved_codesigningtool = apple_mac_toolchain_info.resolved_codesigningtool, rule_descriptor = rule_descriptor, ) @@ -2162,7 +2165,7 @@ def _macos_dylib_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ) @@ -2190,12 +2193,12 @@ def _macos_dylib_impl(ctx): codesigning_support.sign_binary_action( actions = actions, codesign_inputs = ctx.files.codesign_inputs, + codesigningtool = apple_mac_toolchain_info.codesigningtool, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), input_binary = binary_artifact, output_binary = output_file, platform_prerequisites = platform_prerequisites, provisioning_profile = provisioning_profile, - resolved_codesigningtool = apple_mac_toolchain_info.resolved_codesigningtool, rule_descriptor = rule_descriptor, ) @@ -2911,7 +2914,7 @@ def _macos_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -3189,7 +3192,7 @@ def _macos_dynamic_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -3273,7 +3276,9 @@ def _macos_dynamic_framework_impl(ctx): additional_providers = [] for provider in providers: - if type(provider) == "AppleDynamicFramework": + # HACK: this should be updated so we do not need to dynamically check the provider instance. + # See: https://github.com/bazelbuild/bazel/issues/22095 + if hasattr(provider, "framework_files"): # Make the ObjC provider using the framework_files depset found # in the AppleDynamicFramework provider. This is to make the # macos_dynamic_framework usable as a dependency in swift_library diff --git a/apple/internal/partials.bzl b/apple/internal/partials.bzl index b7717a4080..40057faf3b 100644 --- a/apple/internal/partials.bzl +++ b/apple/internal/partials.bzl @@ -54,6 +54,10 @@ load( "@build_bazel_rules_apple//apple/internal/partials:embedded_bundles.bzl", _embedded_bundles_partial = "embedded_bundles_partial", ) +load( + "@build_bazel_rules_apple//apple/internal/partials:cc_info_dylibs.bzl", + _cc_info_dylibs_partial = "cc_info_dylibs_partial", +) load( "@build_bazel_rules_apple//apple/internal/partials:extension_safe_validation.bzl", _extension_safe_validation_partial = "extension_safe_validation_partial", @@ -121,6 +125,7 @@ partials = struct( codesigning_dossier_partial = _codesigning_dossier_partial, debug_symbols_partial = _debug_symbols_partial, embedded_bundles_partial = _embedded_bundles_partial, + cc_info_dylibs_partial = _cc_info_dylibs_partial, extension_safe_validation_partial = _extension_safe_validation_partial, framework_import_partial = _framework_import_partial, framework_header_modulemap_partial = _framework_header_modulemap_partial, diff --git a/apple/internal/partials/BUILD b/apple/internal/partials/BUILD index cd4060c853..52a3b65664 100644 --- a/apple/internal/partials/BUILD +++ b/apple/internal/partials/BUILD @@ -76,6 +76,20 @@ bzl_library( ], ) +bzl_library( + name = "cc_info_dylibs", + srcs = ["cc_info_dylibs.bzl"], + visibility = [ + "//apple/internal:__pkg__", + ], + deps = [ + "//apple/internal:intermediates", + "//apple/internal:processor", + "@bazel_skylib//lib:partial", + "@build_bazel_apple_support//lib:apple_support", + ], +) + bzl_library( name = "clang_rt_dylibs", srcs = ["clang_rt_dylibs.bzl"], diff --git a/apple/internal/partials/cc_info_dylibs.bzl b/apple/internal/partials/cc_info_dylibs.bzl new file mode 100644 index 0000000000..91f934bb9e --- /dev/null +++ b/apple/internal/partials/cc_info_dylibs.bzl @@ -0,0 +1,68 @@ +# Copyright 2024 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Partial implementation for gathering cc_info dylibs.""" + +load("@bazel_skylib//lib:partial.bzl", "partial") +load( + "@build_bazel_rules_apple//apple/internal:processor.bzl", + "processor", +) + +def _cc_info_dylibs_partial_impl( + *, + embedded_targets): + """Implementation for the CcInfo dylibs processing partial.""" + bundle_files = [] + + for target in embedded_targets: + if CcInfo not in target: + continue + cc_info = target[CcInfo] + for linker_input in cc_info.linking_context.linker_inputs.to_list(): + for library in linker_input.libraries: + if library.dynamic_library: + bundle_files.append( + (processor.location.framework, None, depset([library.dynamic_library])), + ) + + return struct(bundle_files = bundle_files) + +def cc_info_dylibs_partial( + *, + embedded_targets): + """Constructor for the CcInfo dylibs processing partial. + + This partial searches through the embedded_targets for dynamic_libraries and adds them + as bundle_files destined for the Framework folder. The cc_* targets (like cc_library) can + depend on dynamic libraries (.dylibs), usually pulled in from a cc_import. These .dylibs are required + at runtime and are similar to .dlls on windows. The macos_application adds the /Contents/Frameworks + folder as an @rpath search path so placing all of the dylibs in this folder seems reasonable. + Generally, .dylibs should have their install name set to @rpath/libname.dylib for this strategy to work. + You can check the install name using + otool -L libname.dylib + and change it using + install_name_tool -id @rpath/libname.dylib libname.dylib + + Args: + embedded_targets: The list of targets that may have CcInfo specifying dylibs that need to be bundled. + + Returns: + A partial that returns the bundle location of all dylibs contained in the embedded_targets CcInfo, if there were any to + bundle. + """ + return partial.make( + _cc_info_dylibs_partial_impl, + embedded_targets = embedded_targets, + ) diff --git a/apple/internal/partials/clang_rt_dylibs.bzl b/apple/internal/partials/clang_rt_dylibs.bzl index 4ad689bf6f..a7a22b8635 100644 --- a/apple/internal/partials/clang_rt_dylibs.bzl +++ b/apple/internal/partials/clang_rt_dylibs.bzl @@ -55,7 +55,7 @@ def _clang_rt_dylibs_partial_impl( file_name = "clang_rt.zip", ) - resolved_clangrttool = apple_mac_toolchain_info.resolved_clangrttool + clangrttool = apple_mac_toolchain_info.clangrttool apple_support.run( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, @@ -63,11 +63,10 @@ def _clang_rt_dylibs_partial_impl( binary_artifact.path, clang_rt_zip.path, ], - executable = resolved_clangrttool.files_to_run, + executable = clangrttool, # This action needs to read the contents of the Xcode bundle. execution_requirements = {"no-sandbox": "1"}, - inputs = depset([binary_artifact] + dylibs, transitive = [resolved_clangrttool.inputs]), - input_manifests = resolved_clangrttool.input_manifests, + inputs = [binary_artifact] + dylibs, outputs = [clang_rt_zip], mnemonic = "ClangRuntimeLibsCopy", xcode_config = platform_prerequisites.xcode_version_config, diff --git a/apple/internal/partials/codesigning_dossier.bzl b/apple/internal/partials/codesigning_dossier.bzl index cf49df1f24..6c810ecf5b 100644 --- a/apple/internal/partials/codesigning_dossier.bzl +++ b/apple/internal/partials/codesigning_dossier.bzl @@ -155,17 +155,18 @@ def _embedded_codesign_dossiers_from_dossier_infos( def _create_combined_zip_artifact( *, actions, + bundletool, dossier_merge_zip, input_archive, label_name, output_combined_zip, output_discriminator, - platform_prerequisites, - resolved_bundletool): + platform_prerequisites): """Generates a zip file with the IPA contents in one subdirectory and the dossier in another. Args: actions: The actions provider from `ctx.actions`. + bundletool: A files_to_run for the bundle tool. dossier_merge_zip: A File referencing the generated code sign dossier zip. input_archive: A File referencing the rule's output archive (IPA or zipped app). label_name: Name of the target being built. @@ -173,7 +174,6 @@ def _create_combined_zip_artifact( output_discriminator: A string to differentiate between different target intermediate files or `None`. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_bundletool: A struct referencing the resolved bundle tool. """ bundletool_control_file = intermediates.file( actions = actions, @@ -226,15 +226,8 @@ def _create_combined_zip_artifact( else: actions.run( arguments = [bundletool_control_file.path], - executable = resolved_bundletool.executable, - inputs = depset( - direct = [bundletool_control_file], - transitive = [ - resolved_bundletool.inputs, - depset([input_archive, dossier_merge_zip]), - ], - ), - input_manifests = resolved_bundletool.input_manifests, + executable = bundletool, + inputs = [bundletool_control_file, input_archive, dossier_merge_zip], **common_combined_dossier_zip_args ) @@ -284,7 +277,7 @@ def _codesigning_dossier_partial_impl( codesigning_support.generate_codesigning_dossier_action( actions = actions, label_name = label_name, - resolved_codesigning_dossier_tool = apple_mac_toolchain_info.resolved_dossier_codesigningtool, + dossier_codesigningtool = apple_mac_toolchain_info.dossier_codesigningtool, output_discriminator = output_discriminator, output_dossier = output_dossier, platform_prerequisites = platform_prerequisites, @@ -331,13 +324,13 @@ def _codesigning_dossier_partial_impl( _create_combined_zip_artifact( actions = actions, + bundletool = apple_xplat_toolchain_info.bundletool, dossier_merge_zip = output_dossier, input_archive = output_archive, label_name = label_name, output_combined_zip = output_combined_zip, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, - resolved_bundletool = apple_xplat_toolchain_info.resolved_bundletool, ) return struct( diff --git a/apple/internal/partials/debug_symbols.bzl b/apple/internal/partials/debug_symbols.bzl index 2965839833..2e851de7fe 100644 --- a/apple/internal/partials/debug_symbols.bzl +++ b/apple/internal/partials/debug_symbols.bzl @@ -174,7 +174,7 @@ def _generate_dsym_info_plist( dsym_info_plist_template, output_discriminator, platform_prerequisites, - resolved_plisttool, + plisttool, rule_label, version): """Generates an XML Info.plist appropriate for a dSYM bundle. @@ -186,7 +186,7 @@ def _generate_dsym_info_plist( output_discriminator: A string to differentiate between different target intermediate files or `None`. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_plisttool: A struct referencing the resolved plist tool. + plisttool: A files_to_run for the plist tool. rule_label: The label of the target being analyzed. version: A label referencing AppleBundleVersionInfo, if provided by the rule. @@ -238,7 +238,7 @@ def _generate_dsym_info_plist( mnemonic = "CompileDSYMInfoPlist", outputs = [dsym_plist], platform_prerequisites = platform_prerequisites, - resolved_plisttool = resolved_plisttool, + plisttool = plisttool, ) return dsym_plist @@ -253,7 +253,7 @@ def _bundle_dsym_files( label_name, output_discriminator, platform_prerequisites, - resolved_plisttool, + plisttool, rule_label, version): """Recreates the .dSYM bundle from the AppleDebugOutputs provider and dSYM binaries. @@ -279,7 +279,7 @@ def _bundle_dsym_files( output_discriminator: A string to differentiate between different target intermediate files or `None`. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_plisttool: A struct referencing the resolved plist tool. + plisttool: A files_to_run for the plist tool. rule_label: The label of the target being analyzed. version: A label referencing AppleBundleVersionInfo, if provided by the rule. @@ -326,7 +326,7 @@ def _bundle_dsym_files( dsym_info_plist_template = dsym_info_plist_template, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, - resolved_plisttool = resolved_plisttool, + plisttool = plisttool, rule_label = rule_label, version = version, ) @@ -368,7 +368,7 @@ def _debug_symbols_partial_impl( linkmaps = {}, output_discriminator = None, platform_prerequisites, - resolved_plisttool, + plisttool, rule_label, version): """Implementation for the debug symbols processing partial.""" @@ -413,7 +413,7 @@ def _debug_symbols_partial_impl( label_name = label_name, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, - resolved_plisttool = resolved_plisttool, + plisttool = plisttool, rule_label = rule_label, version = version, ) @@ -492,7 +492,7 @@ def debug_symbols_partial( linkmaps = {}, output_discriminator = None, platform_prerequisites, - resolved_plisttool, + plisttool, rule_label, version): """Constructor for the debug symbols processing partial. @@ -521,7 +521,7 @@ def debug_symbols_partial( output_discriminator: A string to differentiate between different target intermediate files or `None`. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_plisttool: A struct referencing the resolved plist tool. + plisttool: A files_to_run for the plist tool. rule_label: The label of the target being analyzed. version: A label referencing AppleBundleVersionInfo, if provided by the rule. @@ -542,7 +542,7 @@ def debug_symbols_partial( linkmaps = linkmaps, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, - resolved_plisttool = resolved_plisttool, + plisttool = plisttool, rule_label = rule_label, version = version, ) diff --git a/apple/internal/partials/framework_import.bzl b/apple/internal/partials/framework_import.bzl index 4512e56536..e82613730c 100644 --- a/apple/internal/partials/framework_import.bzl +++ b/apple/internal/partials/framework_import.bzl @@ -174,8 +174,8 @@ def _framework_import_partial_impl( # code sign arguments are mutually exclusive groups. args.add("--disable_signing") - resolved_codesigningtool = apple_mac_toolchain_info.resolved_codesigningtool - resolved_imported_dynamic_framework_processor = apple_mac_toolchain_info.resolved_imported_dynamic_framework_processor + codesigningtool = apple_mac_toolchain_info.codesigningtool + imported_dynamic_framework_processor = apple_mac_toolchain_info.imported_dynamic_framework_processor execution_requirements = {} @@ -194,25 +194,16 @@ def _framework_import_partial_impl( # with different identities. execution_requirements["no-remote"] = "1" - transitive_inputs = [ - resolved_imported_dynamic_framework_processor.inputs, - resolved_codesigningtool.inputs, - ] - apple_support.run( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = [args], - executable = ( - resolved_imported_dynamic_framework_processor.files_to_run - ), + executable = imported_dynamic_framework_processor, execution_requirements = execution_requirements, - inputs = depset(input_files, transitive = transitive_inputs), - input_manifests = resolved_imported_dynamic_framework_processor.input_manifests + - resolved_codesigningtool.input_manifests, + inputs = input_files, mnemonic = "ImportedDynamicFrameworkProcessor", outputs = [framework_zip], - tools = [resolved_codesigningtool.executable], + tools = [codesigningtool], xcode_config = platform_prerequisites.xcode_version_config, ) diff --git a/apple/internal/partials/main_thread_checker_dylibs.bzl b/apple/internal/partials/main_thread_checker_dylibs.bzl index b627cc3aaf..75df16d13a 100644 --- a/apple/internal/partials/main_thread_checker_dylibs.bzl +++ b/apple/internal/partials/main_thread_checker_dylibs.bzl @@ -51,8 +51,8 @@ def _run_main_thread_checker( binary_artifact, dylibs, main_thread_checker_dylib, - platform_prerequisites, - resolved_main_thread_checker_tool): + main_thread_checker_tool, + platform_prerequisites): apple_support.run( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, @@ -60,10 +60,9 @@ def _run_main_thread_checker( binary_artifact.path, main_thread_checker_dylib.path, ], - executable = resolved_main_thread_checker_tool.files_to_run, + executable = main_thread_checker_tool, execution_requirements = {"no-sandbox": "1"}, - inputs = depset([binary_artifact] + dylibs, transitive = [resolved_main_thread_checker_tool.inputs]), - input_manifests = resolved_main_thread_checker_tool.input_manifests, + inputs = [binary_artifact] + dylibs, outputs = [main_thread_checker_dylib], mnemonic = "MainThreadCheckerLibsCopy", xcode_config = platform_prerequisites.xcode_version_config, @@ -86,9 +85,9 @@ def _main_thread_checker_dylibs_partial_impl( return struct(bundle_files = bundle_files) main_thread_checker_dylib = _create_main_thread_checker_dylib(actions, label_name, output_discriminator) - resolved_main_thread_checker_tool = apple_mac_toolchain_info.resolved_main_thread_checker_tool + main_thread_checker_tool = apple_mac_toolchain_info.main_thread_checker_tool - _run_main_thread_checker(actions, binary_artifact, dylibs, main_thread_checker_dylib, platform_prerequisites, resolved_main_thread_checker_tool) + _run_main_thread_checker(actions, binary_artifact, dylibs, main_thread_checker_dylib, main_thread_checker_tool, platform_prerequisites) bundle_files.append( (processor.location.framework, None, depset([main_thread_checker_dylib])), diff --git a/apple/internal/partials/resources.bzl b/apple/internal/partials/resources.bzl index 39c483a7f3..909163b4c7 100644 --- a/apple/internal/partials/resources.bzl +++ b/apple/internal/partials/resources.bzl @@ -368,7 +368,7 @@ def _resources_partial_impl( out_infoplist = out_infoplist, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_descriptor = rule_descriptor, rule_label = rule_label, version = version, diff --git a/apple/internal/partials/support/resources_support.bzl b/apple/internal/partials/support/resources_support.bzl index 9cba4cb10c..339a0bfabf 100644 --- a/apple/internal/partials/support/resources_support.bzl +++ b/apple/internal/partials/support/resources_support.bzl @@ -64,8 +64,8 @@ def _compile_datamodels( output_discriminator, parent_dir, platform_prerequisites, - resolved_xctoolrunner, - swift_module): + swift_module, + xctoolrunner): "Compiles datamodels into mom files." output_files = [] module_name = swift_module or label_name @@ -97,7 +97,7 @@ def _compile_datamodels( module_name = module_name, output_file = output_file, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = resolved_xctoolrunner, + xctoolrunner = xctoolrunner, ) output_files.append( (processor.location.resource, datamodel_parent, depset(direct = [output_file])), @@ -113,7 +113,7 @@ def _compile_mappingmodels( output_discriminator, parent_dir, platform_prerequisites, - resolved_xctoolrunner): + xctoolrunner): """Compiles mapping models into cdm files.""" output_files = [] for mappingmodel_path, input_files in mappingmodel_groups.items(): @@ -131,7 +131,7 @@ def _compile_mappingmodels( mappingmodel_path = mappingmodel_path, output_file = output_file, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = resolved_xctoolrunner, + xctoolrunner = xctoolrunner, ) output_files.append( @@ -205,15 +205,15 @@ def _asset_catalogs( resource_actions.compile_asset_catalog( actions = actions, alternate_icons = alternate_icons, + alticonstool = apple_mac_toolchain_info.alticonstool, asset_files = asset_files, bundle_id = bundle_id, output_dir = assets_dir, output_plist = assets_plist, platform_prerequisites = platform_prerequisites, product_type = product_type, - resolved_alticonstool = apple_mac_toolchain_info.resolved_alticonstool, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, rule_label = rule_label, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) return struct( @@ -276,8 +276,8 @@ def _datamodels( output_discriminator = output_discriminator, parent_dir = parent_dir, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, swift_module = swift_module, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, )) output_files.extend(_compile_mappingmodels( actions = actions, @@ -286,7 +286,7 @@ def _datamodels( parent_dir = parent_dir, mappingmodel_groups = mappingmodel_groups, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, )) return struct(files = output_files) @@ -343,7 +343,7 @@ def _infoplists( output_discriminator = output_discriminator, output_plist = out_plist, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = rule_label, ) return struct( @@ -438,7 +438,7 @@ def _mlmodels( output_bundle = output_bundle, output_plist = output_plist, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) mlmodel_bundles.append( @@ -608,8 +608,8 @@ def _storyboards( input_file = storyboard, output_dir = storyboardc_dir, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, swift_module = swift_module, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) compiled_storyboardcs.append(storyboardc_dir) @@ -625,8 +625,8 @@ def _storyboards( actions = actions, output_dir = linked_storyboard_dir, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, storyboardc_dirs = compiled_storyboardcs, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) return struct( files = [ @@ -705,8 +705,8 @@ def _xibs( input_file = file, output_dir = out_dir, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, swift_module = swift_module, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) nib_files.append(out_dir) diff --git a/apple/internal/partials/swift_dylibs.bzl b/apple/internal/partials/swift_dylibs.bzl index 0c7becda67..c5a23ff4f9 100644 --- a/apple/internal/partials/swift_dylibs.bzl +++ b/apple/internal/partials/swift_dylibs.bzl @@ -82,8 +82,8 @@ def _swift_dylib_action( output_dir, platform_name, platform_prerequisites, - resolved_swift_stdlib_tool, - strip_bitcode): + strip_bitcode, + swift_stdlib_tool): """Registers a swift-stlib-tool action to gather Swift dylibs to bundle.""" swift_stdlib_tool_args = [ "--platform", @@ -104,9 +104,8 @@ def _swift_dylib_action( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = swift_stdlib_tool_args, - executable = resolved_swift_stdlib_tool.files_to_run, - inputs = depset(binary_files, transitive = [resolved_swift_stdlib_tool.inputs]), - input_manifests = resolved_swift_stdlib_tool.input_manifests, + executable = swift_stdlib_tool, + inputs = binary_files, mnemonic = "SwiftStdlibCopy", outputs = [output_dir], xcode_config = platform_prerequisites.xcode_version_config, @@ -177,8 +176,8 @@ def _swift_dylibs_partial_impl( output_dir = output_dir, platform_name = platform_name, platform_prerequisites = platform_prerequisites, - resolved_swift_stdlib_tool = apple_mac_toolchain_info.resolved_swift_stdlib_tool, strip_bitcode = True, + swift_stdlib_tool = apple_mac_toolchain_info.swift_stdlib_tool, ) bundle_files.append((processor.location.framework, None, depset([output_dir]))) @@ -199,8 +198,8 @@ def _swift_dylibs_partial_impl( output_dir = swift_support_output_dir, platform_name = platform_name, platform_prerequisites = platform_prerequisites, - resolved_swift_stdlib_tool = apple_mac_toolchain_info.resolved_swift_stdlib_tool, strip_bitcode = False, + swift_stdlib_tool = apple_mac_toolchain_info.swift_stdlib_tool, ) swift_support_file = (platform_name, swift_support_output_dir) diff --git a/apple/internal/processor.bzl b/apple/internal/processor.bzl index 4c770e8db2..ca47f4de63 100644 --- a/apple/internal/processor.bzl +++ b/apple/internal/processor.bzl @@ -413,13 +413,13 @@ def _bundle_partial_outputs_files( # Since the tree artifact bundler also runs the post processor and codesigning, this # action needs to run on a macOS machine. - resolved_bundletool = apple_mac_toolchain_info.resolved_bundletool_experimental + bundletool = apple_mac_toolchain_info.bundletool_experimental # Required to satisfy an implicit dependency, when the codesigning commands are executed by # the experimental bundle tool script. - resolved_codesigningtool = apple_mac_toolchain_info.resolved_codesigningtool + codesigningtool = apple_mac_toolchain_info.codesigningtool - bundling_tools = [resolved_bundletool.executable, resolved_codesigningtool.executable] + bundling_tools = [bundletool, codesigningtool] if post_processor: bundling_tools.append(post_processor) @@ -438,14 +438,9 @@ def _bundle_partial_outputs_files( apple_support.run( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, - executable = resolved_bundletool.executable, + executable = bundletool, execution_requirements = execution_requirements, - inputs = depset(bundletool_inputs + codesign_inputs, transitive = [ - resolved_bundletool.inputs, - resolved_codesigningtool.inputs, - ]), - input_manifests = resolved_bundletool.input_manifests + - resolved_codesigningtool.input_manifests, + inputs = bundletool_inputs + codesign_inputs, mnemonic = "BundleTreeApp", progress_message = "Bundling, processing and signing %s" % label_name, tools = bundling_tools, @@ -453,11 +448,10 @@ def _bundle_partial_outputs_files( **action_args ) else: - resolved_bundletool = apple_xplat_toolchain_info.resolved_bundletool + bundletool = apple_xplat_toolchain_info.bundletool actions.run( - executable = resolved_bundletool.executable, - inputs = depset(bundletool_inputs, transitive = [resolved_bundletool.inputs]), - input_manifests = resolved_bundletool.input_manifests, + executable = bundletool, + inputs = bundletool_inputs, mnemonic = "BundleApp", progress_message = "Bundling %s" % label_name, **action_args @@ -536,7 +530,7 @@ def _bundle_post_process_and_sign( # TODO(b/149874635): Don't pass frameworks_path unless the rule has it (*_application). codesigning_command = codesigning_support.codesigning_command( - codesigningtool = apple_mac_toolchain_info.resolved_codesigningtool.executable, + codesigningtool = apple_mac_toolchain_info.codesigningtool.executable, entitlements = entitlements, features = features, frameworks_path = archive_paths[_LOCATION_ENUM.framework], @@ -607,6 +601,7 @@ def _bundle_post_process_and_sign( actions = actions, archive_codesigning_path = archive_codesigning_path, codesign_inputs = codesign_inputs, + codesigningtool = apple_mac_toolchain_info.codesigningtool, codesignopts = codesignopts, entitlements = entitlements, features = features, @@ -620,7 +615,6 @@ def _bundle_post_process_and_sign( platform_prerequisites = platform_prerequisites, process_and_sign_template = process_and_sign_template, provisioning_profile = provisioning_profile, - resolved_codesigningtool = apple_mac_toolchain_info.resolved_codesigningtool, rule_descriptor = rule_descriptor, signed_frameworks = transitive_signed_frameworks, ) @@ -677,6 +671,7 @@ def _bundle_post_process_and_sign( actions = actions, archive_codesigning_path = embedding_archive_codesigning_path, codesign_inputs = codesign_inputs, + codesigningtool = apple_mac_toolchain_info.codesigningtool, codesignopts = codesignopts, entitlements = entitlements, features = features, @@ -690,7 +685,6 @@ def _bundle_post_process_and_sign( platform_prerequisites = platform_prerequisites, process_and_sign_template = process_and_sign_template, provisioning_profile = provisioning_profile, - resolved_codesigningtool = apple_mac_toolchain_info.resolved_codesigningtool, rule_descriptor = rule_descriptor, signed_frameworks = transitive_signed_frameworks, ) diff --git a/apple/internal/resource_actions/actool.bzl b/apple/internal/resource_actions/actool.bzl index 26e7c94c30..ef86f8aec8 100644 --- a/apple/internal/resource_actions/actool.bzl +++ b/apple/internal/resource_actions/actool.bzl @@ -24,7 +24,7 @@ load( ) load( "@build_bazel_rules_apple//apple/internal/utils:xctoolrunner.bzl", - "xctoolrunner", + xctoolrunner_support = "xctoolrunner", ) load( "@build_bazel_rules_apple//apple/internal:apple_product_type.bzl", @@ -187,15 +187,15 @@ def compile_asset_catalog( *, actions, alternate_icons, + alticonstool, asset_files, bundle_id, output_dir, output_plist, platform_prerequisites, product_type, - resolved_alticonstool, - resolved_xctoolrunner, - rule_label): + rule_label, + xctoolrunner): """Creates an action that compiles asset catalogs. This action populates a directory with compiled assets that must be merged @@ -206,6 +206,7 @@ def compile_asset_catalog( Args: actions: The actions provider from `ctx.actions`. alternate_icons: Alternate icons files, organized in .alticon directories. + alticonstool: A files_to_run for the alticonstool tool. asset_files: An iterable of files in all asset catalogs that should be packaged as part of this catalog. This should include transitive dependencies (i.e., assets not just from the application target, but @@ -217,9 +218,8 @@ def compile_asset_catalog( into Info.plist. May be None if the output plist is not desired. platform_prerequisites: Struct containing information on the platform being targeted. product_type: The product type identifier used to describe the current bundle type. - resolved_alticonstool: A struct referencing the resolved alticonstool tool. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. rule_label: The label of the target being analyzed. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ platform = platform_prerequisites.platform actool_platform = platform.name_in_plist.lower() @@ -227,7 +227,7 @@ def compile_asset_catalog( args = [ "actool", "--compile", - xctoolrunner.prefixed_path(output_dir.path), + xctoolrunner_support.prefixed_path(output_dir.path), "--platform", actool_platform, "--minimum-deployment-target", @@ -264,7 +264,7 @@ def compile_asset_catalog( actool_outputs.append(actool_output_plist) args.extend([ "--output-partial-info-plist", - xctoolrunner.prefixed_path(actool_output_plist.path), + xctoolrunner_support.prefixed_path(actool_output_plist.path), ]) xcassets = group_files_by_directory( @@ -273,16 +273,15 @@ def compile_asset_catalog( attr = "asset_catalogs", ).keys() - args.extend([xctoolrunner.prefixed_path(xcasset) for xcasset in xcassets]) + args.extend([xctoolrunner_support.prefixed_path(xcasset) for xcasset in xcassets]) apple_support.run( actions = actions, arguments = args, apple_fragment = platform_prerequisites.apple_fragment, - executable = resolved_xctoolrunner.files_to_run, + executable = xctoolrunner, execution_requirements = {"no-sandbox": "1"}, - inputs = depset(asset_files, transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + inputs = asset_files, mnemonic = "AssetCatalogCompile", outputs = actool_outputs, xcode_config = platform_prerequisites.xcode_version_config, @@ -299,9 +298,8 @@ def compile_asset_catalog( alticons_files = alternate_icons, device_families = platform_prerequisites.device_families, ), - executable = resolved_alticonstool.files_to_run, - inputs = depset([actool_output_plist] + alternate_icons, transitive = [resolved_alticonstool.inputs]), - input_manifests = resolved_alticonstool.input_manifests, + executable = alticonstool, + inputs = [actool_output_plist] + alternate_icons, mnemonic = "AlternateIconsInsert", outputs = alticons_outputs, xcode_config = platform_prerequisites.xcode_version_config, diff --git a/apple/internal/resource_actions/datamodel.bzl b/apple/internal/resource_actions/datamodel.bzl index da26409e9e..5ed8f0c943 100644 --- a/apple/internal/resource_actions/datamodel.bzl +++ b/apple/internal/resource_actions/datamodel.bzl @@ -20,7 +20,7 @@ load( ) load( "@build_bazel_rules_apple//apple/internal/utils:xctoolrunner.bzl", - "xctoolrunner", + xctoolrunner_support = "xctoolrunner", ) def compile_datamodels( @@ -31,7 +31,7 @@ def compile_datamodels( module_name, output_file, platform_prerequisites, - resolved_xctoolrunner): + xctoolrunner): """Creates an action that compiles datamodels. Args: @@ -41,7 +41,7 @@ def compile_datamodels( module_name: The module name to use when compiling the datamodels. output_file: The file reference to the compiled datamodel. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ platform = platform_prerequisites.platform platform_name = platform.name_in_plist.lower() @@ -53,17 +53,16 @@ def compile_datamodels( platform_prerequisites.minimum_os, "--module", module_name, - xctoolrunner.prefixed_path(datamodel_path), - xctoolrunner.prefixed_path(output_file.path), + xctoolrunner_support.prefixed_path(datamodel_path), + xctoolrunner_support.prefixed_path(output_file.path), ] apple_support.run( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = args, - executable = resolved_xctoolrunner.files_to_run, - inputs = depset(input_files, transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + executable = xctoolrunner, + inputs = input_files, mnemonic = "MomCompile", outputs = [output_file], xcode_config = platform_prerequisites.xcode_version_config, @@ -76,7 +75,7 @@ def compile_mappingmodel( mappingmodel_path, output_file, platform_prerequisites, - resolved_xctoolrunner): + xctoolrunner): """Creates an action that compiles CoreData mapping models. Args: @@ -85,21 +84,20 @@ def compile_mappingmodel( mappingmodel_path: The path to the directory containing the mapping model. output_file: The file reference to the compiled mapping model. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ args = [ "mapc", - xctoolrunner.prefixed_path(mappingmodel_path), - xctoolrunner.prefixed_path(output_file.path), + xctoolrunner_support.prefixed_path(mappingmodel_path), + xctoolrunner_support.prefixed_path(output_file.path), ] apple_support.run( actions = actions, arguments = args, apple_fragment = platform_prerequisites.apple_fragment, - executable = resolved_xctoolrunner.files_to_run, - inputs = depset(input_files, transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + executable = xctoolrunner, + inputs = input_files, mnemonic = "MappingModelCompile", outputs = [output_file], xcode_config = platform_prerequisites.xcode_version_config, @@ -112,7 +110,7 @@ def generate_datamodels( input_files, output_dir, platform_prerequisites, - resolved_xctoolrunner, + xctoolrunner, swift_version = None): """Creates an action that generates CoreData model class files. @@ -122,7 +120,7 @@ def generate_datamodels( input_files: The list of files to process for the given datamodel. output_dir: The output directory reference where generated datamodel classes will be. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. swift_version: (optional) Target Swift version for generated datamodel classes. """ platform = platform_prerequisites.platform @@ -137,8 +135,8 @@ def generate_datamodels( if swift_version: args.add("--swift-version", swift_version) - args.add(xctoolrunner.prefixed_path(datamodel_path)) - args.add(xctoolrunner.prefixed_path(output_dir.path)) + args.add(xctoolrunner_support.prefixed_path(datamodel_path)) + args.add(xctoolrunner_support.prefixed_path(output_dir.path)) args.add("--xctoolrunner_assert_nonempty_dir", output_dir.path) @@ -146,9 +144,8 @@ def generate_datamodels( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = [args], - executable = resolved_xctoolrunner.files_to_run, - inputs = depset(input_files, transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + executable = xctoolrunner, + inputs = input_files, mnemonic = "MomGenerate", outputs = [output_dir], xcode_config = platform_prerequisites.xcode_version_config, diff --git a/apple/internal/resource_actions/ibtool.bzl b/apple/internal/resource_actions/ibtool.bzl index a3756ecf7a..d72445c888 100644 --- a/apple/internal/resource_actions/ibtool.bzl +++ b/apple/internal/resource_actions/ibtool.bzl @@ -20,7 +20,7 @@ load( ) load( "@build_bazel_rules_apple//apple/internal/utils:xctoolrunner.bzl", - "xctoolrunner", + xctoolrunner_support = "xctoolrunner", ) load( "@bazel_skylib//lib:collections.bzl", @@ -59,8 +59,8 @@ def compile_storyboard( input_file, output_dir, platform_prerequisites, - resolved_xctoolrunner, - swift_module): + swift_module, + xctoolrunner): """Creates an action that compiles a storyboard. Args: @@ -68,15 +68,15 @@ def compile_storyboard( input_file: The storyboard to compile. output_dir: The directory where the compiled outputs should be placed. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. swift_module: The name of the Swift module to use when compiling the storyboard. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ args = [ "ibtool", "--compilation-directory", - xctoolrunner.prefixed_path(output_dir.dirname), + xctoolrunner_support.prefixed_path(output_dir.dirname), ] min_os = platform_prerequisites.minimum_os @@ -85,17 +85,16 @@ def compile_storyboard( args.extend([ "--module", swift_module, - xctoolrunner.prefixed_path(input_file.path), + xctoolrunner_support.prefixed_path(input_file.path), ]) apple_support.run( actions = actions, arguments = args, apple_fragment = platform_prerequisites.apple_fragment, - executable = resolved_xctoolrunner.files_to_run, + executable = xctoolrunner, execution_requirements = {"no-sandbox": "1"}, - inputs = depset([input_file], transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + inputs = [input_file], mnemonic = "StoryboardCompile", outputs = [output_dir], xcode_config = platform_prerequisites.xcode_version_config, @@ -106,8 +105,8 @@ def link_storyboards( actions, output_dir, platform_prerequisites, - resolved_xctoolrunner, - storyboardc_dirs): + storyboardc_dirs, + xctoolrunner): """Creates an action that links multiple compiled storyboards. Storyboards that reference each other must be linked, and this operation also @@ -118,9 +117,9 @@ def link_storyboards( actions: The actions provider from `ctx.actions`. output_dir: The directory where the linked outputs should be placed. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A reference to the executable wrapper for "xcrun" tools. storyboardc_dirs: A list of `File`s that represent directories containing the compiled storyboards. + xctoolrunner: A files_to_run for the wrapper for the "xcrun" tools. """ min_os = platform_prerequisites.minimum_os @@ -129,11 +128,11 @@ def link_storyboards( args = [ "ibtool", "--link", - xctoolrunner.prefixed_path(output_dir.path), + xctoolrunner_support.prefixed_path(output_dir.path), ] args.extend(_ibtool_arguments(min_os, families)) args.extend([ - xctoolrunner.prefixed_path(f.path) + xctoolrunner_support.prefixed_path(f.path) for f in storyboardc_dirs ]) @@ -141,10 +140,9 @@ def link_storyboards( actions = actions, arguments = args, apple_fragment = platform_prerequisites.apple_fragment, - executable = resolved_xctoolrunner.files_to_run, + executable = xctoolrunner, execution_requirements = {"no-sandbox": "1"}, - inputs = depset(storyboardc_dirs, transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + inputs = storyboardc_dirs, mnemonic = "StoryboardLink", outputs = [output_dir], xcode_config = platform_prerequisites.xcode_version_config, @@ -156,8 +154,8 @@ def compile_xib( input_file, output_dir, platform_prerequisites, - resolved_xctoolrunner, - swift_module): + swift_module, + xctoolrunner): """Creates an action that compiles a Xib file. Args: @@ -165,9 +163,9 @@ def compile_xib( input_file: The Xib file to compile. output_dir: The file reference for the output directory. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. swift_module: The name of the Swift module to use when compiling the Xib file. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ min_os = platform_prerequisites.minimum_os @@ -178,23 +176,22 @@ def compile_xib( args = [ "ibtool", "--compile", - xctoolrunner.prefixed_path(paths.join(output_dir.path, nib_name)), + xctoolrunner_support.prefixed_path(paths.join(output_dir.path, nib_name)), ] args.extend(_ibtool_arguments(min_os, families)) args.extend([ "--module", swift_module, - xctoolrunner.prefixed_path(input_file.path), + xctoolrunner_support.prefixed_path(input_file.path), ]) apple_support.run( actions = actions, arguments = args, apple_fragment = platform_prerequisites.apple_fragment, - executable = resolved_xctoolrunner.files_to_run, + executable = xctoolrunner, execution_requirements = {"no-sandbox": "1"}, - inputs = depset([input_file], transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + inputs = [input_file], mnemonic = "XibCompile", outputs = [output_dir], xcode_config = platform_prerequisites.xcode_version_config, diff --git a/apple/internal/resource_actions/intent.bzl b/apple/internal/resource_actions/intent.bzl index 0137fddd0f..9bf24b887c 100644 --- a/apple/internal/resource_actions/intent.bzl +++ b/apple/internal/resource_actions/intent.bzl @@ -20,7 +20,7 @@ load( ) load( "@build_bazel_rules_apple//apple/internal/utils:xctoolrunner.bzl", - "xctoolrunner", + xctoolrunner_support = "xctoolrunner", ) load( "@bazel_skylib//lib:versions.bzl", @@ -40,7 +40,7 @@ def generate_intent_classes_sources( swift_version, class_visibility, platform_prerequisites, - resolved_xctoolrunner): + xctoolrunner): """Creates an action that cgenerates intent classes from an intentdefinition file. Args: @@ -55,7 +55,7 @@ def generate_intent_classes_sources( swift_version: Version of Swift to use for the generated classes. class_visibility: Visibility attribute for the generated classes. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A reference to the executable wrapper for "xcrun" tools. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ is_swift = language == "Swift" @@ -64,7 +64,7 @@ def generate_intent_classes_sources( "intentbuilderc", "generate", "-input", - xctoolrunner.prefixed_path(input_file.path), + xctoolrunner_support.prefixed_path(input_file.path), "-language", language, "-classPrefix", @@ -103,8 +103,8 @@ def generate_intent_classes_sources( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = arguments, - executable = resolved_xctoolrunner.files_to_run, - inputs = depset([input_file], transitive = [resolved_xctoolrunner.inputs]), + executable = xctoolrunner, + inputs = [input_file], mnemonic = "IntentGenerate", outputs = outputs, xcode_config = platform_prerequisites.xcode_version_config, diff --git a/apple/internal/resource_actions/mlmodel.bzl b/apple/internal/resource_actions/mlmodel.bzl index 40238c7d0a..3230d7847f 100644 --- a/apple/internal/resource_actions/mlmodel.bzl +++ b/apple/internal/resource_actions/mlmodel.bzl @@ -20,7 +20,7 @@ load( ) load( "@build_bazel_rules_apple//apple/internal/utils:xctoolrunner.bzl", - "xctoolrunner", + xctoolrunner_support = "xctoolrunner", ) def compile_mlmodel( @@ -30,7 +30,7 @@ def compile_mlmodel( output_bundle, output_plist, platform_prerequisites, - resolved_xctoolrunner): + xctoolrunner): """Creates an action that compiles an mlmodel file into an mlmodelc bundle. Args: @@ -39,24 +39,23 @@ def compile_mlmodel( output_bundle: The directory reference for the output mlmodelc bundle. output_plist: The file reference for the output plist from coremlc that needs to be merged. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ args = [ "coremlc", "compile", - xctoolrunner.prefixed_path(input_file.path), + xctoolrunner_support.prefixed_path(input_file.path), output_bundle.dirname, "--output-partial-info-plist", - xctoolrunner.prefixed_path(output_plist.path), + xctoolrunner_support.prefixed_path(output_plist.path), ] apple_support.run( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = args, - executable = resolved_xctoolrunner.files_to_run, - inputs = depset([input_file], transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + executable = xctoolrunner, + inputs = [input_file], mnemonic = "MlmodelCompile", outputs = [output_bundle, output_plist], xcode_config = platform_prerequisites.xcode_version_config, @@ -71,7 +70,7 @@ def generate_mlmodel_sources( objc_output_hdr, language, platform_prerequisites, - resolved_xctoolrunner): + xctoolrunner): """Creates an action that generates sources for an mlmodel file. Args: @@ -82,7 +81,7 @@ def generate_mlmodel_sources( objc_output_hdr: The output header file when generating Obj-C. language: Language of generated classes ("Objective-C", "Swift"). platform_prerequisites: Struct containing information on the platform being targeted. - resolved_xctoolrunner: A struct referencing the resolved wrapper for "xcrun" tools. + xctoolrunner: A files_to_run for the wrapper around the "xcrun" tool. """ is_swift = language == "Swift" @@ -90,7 +89,7 @@ def generate_mlmodel_sources( arguments = [ "coremlc", "generate", - xctoolrunner.prefixed_path(input_file.path), + xctoolrunner_support.prefixed_path(input_file.path), ] outputs = [] @@ -110,9 +109,8 @@ def generate_mlmodel_sources( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = arguments, - executable = resolved_xctoolrunner.files_to_run, - inputs = depset([input_file], transitive = [resolved_xctoolrunner.inputs]), - input_manifests = resolved_xctoolrunner.input_manifests, + executable = xctoolrunner, + inputs = [input_file], mnemonic = "MlmodelGenerate", outputs = outputs, xcode_config = platform_prerequisites.xcode_version_config, diff --git a/apple/internal/resource_actions/plist.bzl b/apple/internal/resource_actions/plist.bzl index 6e1ec1c439..2095b23847 100644 --- a/apple/internal/resource_actions/plist.bzl +++ b/apple/internal/resource_actions/plist.bzl @@ -47,7 +47,7 @@ def plisttool_action( mnemonic = None, outputs, platform_prerequisites, - resolved_plisttool): + plisttool): """Registers an action that invokes `plisttool`. This function is a low-level helper that simply invokes `plisttool` with the given arguments. @@ -61,15 +61,14 @@ def plisttool_action( mnemonic: The mnemonic to display when the action executes. Defaults to None. outputs: Any `File`s that should be treated as outputs of the underlying action. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_plisttool: A struct referencing the resolved plist tool. + plisttool: A files_to_run for the plist tool. """ apple_support.run( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = [control_file.path], - executable = resolved_plisttool.files_to_run, - inputs = depset(inputs + [control_file], transitive = [resolved_plisttool.inputs]), - input_manifests = resolved_plisttool.input_manifests, + executable = plisttool, + inputs = inputs + [control_file], mnemonic = mnemonic, outputs = outputs, xcode_config = platform_prerequisites.xcode_version_config, @@ -120,7 +119,7 @@ def merge_resource_infoplists( output_discriminator, output_plist, platform_prerequisites, - resolved_plisttool, + plisttool, rule_label): """Merges a list of plist files for resource bundles with substitutions. @@ -133,7 +132,7 @@ def merge_resource_infoplists( or `None`. output_plist: The file reference for the output plist. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_plisttool: A struct referencing the resolved plist tool. + plisttool: A files_to_run for the plist tool. rule_label: The label of the target being analyzed. """ product_name = paths.replace_extension(bundle_name_with_extension, "") @@ -179,7 +178,7 @@ def merge_resource_infoplists( mnemonic = "CompileInfoPlist", outputs = [output_plist], platform_prerequisites = platform_prerequisites, - resolved_plisttool = resolved_plisttool, + plisttool = plisttool, ) def merge_root_infoplists( @@ -200,7 +199,7 @@ def merge_root_infoplists( output_plist, output_pkginfo, platform_prerequisites, - resolved_plisttool, + plisttool, rule_descriptor, rule_label, version, @@ -237,7 +236,7 @@ def merge_root_infoplists( required. output_plist: The file reference for the merged output plist. platform_prerequisites: Struct containing information on the platform being targeted. - resolved_plisttool: A struct referencing the resolved plist tool. + plisttool: A files_to_run for the plist tool. rule_descriptor: A rule descriptor for platform and product types from the rule context. rule_label: The label of the target being analyzed. version: A label referencing AppleBundleVersionInfo, if provided by the rule. @@ -389,5 +388,5 @@ def merge_root_infoplists( mnemonic = "CompileRootInfoPlist", outputs = output_files, platform_prerequisites = platform_prerequisites, - resolved_plisttool = resolved_plisttool, + plisttool = plisttool, ) diff --git a/apple/internal/resource_rules/apple_core_data_model.bzl b/apple/internal/resource_rules/apple_core_data_model.bzl index 853713cb9c..97058e58fa 100644 --- a/apple/internal/resource_rules/apple_core_data_model.bzl +++ b/apple/internal/resource_rules/apple_core_data_model.bzl @@ -105,8 +105,8 @@ def _apple_core_data_model_impl(ctx): input_files = files.to_list(), output_dir = output_dir, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, swift_version = swift_version, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) output_files.append(output_dir) diff --git a/apple/internal/resource_rules/apple_core_ml_library.bzl b/apple/internal/resource_rules/apple_core_ml_library.bzl index 3b1d3fddf7..c680253c6a 100644 --- a/apple/internal/resource_rules/apple_core_ml_library.bzl +++ b/apple/internal/resource_rules/apple_core_ml_library.bzl @@ -114,7 +114,7 @@ def _apple_core_ml_library_impl(ctx): objc_output_src = objc_output_src, objc_output_hdr = objc_output_hdr, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) if is_swift: diff --git a/apple/internal/resource_rules/apple_intent_library.bzl b/apple/internal/resource_rules/apple_intent_library.bzl index f53a5b79d8..9eaf056f95 100644 --- a/apple/internal/resource_rules/apple_intent_library.bzl +++ b/apple/internal/resource_rules/apple_intent_library.bzl @@ -94,7 +94,7 @@ def _apple_intent_library_impl(ctx): swift_version = ctx.attr.swift_version, class_visibility = ctx.attr.class_visibility, platform_prerequisites = platform_prerequisites, - resolved_xctoolrunner = apple_mac_toolchain_info.resolved_xctoolrunner, + xctoolrunner = apple_mac_toolchain_info.xctoolrunner, ) if is_swift: diff --git a/apple/internal/rule_factory.bzl b/apple/internal/rule_factory.bzl index 0f404667fd..c3294e9cb9 100644 --- a/apple/internal/rule_factory.bzl +++ b/apple/internal/rule_factory.bzl @@ -47,7 +47,8 @@ _COMMON_TEST_ATTRS = { ), "env": attr.string_dict( doc = """ -Dictionary of environment variables that should be set during the test execution. +Dictionary of environment variables that should be set during the test execution. The values of +the dictionary are subject to "Make" variable expansion. """, ), "runner": attr.label( diff --git a/apple/internal/testing/apple_test_bundle_support.bzl b/apple/internal/testing/apple_test_bundle_support.bzl index 411372a0ba..628439bd6d 100644 --- a/apple/internal/testing/apple_test_bundle_support.bzl +++ b/apple/internal/testing/apple_test_bundle_support.bzl @@ -467,7 +467,7 @@ def _apple_test_bundle_impl(*, ctx, product_type): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), diff --git a/apple/internal/testing/apple_test_rule_support.bzl b/apple/internal/testing/apple_test_rule_support.bzl index b27f934988..2f3200283f 100644 --- a/apple/internal/testing/apple_test_rule_support.bzl +++ b/apple/internal/testing/apple_test_rule_support.bzl @@ -269,6 +269,13 @@ def _apple_test_rule_impl(*, ctx, requires_dossiers, test_type): runner_info = runner_attr[AppleTestRunnerInfo] execution_requirements = getattr(runner_info, "execution_requirements", {}) + # ctx.expand_make_variables is marked deprecated in the docs but every ruleset uses it. Not + # sure how they're planning on getting rid of it for good. + rule_test_env = { + k: ctx.expand_make_variables("env", v, {}) + for k, v in ctx.attr.env.items() + } + test_bundle_target = ctx.attr.deps[0] test_bundle = test_bundle_target[AppleTestInfo].test_bundle @@ -286,7 +293,7 @@ def _apple_test_rule_impl(*, ctx, requires_dossiers, test_type): test_environment = _get_simulator_test_environment( command_line_test_env = ctx.configuration.test_env, features = ctx.features, - rule_test_env = ctx.attr.env, + rule_test_env = rule_test_env, runner_test_env = getattr(runner_info, "test_environment", {}), ) diff --git a/apple/internal/tvos_rules.bzl b/apple/internal/tvos_rules.bzl index f759b16b75..d4875f5cda 100644 --- a/apple/internal/tvos_rules.bzl +++ b/apple/internal/tvos_rules.bzl @@ -309,7 +309,7 @@ def _tvos_application_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -631,7 +631,7 @@ def _tvos_dynamic_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -715,7 +715,9 @@ def _tvos_dynamic_framework_impl(ctx): providers = processor_result.providers additional_providers = [] for provider in providers: - if type(provider) == "AppleDynamicFramework": + # HACK: this should be updated so we do not need to dynamically check the provider instance. + # See: https://github.com/bazelbuild/bazel/issues/22095 + if hasattr(provider, "framework_files"): # Make the ObjC provider using the framework_files depset found # in the AppleDynamicFramework provider. This is to make the # tvos_dynamic_framework usable as a dependency in swift_library @@ -921,7 +923,7 @@ def _tvos_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1201,7 +1203,7 @@ def _tvos_extension_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), diff --git a/apple/internal/visionos_rules.bzl b/apple/internal/visionos_rules.bzl index b6255607fb..64abaff85c 100644 --- a/apple/internal/visionos_rules.bzl +++ b/apple/internal/visionos_rules.bzl @@ -313,7 +313,7 @@ Resolved Xcode is version {xcode_version}. label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -628,7 +628,7 @@ def _visionos_dynamic_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -712,7 +712,9 @@ def _visionos_dynamic_framework_impl(ctx): providers = processor_result.providers additional_providers = [] for provider in providers: - if type(provider) == "AppleDynamicFramework": + # HACK: this should be updated so we do not need to dynamically check the provider instance. + # See: https://github.com/bazelbuild/bazel/issues/22095 + if hasattr(provider, "framework_files"): # Make the ObjC provider using the framework_files depset found # in the AppleDynamicFramework provider. This is to make the # visionos_dynamic_framework usable as a dependency in swift_library @@ -915,7 +917,7 @@ def _visionos_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1191,7 +1193,7 @@ def _visionos_extension_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), diff --git a/apple/internal/watchos_rules.bzl b/apple/internal/watchos_rules.bzl index cf8871a4aa..2215ff01a7 100644 --- a/apple/internal/watchos_rules.bzl +++ b/apple/internal/watchos_rules.bzl @@ -305,7 +305,7 @@ def _watchos_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -582,7 +582,7 @@ def _watchos_dynamic_framework_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -666,7 +666,9 @@ def _watchos_dynamic_framework_impl(ctx): providers = processor_result.providers additional_providers = [] for provider in providers: - if type(provider) == "AppleDynamicFramework": + # HACK: this should be updated so we do not need to dynamically check the provider instance. + # See: https://github.com/bazelbuild/bazel/issues/22095 + if hasattr(provider, "framework_files"): # Make the ObjC provider using the framework_files depset found # in the AppleDynamicFramework provider. This is to make the # watchos_dynamic_framework usable as a dependency in swift_library @@ -921,7 +923,7 @@ reproducible error case.".format( executable_name = executable_name, label_name = label.name, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1219,7 +1221,7 @@ def _watchos_extension_impl(ctx): label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1684,7 +1686,7 @@ delegate is referenced in the single-target `watchos_application`'s `deps`. label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -1851,7 +1853,7 @@ This attribute is deprecated, please use `extensions` instead. doc = """ In case of single-target watchOS app, a list of watchOS application extensions to include in the final watch app bundle. -In case of an extension-based watchOS app, a list with a single element, +In case of an extension-based watchOS app, a list with a single element, the watchOS 2 `watchos_extension` that is required to be bundled within a watchOS 2 app. """, ), diff --git a/apple/internal/xcframework_rules.bzl b/apple/internal/xcframework_rules.bzl index fe2845c96f..4d053c441c 100644 --- a/apple/internal/xcframework_rules.bzl +++ b/apple/internal/xcframework_rules.bzl @@ -331,7 +331,7 @@ def _create_xcframework_root_infoplist( actions, apple_fragment, available_libraries, - resolved_plisttool, + plisttool, rule_label, xcode_config): """Generates a root Info.plist for a given XCFramework. @@ -341,7 +341,7 @@ def _create_xcframework_root_infoplist( apple_fragment: An Apple fragment (ctx.fragments.apple). available_libraries: A dictionary containing keys representing how a given framework should be referenced in the root Info.plist of a given XCFramework bundle. - resolved_plisttool: A struct referencing the resolved plist tool. + plisttool: A files_to_run for the plist tool. rule_label: The label of the target being analyzed. xcode_config: The `apple_common.XcodeVersionConfig` provider from the context. @@ -380,9 +380,8 @@ def _create_xcframework_root_infoplist( actions = actions, apple_fragment = apple_fragment, arguments = [plisttool_control_file.path], - executable = resolved_plisttool.files_to_run, - inputs = depset([plisttool_control_file], transitive = [resolved_plisttool.inputs]), - input_manifests = resolved_plisttool.input_manifests, + executable = plisttool, + inputs = [plisttool_control_file], mnemonic = "CreateXCFrameworkRootInfoPlist", outputs = [root_info_plist], xcode_config = xcode_config, @@ -393,18 +392,19 @@ def _create_xcframework_bundle( *, actions, bundle_name, + bundletool, framework_archive_files, framework_archive_merge_files, framework_archive_merge_zips = [], label_name, output_archive, - resolved_bundletool, root_info_plist): """Generates the bundle archive for an XCFramework. Args: actions: The actions providerx from `ctx.actions`. bundle_name: The name of the XCFramework bundle. + bundletool: A files to run for the bundle tool. framework_archive_files: A list of depsets referencing files to be used as inputs to the bundling action. This should include every archive referenced as a "src" of framework_archive_merge_zips. @@ -419,7 +419,6 @@ def _create_xcframework_bundle( `bundle_path`. label_name: Name of the target being built. output_archive: The file representing the final bundled archive. - resolved_bundletool: A struct referencing the resolved bundle tool. root_info_plist: A `File` representing a fully formed root Info.plist for this XCFramework. """ bundletool_control_file = intermediates.file( @@ -443,12 +442,11 @@ def _create_xcframework_bundle( actions.run( arguments = [bundletool_control_file.path], - executable = resolved_bundletool.files_to_run, + executable = bundletool, inputs = depset( direct = [bundletool_control_file, root_info_plist], - transitive = [resolved_bundletool.inputs] + framework_archive_files, + transitive = framework_archive_files, ), - input_manifests = resolved_bundletool.input_manifests, mnemonic = "CreateXCFrameworkBundle", outputs = [output_archive], progress_message = "Bundling %s" % label_name, @@ -634,7 +632,7 @@ def _apple_xcframework_impl(ctx): linkmaps = link_output.linkmaps, output_discriminator = library_identifier, platform_prerequisites = platform_prerequisites, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, version = ctx.attr.version, ), @@ -742,7 +740,7 @@ def _apple_xcframework_impl(ctx): actions = actions, apple_fragment = ctx.fragments.apple, available_libraries = available_libraries, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig], ) @@ -750,12 +748,12 @@ def _apple_xcframework_impl(ctx): _create_xcframework_bundle( actions = actions, bundle_name = bundle_name, + bundletool = apple_xplat_toolchain_info.bundletool, framework_archive_files = framework_archive_files, framework_archive_merge_files = framework_archive_merge_files, framework_archive_merge_zips = framework_archive_merge_zips, label_name = label.name, output_archive = ctx.outputs.archive, - resolved_bundletool = apple_xplat_toolchain_info.resolved_bundletool, root_info_plist = root_info_plist, ) @@ -1092,7 +1090,7 @@ def _apple_static_xcframework_impl(ctx): actions = actions, apple_fragment = apple_fragment, available_libraries = available_libraries, - resolved_plisttool = apple_mac_toolchain_info.resolved_plisttool, + plisttool = apple_mac_toolchain_info.plisttool, rule_label = label, xcode_config = xcode_config, ) @@ -1100,11 +1098,11 @@ def _apple_static_xcframework_impl(ctx): _create_xcframework_bundle( actions = actions, bundle_name = bundle_name, + bundletool = apple_xplat_toolchain_info.bundletool, framework_archive_files = framework_archive_files, framework_archive_merge_files = framework_archive_merge_files, label_name = label.name, output_archive = outputs_archive, - resolved_bundletool = apple_xplat_toolchain_info.resolved_bundletool, root_info_plist = root_info_plist, ) diff --git a/apple/repositories.bzl b/apple/repositories.bzl index 1b93ea0c56..22e1d5c331 100644 --- a/apple/repositories.bzl +++ b/apple/repositories.bzl @@ -114,16 +114,16 @@ def apple_rules_dependencies(ignore_version_differences = False, include_bzlmod_ _maybe( http_archive, name = "build_bazel_apple_support", - sha256 = "a8ba6fd09d0ffeba9b5f398f3a46262470fe0addddb4ef5afa7eab18d001a7b0", - url = "https://github.com/bazelbuild/apple_support/releases/download/1.14.0/apple_support.1.14.0.tar.gz", + sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80", + url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz", ignore_version_differences = ignore_version_differences, ) _maybe( http_archive, name = "build_bazel_rules_swift", - sha256 = "9bc9dc949062405412404c0f07f7323ba310f3f91f42af414ac27e338ba7bb8c", - url = "https://github.com/bazelbuild/rules_swift/releases/download/1.17.0/rules_swift.1.17.0.tar.gz", + sha256 = "bb01097c7c7a1407f8ad49a1a0b1960655cf823c26ad2782d0b7d15b323838e2", + url = "https://github.com/bazelbuild/rules_swift/releases/download/1.18.0/rules_swift.1.18.0.tar.gz", ignore_version_differences = ignore_version_differences, ) @@ -131,21 +131,10 @@ def apple_rules_dependencies(ignore_version_differences = False, include_bzlmod_ http_archive, name = "platforms", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz", ], - sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51", - ignore_version_differences = ignore_version_differences, - ) - - _maybe( - http_archive, - name = "platforms", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", - ], - sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51", + sha256 = "5eda539c841265031c2f82d8ae7a3a6490bd62176e0c038fc469eabf91f6149b", ignore_version_differences = ignore_version_differences, ) diff --git a/apple/testing/default_runner/ios_xctestrun_runner.template.sh b/apple/testing/default_runner/ios_xctestrun_runner.template.sh index 6a61e878c4..b58202649e 100755 --- a/apple/testing/default_runner/ios_xctestrun_runner.template.sh +++ b/apple/testing/default_runner/ios_xctestrun_runner.template.sh @@ -160,6 +160,15 @@ if [[ -n "$test_host_path" ]]; then # If this is set in the case there is no test host, some tests hang indefinitely xctestrun_env+="XCInjectBundleInto$(escape "__TESTHOST__/$test_host_name.app/$test_host_name")" + developer_path="$(xcode-select -p)/Platforms/$test_execution_platform/Developer" + libraries_path="$developer_path/Library" + + # Added in Xcode 16.0 + testing_framework_path="$libraries_path/Frameworks/Testing.framework" + if [[ -d "$testing_framework_path" ]]; then + xctestrun_env+="DYLD_FRAMEWORK_PATH$libraries_path/Frameworks" + fi + if [[ "$test_type" = "XCUITEST" ]]; then xcrun_is_xctrunner_hosted_bundle="true" xcrun_is_ui_test_bundle="true" @@ -169,8 +178,6 @@ if [[ -n "$test_host_path" ]]; then readonly runner_app_name="$test_bundle_name-Runner" readonly runner_app="$runner_app_name.app" readonly runner_app_destination="$test_tmp_dir/$runner_app" - developer_path="$(xcode-select -p)/Platforms/$test_execution_platform/Developer" - libraries_path="$developer_path/Library" cp -R "$libraries_path/Xcode/Agents/XCTRunner.app" "$runner_app_destination" chmod -R 777 "$runner_app_destination" xctestrun_test_host_path="__TESTROOT__/$runner_app" @@ -190,7 +197,9 @@ if [[ -n "$test_host_path" ]]; then xcrun_test_bundle_path="__TESTHOST__/PlugIns/$test_bundle_name.xctest" /usr/bin/sed \ + -e "s@\$(WRAPPEDPRODUCTNAME)@XCTRunner@g"\ -e "s@WRAPPEDPRODUCTNAME@XCTRunner@g"\ + -e "s@\$(WRAPPEDPRODUCTBUNDLEIDENTIFIER)@$xcrun_test_host_bundle_identifier@g"\ -e "s@WRAPPEDPRODUCTBUNDLEIDENTIFIER@$xcrun_test_host_bundle_identifier@g"\ -i "" \ "$runner_app_destination/Info.plist" @@ -209,6 +218,10 @@ if [[ -n "$test_host_path" ]]; then if [[ -d "$xctestsupport_framework_path" ]]; then cp -R "$xctestsupport_framework_path" "$runner_app_frameworks_destination/XCTestSupport.framework" fi + # Added in Xcode 16.0 + if [[ -d "$testing_framework_path" ]]; then + cp -R "$testing_framework_path" "$runner_app_frameworks_destination/Testing.framework" + fi if [[ "$build_for_device" == true ]]; then # XCTRunner is multi-archs. When launching XCTRunner on arm64e device, it # will be launched as arm64e process by default. If the test bundle is arm64 diff --git a/apple/testing/default_runner/ios_xctestrun_runner.template.xctestrun b/apple/testing/default_runner/ios_xctestrun_runner.template.xctestrun index 79328eb737..4cca6158df 100644 --- a/apple/testing/default_runner/ios_xctestrun_runner.template.xctestrun +++ b/apple/testing/default_runner/ios_xctestrun_runner.template.xctestrun @@ -2,7 +2,7 @@ - BazelTests + BAZEL_TEST_PRODUCT_MODULE_NAME ProductModuleName BAZEL_TEST_PRODUCT_MODULE_NAME diff --git a/apple/testing/default_runner/simulator_creator.py b/apple/testing/default_runner/simulator_creator.py index 2bf25533d0..98fdeac646 100755 --- a/apple/testing/default_runner/simulator_creator.py +++ b/apple/testing/default_runner/simulator_creator.py @@ -46,7 +46,7 @@ def _boot_simulator(simulator_id: str) -> None: print(f"Not ignoring failure: {e.returncode}", file=sys.stderr) raise # Add more arbitrary delay before tests run. Even bootstatus doesn't wait - # long enough and tests can still fail because the simulator isn't read + # long enough and tests can still fail because the simulator isn't ready time.sleep(3) diff --git a/apple/versioning.bzl b/apple/versioning.bzl index 8411abe043..09ff7c6afd 100644 --- a/apple/versioning.bzl +++ b/apple/versioning.bzl @@ -133,13 +133,12 @@ def _apple_bundle_version_impl(ctx): ) inputs.append(control_file) - resolved_versiontool = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo].resolved_versiontool + versiontool = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo].versiontool ctx.actions.run( - executable = resolved_versiontool.executable, + executable = versiontool, arguments = [control_file.path, bundle_version_file.path], - inputs = depset(inputs, transitive = [resolved_versiontool.inputs]), - input_manifests = resolved_versiontool.input_manifests, + inputs = inputs, outputs = [bundle_version_file], mnemonic = "AppleBundleVersion", ) diff --git a/doc/rules-docc.md b/doc/rules-docc.md index 4e04c84b8b..7c1c511ddb 100755 --- a/doc/rules-docc.md +++ b/doc/rules-docc.md @@ -8,8 +8,8 @@ Defines rules for building Apple DocC targets.
 docc_archive(name, default_code_listing_language, dep, diagnostic_level, enable_inherited_docs,
-             fallback_bundle_identifier, fallback_bundle_version, fallback_display_name, kinds,
-             transform_for_static_hosting)
+             fallback_bundle_identifier, fallback_bundle_version, fallback_display_name,
+             hosting_base_path, kinds, transform_for_static_hosting)
 
Builds a .doccarchive for the given dependency. @@ -44,6 +44,7 @@ docc_archive( | fallback_bundle_identifier | A fallback bundle identifier if no value is provided in the documentation bundle's Info.plist file. | String | required | | | fallback_bundle_version | A fallback bundle version if no value is provided in the documentation bundle's Info.plist file. | String | required | | | fallback_display_name | A fallback display name if no value is provided in the documentation bundle's Info.plist file. | String | required | | +| hosting_base_path | The base path your documentation website will be hosted at. For example, to deploy your site to 'example.com/my_name/my_project/documentation' instead of 'example.com/documentation', pass '/my_name/my_project' as the base path. | String | optional | `""` | | kinds | The kinds of entities to filter generated documentation for. | List of strings | optional | `[]` | | transform_for_static_hosting | - | Boolean | optional | `True` | diff --git a/doc/rules-ios.md b/doc/rules-ios.md index 67534bfe1f..b9fd0ff770 100644 --- a/doc/rules-ios.md +++ b/doc/rules-ios.md @@ -591,7 +591,7 @@ of the attributes inherited by all test rules, please check the | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"ios"` | @@ -643,7 +643,7 @@ of the attributes inherited by all test rules, please check the | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"ios"` | diff --git a/doc/rules-macos.md b/doc/rules-macos.md index 7d6484aae2..fc6cd72ecf 100644 --- a/doc/rules-macos.md +++ b/doc/rules-macos.md @@ -638,7 +638,7 @@ Note: macOS UI tests are not currently supported in the default test runner. | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"macos"` | @@ -681,7 +681,7 @@ find more information about testing for Apple platforms | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"macos"` | diff --git a/doc/rules-tvos.md b/doc/rules-tvos.md index 0d8936c921..c347b3495c 100644 --- a/doc/rules-tvos.md +++ b/doc/rules-tvos.md @@ -350,7 +350,7 @@ the attributes inherited by all test rules, please check the | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"tvos"` | @@ -399,7 +399,7 @@ of the attributes inherited by all test rules, please check the | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"tvos"` | diff --git a/doc/rules-visionos.md b/doc/rules-visionos.md index 87e232d2ce..6000403a61 100755 --- a/doc/rules-visionos.md +++ b/doc/rules-visionos.md @@ -298,7 +298,7 @@ the attributes inherited by all test rules, please check the | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"visionos"` | @@ -347,7 +347,7 @@ of the attributes inherited by all test rules, please check the | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"visionos"` | diff --git a/doc/rules-watchos.md b/doc/rules-watchos.md index 20470e2cbc..80e315ff82 100644 --- a/doc/rules-watchos.md +++ b/doc/rules-watchos.md @@ -308,7 +308,7 @@ watchOS UI Test rule. | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"watchos"` | @@ -340,7 +340,7 @@ watchOS Unit Test rule. | deps | - | List of labels | required | | | data | Files to be made available to the test during its execution. | List of labels | optional | `[]` | | bundle_name | The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead. | String | optional | `""` | -| env | Dictionary of environment variables that should be set during the test execution. | Dictionary: String -> String | optional | `{}` | +| env | Dictionary of environment variables that should be set during the test execution. The values of the dictionary are subject to "Make" variable expansion. | Dictionary: String -> String | optional | `{}` | | minimum_deployment_os_version | A required string indicating the minimum deployment OS version supported by the target, represented as a dotted version number (for example, "9.0"). This is different from `minimum_os_version`, which is effective at compile time. Ensure version specific APIs are guarded with `available` clauses. | String | optional | `""` | | minimum_os_version | A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0"). | String | required | | | platform_type | - | String | optional | `"watchos"` | diff --git a/test/ios_test_runner_unit_test.sh b/test/ios_test_runner_unit_test.sh index 39bb01e15c..80c23db6bc 100755 --- a/test/ios_test_runner_unit_test.sh +++ b/test/ios_test_runner_unit_test.sh @@ -323,6 +323,79 @@ ios_unit_test( EOF } +function create_ios_unit_make_var_test() { + if [[ ! -f ios/BUILD ]]; then + fail "create_sim_runners must be called first." + fi + + cat > ios/make_var_unit_test.m < +#include +#include + +@interface MakeVarUnitTest : XCTestCase + +@end + +@implementation MakeVarUnitTest + +- (void)testMakeVar { + XCTAssertEqualObjects([NSProcessInfo processInfo].environment[@"MY_MAKE_VAR"], @"$1", @"should pass"); +} + +@end +EOF + + cat >ios/MakeVarUnitTest-Info.plist < + + CFBundleExecutable + MakeVarUnitTest + +
+EOF + + cat >> ios/BUILD < ios/make_var_unit_test.m < +#include +#include + +@interface MakeVarUnitTest : XCTestCase + +@end + +@implementation MakeVarUnitTest + +- (void)testMakeVar { + XCTAssertEqualObjects([NSProcessInfo processInfo].environment[@"MY_MAKE_VAR"], @"$1", @"should pass"); +} + +@end +EOF + + cat >ios/MakeVarUnitTest-Info.plist < + + CFBundleExecutable + MakeVarUnitTest + + +EOF + + cat >> ios/BUILD <> app/BUILD < + +void MyLibFunc(const char *myString) { std::cout << myString << "\n"; } diff --git a/test/starlark_tests/resources/ccinfo_dylibs/mylib/lib.hpp b/test/starlark_tests/resources/ccinfo_dylibs/mylib/lib.hpp new file mode 100644 index 0000000000..ccb1e37d3f --- /dev/null +++ b/test/starlark_tests/resources/ccinfo_dylibs/mylib/lib.hpp @@ -0,0 +1,3 @@ +#pragma once + +void MyLibFunc(const char *myString); diff --git a/test/starlark_tests/targets_under_test/ios/BUILD b/test/starlark_tests/targets_under_test/ios/BUILD index 28c78092c4..3fc666031f 100644 --- a/test/starlark_tests/targets_under_test/ios/BUILD +++ b/test/starlark_tests/targets_under_test/ios/BUILD @@ -4877,6 +4877,24 @@ swift_library( visibility = ["//visibility:public"], ) +objc_library( + name = "basic_objc_lib_with_data_and_docc_bundle_dependency", + srcs = [ + "//test/starlark_tests/resources:shared.h", + "//test/starlark_tests/resources:shared.m", + ], + data = ["//test/starlark_tests/resources:additional.txt"], + deps = [":basic_framework_lib_with_docc_bundle"], +) + +docc_archive( + name = "basic_objc_lib_with_data_and_docc_bundle_dependency.doccarchive", + dep = ":basic_objc_lib_with_data_and_docc_bundle_dependency", + fallback_bundle_identifier = "com.google.example.objc.lib", + fallback_bundle_version = "1.0", + fallback_display_name = "BasicLib", +) + ios_dynamic_framework( name = "basic_framework_with_docc_bundle", bundle_id = "com.google.example.framework", @@ -4902,3 +4920,37 @@ docc_archive( fallback_bundle_version = "1.0", fallback_display_name = "BasicFramework", ) + +docc_archive( + name = "basic_framework_with_docc_bundle_custom_base_path.doccarchive", + dep = ":basic_framework_with_docc_bundle", + fallback_bundle_identifier = "com.google.example.framework", + fallback_bundle_version = "1.0", + fallback_display_name = "BasicFramework", + hosting_base_path = "custom/base/path", +) + +# --------------------------------------------------------------------------------------- +# Target for extension resource bundling. + +ios_extension( + name = "ext_with_resources", + bundle_id = "com.google.example.ext_with_resources", + entitlements = "//test/starlark_tests/resources:entitlements.plist", + families = [ + "iphone", + "ipad", + ], + infoplists = [ + "//test/starlark_tests/resources:Info.plist", + ], + minimum_os_version = common.min_os_ios.baseline, + provisioning_profile = "//test/testdata/provisioning:integration_testing_ios.mobileprovision", + resources = [ + "//test/starlark_tests/resources:additional.txt", + ], + tags = common.fixture_tags, + deps = [ + "//test/starlark_tests/resources:objc_main_lib", + ], +) diff --git a/test/starlark_tests/targets_under_test/macos/BUILD b/test/starlark_tests/targets_under_test/macos/BUILD index ed0cfdefd3..4c93c02f60 100644 --- a/test/starlark_tests/targets_under_test/macos/BUILD +++ b/test/starlark_tests/targets_under_test/macos/BUILD @@ -2907,3 +2907,17 @@ macos_unit_test( "//test/starlark_tests/resources:objc_test_lib", ], ) + +# --------------------------------------------------------------------------------------- +# Targets for CcInfo dylib bundling tests + +macos_application( + name = "app_with_ccinfo_dylib_deps", + bundle_id = "com.google.example", + infoplists = [ + "//test/starlark_tests/resources:Info.plist", + ], + minimum_os_version = common.min_os_macos.baseline, + tags = common.fixture_tags, + deps = ["//test/starlark_tests/resources:ccinfo_dylibs_libapp"], +) diff --git a/tools/bundletool/bundletool_experimental.py b/tools/bundletool/bundletool_experimental.py index 065e91b8f3..6d706801c0 100644 --- a/tools/bundletool/bundletool_experimental.py +++ b/tools/bundletool/bundletool_experimental.py @@ -172,7 +172,7 @@ def _add_files(self, src, dest, executable, bundle_root): self._copy_file(src, dest, executable, bundle_root) def _add_zip_contents(self, src, dest, bundle_root): - """Adds the contents of another ZIP file to the bundle. + """Adds the contents of another ZIP file/App to the bundle. Args: src: The path to the file or directory that should be added. @@ -182,19 +182,30 @@ def _add_zip_contents(self, src, dest, bundle_root): bundle_root: The bundle root directory into which the files should be added. """ - with zipfile.ZipFile(src, 'r') as src_zip: - for src_zipinfo in src_zip.infolist(): - # Normalize the destination path to remove any extraneous internal - # slashes or "." segments, but retain the final slash for directory - # entries. - file_dest = os.path.normpath(os.path.join(dest, src_zipinfo.filename)) - if src_zipinfo.filename.endswith('/'): - continue - - # Check for Unix --x--x--x permissions. - executable = src_zipinfo.external_attr >> 16 & 0o111 != 0 - data = src_zip.read(src_zipinfo) - self._write_entry(file_dest, data, executable, bundle_root) + # Some bundle_zip entries may be bundled apps which are nested + # into the current bundle. + _, ext = os.path.splitext(src) + if ext == ".app": + # If so, we can just copy those into the expected location + # without any additional processing + app_name = os.path.basename(src) + shutil.copytree(src, os.path.join(bundle_root, dest, app_name)) + else: + with zipfile.ZipFile(src, "r") as src_zip: + for src_zipinfo in src_zip.infolist(): + # Normalize the destination path to remove any extraneous internal + # slashes or "." segments, but retain the final slash for directory + # entries. + file_dest = os.path.normpath( + os.path.join(dest, src_zipinfo.filename) + ) + if src_zipinfo.filename.endswith("/"): + continue + + # Check for Unix --x--x--x permissions. + executable = src_zipinfo.external_attr >> 16 & 0o111 != 0 + data = src_zip.read(src_zipinfo) + self._write_entry(file_dest, data, executable, bundle_root) def _copy_file(self, src, dest, executable, bundle_root): """Copies a file into the bundle.