Skip to content

Commit

Permalink
Upload debug symbols in engine v2 fuchsia build. (#47626)
Browse files Browse the repository at this point in the history
This is the last missing piece to migrate fuchsia to engine v2 and will allow us to remove more of the old recipe versions.

Bug: flutter/flutter#135189

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
godofredoc authored Nov 3, 2023
1 parent 29a5fff commit 72262a2
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 4 deletions.
36 changes: 32 additions & 4 deletions ci/builders/linux_fuchsia.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,21 @@
"flutter/shell/platform/fuchsia:fuchsia",
"fuchsia_tests"
]
}
},
"tests": [
{
"name": "Upload to Symbol Server for arch: arm64",
"language": "python3",
"script": "flutter/tools/fuchsia/upload_to_symbol_server.py",
"parameters": [
"--symbol-dir",
"out/fuchsia_debug_arm64/.build-id",
"--engine-version",
"${REVISION}",
"--upload"
]
}
]
},
{
"drone_dimensions": [
Expand Down Expand Up @@ -143,7 +157,21 @@
"flutter/shell/platform/fuchsia:fuchsia",
"fuchsia_tests"
]
}
},
"tests": [
{
"name": "Upload to Symbol Server for arch: x64",
"language": "python3",
"script": "flutter/tools/fuchsia/upload_to_symbol_server.py",
"parameters": [
"--symbol-dir",
"out/fuchsia_debug_x64/.build-id",
"--engine-version",
"${REVISION}",
"--upload"
]
}
]
}
],
"generators": {
Expand All @@ -164,7 +192,7 @@
"parameters": [
"--engine-version",
"${REVISION}",
"--upload",
"--upload",
"--target-arch",
"arm64",
"--out-dir",
Expand All @@ -182,7 +210,7 @@
"parameters": [
"--engine-version",
"${REVISION}",
"--upload",
"--upload",
"--target-arch",
"x64",
"--out-dir",
Expand Down
89 changes: 89 additions & 0 deletions tools/fuchsia/upload_to_symbol_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Uploads debug symbols to the symbols server."""

import argparse
import os
import subprocess
import sys
import tempfile

## Path to the engine root checkout. This is used to calculate absolute
## paths if relative ones are passed to the script.
BUILD_ROOT_DIR = os.path.abspath(
os.path.join(os.path.realpath(__file__), '..', '..', '..', '..')
)
FUCHSIA_ARTIFACTS_DEBUG_NAMESPACE = 'debug'
FUCHSIA_ARTIFACTS_BUCKET_NAME = 'fuchsia-artifacts-release'


def remote_filename(exec_path):
# An example of exec_path is:
# out/fuchsia_debug_x64/flutter-fuchsia-x64/d4/917f5976.debug
# In the above example "d4917f5976" is the elf BuildID for the
# executable. First 2 characters are used as the directory name
# and the rest of the string is the name of the unstripped executable.
parts = exec_path.split('/')
# We want d4917f5976.debug as the result.
return ''.join(parts[-2:])


def process_symbols(should_upload, symbol_dir):
full_path = os.path.join(BUILD_ROOT_DIR, symbol_dir)

files = []
for (dirpath, dirnames, filenames) in os.walk(full_path):
files.extend([os.path.join(dirpath, f) for f in filenames])

# Remove dbg_files
files = [f for f in files if 'dbg_success' not in f]

for file in files:
remote_path = 'gs://%s/%s' % (
FUCHSIA_ARTIFACTS_BUCKET_NAME, remote_filename(file)
)
if should_upload:
command = 'gsutil cp %s %s' % (full_path, remote_path)
subprocess.check_call(command)
else:
print(remote_path)


def main():
parser = argparse.ArgumentParser()

parser.add_argument(
'--symbol-dir',
required=True,
help='Directory that contain the debug symbols.'
)
parser.add_argument(
'--engine-version',
required=True,
help='Specifies the flutter engine SHA.'
)
parser.add_argument(
'--upload',
default=False,
action='store_true',
help='If set, uploads symbols to the server.'
)

args = parser.parse_args()

should_upload = args.upload
engine_version = args.engine_version
if not engine_version:
engine_version = 'HEAD'
should_upload = False

process_symbols(should_upload, args.symbol_dir)
return 0


if __name__ == '__main__':
sys.exit(main())

0 comments on commit 72262a2

Please sign in to comment.