Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
upload_to_symbol_server.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Uploads debug symbols to the symbols server."""
8
9import argparse
10import os
11import subprocess
12import sys
13import tempfile
14
15## Path to the engine root checkout. This is used to calculate absolute
16## paths if relative ones are passed to the script.
17BUILD_ROOT_DIR = os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..', '..'))
18FUCHSIA_ARTIFACTS_DEBUG_NAMESPACE = 'debug'
19FUCHSIA_ARTIFACTS_BUCKET_NAME = 'fuchsia-artifacts-release'
20
21
22def remote_filename(exec_path):
23 # An example of exec_path is:
24 # out/fuchsia_debug_x64/flutter-fuchsia-x64/d4/917f5976.debug
25 # In the above example "d4917f5976" is the elf BuildID for the
26 # executable. First 2 characters are used as the directory name
27 # and the rest of the string is the name of the unstripped executable.
28 parts = exec_path.split('/')
29 # We want d4917f5976.debug as the result.
30 return ''.join(parts[-2:])
31
32
33def exists_remotely(remote_path):
34 gsutil = os.path.join(os.environ['DEPOT_TOOLS'], 'gsutil.py')
35 command = ['python3', gsutil, '--', 'stat', remote_path]
36 process = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
37 stdout, stderr = process.communicate()
38 return_code = process.wait()
39 if return_code == 0:
40 print('%s exists - skipping copy' % remote_path)
41 return return_code == 0
42
43
44def process_symbols(should_upload, symbol_dir):
45 full_path = os.path.join(BUILD_ROOT_DIR, symbol_dir)
46
47 files = []
48 for (dirpath, dirnames, filenames) in os.walk(full_path):
49 files.extend([os.path.join(dirpath, f) for f in filenames])
50
51 print('List of files to upload')
52 print('\n'.join(files))
53
54 # Remove dbg_files
55 files = [f for f in files if 'dbg_success' not in f]
56
57 for file in files:
58 remote_path = 'gs://%s/%s/%s' % (
59 FUCHSIA_ARTIFACTS_BUCKET_NAME, FUCHSIA_ARTIFACTS_DEBUG_NAMESPACE, remote_filename(file)
60 )
61 if should_upload and not exists_remotely(remote_path):
62 gsutil = os.path.join(os.environ['DEPOT_TOOLS'], 'gsutil.py')
63 command = ['python3', gsutil, '--', 'cp', file, remote_path]
64 subprocess.check_call(command)
65 else:
66 print(remote_path)
67
68
69def main():
70 parser = argparse.ArgumentParser()
71
72 parser.add_argument(
73 '--symbol-dir', required=True, help='Directory that contain the debug symbols.'
74 )
75 parser.add_argument('--engine-version', required=True, help='Specifies the flutter engine SHA.')
76 parser.add_argument(
77 '--upload', default=False, action='store_true', help='If set, uploads symbols to the server.'
78 )
79
80 args = parser.parse_args()
81
82 should_upload = args.upload
83 engine_version = args.engine_version
84 if not engine_version:
85 engine_version = 'HEAD'
86 should_upload = False
87
88 process_symbols(should_upload, args.symbol_dir)
89 return 0
90
91
92if __name__ == '__main__':
93 sys.exit(main())
void print(void *str)
Definition bridge.cpp:126
Definition main.py:1
process_symbols(should_upload, symbol_dir)