From fdb07d06f722eaeb4f5d4d04f47b6605e0b2bc0c Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 23 Feb 2024 15:43:38 -0800 Subject: [PATCH 1/3] Add watchos_device_arm64(e) CPUs (#2342) --- apple/BUILD | 3 ++- platform_mappings | 8 ++++++++ test/apple_shell_testutils.sh | 2 +- .../apple_dynamic_xcframework_import_tests.bzl | 18 ++++++++++++++++++ .../targets_under_test/watchos/BUILD | 4 +++- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/apple/BUILD b/apple/BUILD index 7bb43b8ef0..7bab0297f4 100644 --- a/apple/BUILD +++ b/apple/BUILD @@ -1,5 +1,5 @@ -load(":cc_toolchain_forwarder.bzl", "cc_toolchain_forwarder") load("@bazel_skylib//:bzl_library.bzl", "bzl_library") +load(":cc_toolchain_forwarder.bzl", "cc_toolchain_forwarder") package(default_visibility = ["//visibility:public"]) @@ -27,6 +27,7 @@ licenses(["notice"]) "watchos_arm64_32", "watchos_x86_64", "watchos_device_arm64", + "watchos_device_arm64e", ] ] diff --git a/platform_mappings b/platform_mappings index 713740331a..da82b541dd 100644 --- a/platform_mappings +++ b/platform_mappings @@ -75,6 +75,14 @@ platforms: --apple_platform_type=watchos --cpu=watchos_arm64_32 + @build_bazel_apple_support//platforms:watchos_device_arm64 + --apple_platform_type=watchos + --cpu=watchos_device_arm64 + + @build_bazel_apple_support//platforms:watchos_device_arm64e + --apple_platform_type=watchos + --cpu=watchos_device_arm64e + flags: --cpu=darwin_x86_64 --apple_platform_type=macos diff --git a/test/apple_shell_testutils.sh b/test/apple_shell_testutils.sh index eb635e82a8..1d6df0b313 100755 --- a/test/apple_shell_testutils.sh +++ b/test/apple_shell_testutils.sh @@ -384,7 +384,7 @@ function current_archs() { value="$(echo "$option" | cut -d= -f2)" else # Eliminate `sim_` prefixes from `cpu`s as it is not part of the arch. - value="$(echo "$option" | cut -d= -f2 | sed 's/sim_//g')" + value="$(echo "$option" | cut -d= -f2 | sed -e 's/sim_//g' -e 's/device_//g')" fi echo "$value" | tr "," "\n" return diff --git a/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl b/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl index b0ef7575a6..72fa31b4c5 100644 --- a/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl +++ b/test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl @@ -292,6 +292,24 @@ def apple_dynamic_xcframework_import_test_suite(name): cpus = {"watchos_cpus": ["arm64_32"]}, macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOS"], ) + archive_contents_test( + name = "{}_links_watchos_device_arm64_macho_load_cmd_for_device_test".format(name), + build_type = "device", + target_under_test = "//test/starlark_tests/targets_under_test/watchos:app_with_imported_xcframework", + binary_test_file = "$BUNDLE_ROOT/Frameworks/generated_dynamic_watchos_xcframework.framework/generated_dynamic_watchos_xcframework", + binary_test_architecture = "arm64", + cpus = {"watchos_cpus": ["device_arm64"]}, + macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOS"], + ) + archive_contents_test( + name = "{}_links_watchos_device_arm64e_macho_load_cmd_for_device_test".format(name), + build_type = "device", + target_under_test = "//test/starlark_tests/targets_under_test/watchos:app_with_imported_xcframework", + binary_test_file = "$BUNDLE_ROOT/Frameworks/generated_dynamic_watchos_xcframework.framework/generated_dynamic_watchos_xcframework", + binary_test_architecture = "arm64e", + cpus = {"watchos_cpus": ["device_arm64e"]}, + macho_load_commands_contain = ["cmd LC_BUILD_VERSION", "platform WATCHOS"], + ) # Verify tvos_application bundles XCFramework library for device and simulator architectures. archive_contents_test( diff --git a/test/starlark_tests/targets_under_test/watchos/BUILD b/test/starlark_tests/targets_under_test/watchos/BUILD index f07749e44b..829d3607e6 100644 --- a/test/starlark_tests/targets_under_test/watchos/BUILD +++ b/test/starlark_tests/targets_under_test/watchos/BUILD @@ -1120,8 +1120,10 @@ generate_dynamic_xcframework( }, platforms = { "watchos": [ - "armv7k", + "arm64", "arm64_32", + "arm64e", + "armv7k", ], "watchos_simulator": [ "x86_64", From 6a3a36e4b88fc0e9076cb916ee1a900debe213d3 Mon Sep 17 00:00:00 2001 From: Aaron Sky Date: Fri, 23 Feb 2024 19:17:13 -0500 Subject: [PATCH 2/3] Allow underscores in bundle identifiers (#2411) --- apple/internal/bundling_support.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/internal/bundling_support.bzl b/apple/internal/bundling_support.bzl index 30f0dcccb8..0c96222a52 100644 --- a/apple/internal/bundling_support.bzl +++ b/apple/internal/bundling_support.bzl @@ -377,7 +377,7 @@ def _validate_bundle_id(bundle_id): # handled by the split(), so just have to check for '-'. for i in range(len(part)): ch = part[i] - if ch != "-" and not ch.isalnum(): + if ch not in ["-", "_"] and not ch.isalnum(): fail("Invalid character(s) in bundle_id: \"%s\"" % bundle_id) # Define the loadable module that lists the exported symbols in this file. From 5db6e74a143d15ba327f6f8cb3bff4459bf7d49d Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Fri, 23 Feb 2024 19:35:00 -0500 Subject: [PATCH 3/3] Fix DWARF binary not copied for AppleDsymBundleInfo (#2396) From what I can tell the `AppleDebugInfo` provider correctly gives us the binary paths, the only difference is that `AppleDsymBundleInfo` seems to add a `/dSYMS/` directory path. This PR updates to copy to the dwarf binaries the correct `/dSYMS/` as well. Co-authored-by: Matt Robinson --- apple/internal/partials/debug_symbols.bzl | 16 ++++++++++++---- test/starlark_tests/xcarchive_tests.bzl | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apple/internal/partials/debug_symbols.bzl b/apple/internal/partials/debug_symbols.bzl index a7351a5d32..c2595f39ba 100644 --- a/apple/internal/partials/debug_symbols.bzl +++ b/apple/internal/partials/debug_symbols.bzl @@ -106,7 +106,7 @@ def _collect_linkmaps( return outputs -def _copy_dsyms_into_declared_bundle( +def _generate_dsym_binaries( *, actions, debug_output_filename, @@ -303,13 +303,21 @@ def _bundle_dsym_files( found_binaries_by_arch.update(dsym_binaries) if found_binaries_by_arch: - output_files = _copy_dsyms_into_declared_bundle( + generated_dsym_binaries = _generate_dsym_binaries( actions = actions, debug_output_filename = dsym_output_filename, dsym_bundle_name = dsym_bundle_name, found_binaries_by_arch = found_binaries_by_arch, platform_prerequisites = platform_prerequisites, ) + output_files.extend(generated_dsym_binaries) + dsyms_command = (" && ".join([ + "cp \"{dsym_path}\" \"${{OUTPUT_DIR}}/Contents/Resources/DWARF/{dsym_bundle_name}\"".format( + dsym_path = dsym_binary.path, + dsym_bundle_name = dsym_output_filename, + ) + for dsym_binary in generated_dsym_binaries + ])) # If we found any binaries, create the Info.plist for the bundle as well. dsym_plist = _generate_dsym_info_plist( @@ -334,9 +342,9 @@ def _bundle_dsym_files( apple_support.run_shell( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, - inputs = [dsym_plist] + found_binaries_by_arch.values(), + inputs = generated_dsym_binaries + [dsym_plist] + found_binaries_by_arch.values(), outputs = [dsym_bundle_dir], - command = ("mkdir -p \"${OUTPUT_DIR}/Contents/Resources/DWARF\" && " + plist_command), + command = ("mkdir -p \"${OUTPUT_DIR}/Contents/Resources/DWARF\" && " + dsyms_command + " && " + plist_command), env = { "OUTPUT_DIR": dsym_bundle_dir.path, }, diff --git a/test/starlark_tests/xcarchive_tests.bzl b/test/starlark_tests/xcarchive_tests.bzl index ebd868c0a2..4c1f0f2130 100644 --- a/test/starlark_tests/xcarchive_tests.bzl +++ b/test/starlark_tests/xcarchive_tests.bzl @@ -53,6 +53,8 @@ def xcarchive_test_suite(name): target_under_test = "//test/starlark_tests/targets_under_test/ios:app_minimal.xcarchive", contains = [ "$BUNDLE_ROOT/dSYMs/app_minimal.app.dSYM", + "$BUNDLE_ROOT/dSYMs/app_minimal.app.dSYM/Contents/Resources/DWARF/app_minimal", + "$BUNDLE_ROOT/dSYMs/app_minimal.app.dSYM/Contents/Info.plist", "$BUNDLE_ROOT/Info.plist", "$BUNDLE_ROOT/Products/Applications/app_minimal.app", ], @@ -76,6 +78,8 @@ def xcarchive_test_suite(name): contains = [ "$BUNDLE_ROOT/dSYMs/app_with_ext_space_in_path.app.dSYM", "$BUNDLE_ROOT/dSYMs/ext with space.appex.dSYM", + "$BUNDLE_ROOT/dSYMs/ext with space.appex.dSYM/Contents/Resources/DWARF/ext with space", + "$BUNDLE_ROOT/dSYMs/ext with space.appex.dSYM/Contents/Info.plist", "$BUNDLE_ROOT/Info.plist", "$BUNDLE_ROOT/Products/Applications/app_with_ext_space_in_path.app", ],