Skip to content

Commit

Permalink
Fix DWARF binary not copied for AppleDsymBundleInfo (#2396)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
luispadron and mattrobmattrob committed Feb 24, 2024
1 parent 6a3a36e commit 5db6e74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
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
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 5db6e74

Please sign in to comment.