-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload debug symbols in engine v2 fuchsia build. (#47626)
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
1 parent
29a5fff
commit 72262a2
Showing
2 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |