diff --git a/ci/builders/linux_fuchsia.json b/ci/builders/linux_fuchsia.json index 72a72490e303c..da37bd6cd81a1 100644 --- a/ci/builders/linux_fuchsia.json +++ b/ci/builders/linux_fuchsia.json @@ -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": [ @@ -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": { @@ -164,7 +192,7 @@ "parameters": [ "--engine-version", "${REVISION}", - "--upload", + "--upload", "--target-arch", "arm64", "--out-dir", @@ -182,7 +210,7 @@ "parameters": [ "--engine-version", "${REVISION}", - "--upload", + "--upload", "--target-arch", "x64", "--out-dir", diff --git a/tools/fuchsia/upload_to_symbol_server.py b/tools/fuchsia/upload_to_symbol_server.py new file mode 100755 index 0000000000000..dabd8728f1d46 --- /dev/null +++ b/tools/fuchsia/upload_to_symbol_server.py @@ -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())