Skip to content

Commit

Permalink
Merge branch 'master' into fix/dy-fmk-loss-in-impl-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemotongye committed Feb 26, 2024
2 parents 287fcf8 + 5db6e74 commit 6c0dc19
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 8 deletions.
3 changes: 2 additions & 1 deletion apple/BUILD
Original file line number Diff line number Diff line change
@@ -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"])

Expand Down Expand Up @@ -27,6 +27,7 @@ licenses(["notice"])
"watchos_arm64_32",
"watchos_x86_64",
"watchos_device_arm64",
"watchos_device_arm64e",
]
]

Expand Down
2 changes: 1 addition & 1 deletion apple/internal/bundling_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 12 additions & 4 deletions apple/internal/partials/debug_symbols.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _collect_linkmaps(

return outputs

def _copy_dsyms_into_declared_bundle(
def _generate_dsym_binaries(
*,
actions,
debug_output_filename,
Expand Down Expand Up @@ -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(
Expand All @@ -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,
},
Expand Down
8 changes: 8 additions & 0 deletions platform_mappings
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/apple_shell_testutils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/starlark_tests/apple_dynamic_xcframework_import_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,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(
Expand Down
4 changes: 3 additions & 1 deletion test/starlark_tests/targets_under_test/watchos/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,10 @@ generate_dynamic_xcframework(
},
platforms = {
"watchos": [
"armv7k",
"arm64",
"arm64_32",
"arm64e",
"armv7k",
],
"watchos_simulator": [
"x86_64",
Expand Down
4 changes: 4 additions & 0 deletions test/starlark_tests/xcarchive_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand All @@ -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",
],
Expand Down

0 comments on commit 6c0dc19

Please sign in to comment.