OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import argparse | 6 import argparse |
| 7 import glob |
7 import imp | 8 import imp |
| 9 import itertools |
8 import os | 10 import os |
9 import subprocess | 11 import subprocess |
10 import sys | 12 import sys |
11 import tempfile | 13 import tempfile |
12 import time | 14 import time |
13 import zipfile | 15 import zipfile |
14 | 16 |
| 17 sys.path.append(os.path.join(os.path.dirname(__file__), |
| 18 os.pardir, 'third_party', 'pyelftools')) |
| 19 import elftools.elf.elffile as elffile |
| 20 |
| 21 sys.path.append(os.path.join(os.path.dirname(__file__), |
| 22 os.pardir, 'third_party', 'mojo_devtools')) |
| 23 import android_gdb.signatures as signatures |
| 24 |
15 SERVICES = ["network_service", "network_service_apptests"] | 25 SERVICES = ["network_service", "network_service_apptests"] |
16 | 26 |
17 # A service does not need to expose interfaces. Those that do expose interfaces | 27 # A service does not need to expose interfaces. Those that do expose interfaces |
18 # have their mojoms located in the directories listed below, in paths relative | 28 # have their mojoms located in the directories listed below, in paths relative |
19 # to the directory of this script. | 29 # to the directory of this script. |
20 MOJOMS_IN_DIR = { | 30 MOJOMS_IN_DIR = { |
21 "network_service": os.path.join("network", "public", "interfaces") | 31 "network_service": os.path.join("network", "public", "interfaces") |
22 } | 32 } |
23 | 33 |
24 # The network service is downloaded out-of-band rather than dynamically by the | 34 # The network service is downloaded out-of-band rather than dynamically by the |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 with tempfile.NamedTemporaryFile() as mojom_zip_file: | 89 with tempfile.NamedTemporaryFile() as mojom_zip_file: |
80 with zipfile.ZipFile(mojom_zip_file, 'w') as z: | 90 with zipfile.ZipFile(mojom_zip_file, 'w') as z: |
81 for root, _, files in os.walk(absolute_mojom_directory_path): | 91 for root, _, files in os.walk(absolute_mojom_directory_path): |
82 for filename in files: | 92 for filename in files: |
83 absolute_file_path = os.path.join(root, filename) | 93 absolute_file_path = os.path.join(root, filename) |
84 relative_file_path = os.path.relpath(absolute_file_path, root) | 94 relative_file_path = os.path.relpath(absolute_file_path, root) |
85 z.write(absolute_file_path, relative_file_path) | 95 z.write(absolute_file_path, relative_file_path) |
86 gsutil_cp(mojom_zip_file.name, dest, dry_run) | 96 gsutil_cp(mojom_zip_file.name, dest, dry_run) |
87 | 97 |
88 | 98 |
| 99 def upload_symbols(binary_dir, dry_run): |
| 100 dest_dir = "gs://mojo/symbols/" |
| 101 symbols_dir = os.path.join(binary_dir, "symbols") |
| 102 for name in os.listdir(symbols_dir): |
| 103 path = os.path.join(symbols_dir, name) |
| 104 with open(path) as f: |
| 105 signature = signatures.get_signature(f, elffile) |
| 106 if signature is not None: |
| 107 dest = dest_dir + signature |
| 108 gsutil_cp(path, dest, dry_run) |
| 109 |
89 def upload_binary(version_name, service, binary_dir, platform, dry_run): | 110 def upload_binary(version_name, service, binary_dir, platform, dry_run): |
90 dest_dir = "gs://mojo/" + service + "/" + version_name + "/" + platform + "/" | 111 dest_dir = "gs://mojo/" + service + "/" + version_name + "/" + platform + "/" |
91 should_zip = service in SERVICES_WITH_ZIPPED_BINARIES | 112 should_zip = service in SERVICES_WITH_ZIPPED_BINARIES |
92 binary_name = service + ".mojo" | 113 binary_name = service + ".mojo" |
93 absolute_binary_path = os.path.join(root_path, binary_dir, binary_name) | 114 absolute_binary_path = os.path.join(root_path, binary_dir, binary_name) |
94 | 115 |
95 if not should_zip: | 116 if not should_zip: |
96 # Upload the binary. | 117 # Upload the binary. |
97 dest = dest_dir + binary_name | 118 dest = dest_dir + binary_name |
98 gsutil_cp(absolute_binary_path, dest, dry_run) | 119 gsutil_cp(absolute_binary_path, dest, dry_run) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 "--android-arm-binary-dir", | 154 "--android-arm-binary-dir", |
134 help="Path to the dir containing the android-arm service binary relative " | 155 help="Path to the dir containing the android-arm service binary relative " |
135 "to the repo root, e.g. out/android_Release") | 156 "to the repo root, e.g. out/android_Release") |
136 parser.add_argument("service", | 157 parser.add_argument("service", |
137 help="The service to be uploaded (one of %s)" % SERVICES) | 158 help="The service to be uploaded (one of %s)" % SERVICES) |
138 parser.add_argument( | 159 parser.add_argument( |
139 "--custom-build", action="store_true", | 160 "--custom-build", action="store_true", |
140 help="Indicates that this is a build with change that is not committed. " | 161 help="Indicates that this is a build with change that is not committed. " |
141 "The change must be uploaded to Rietveld. The script needs to be " | 162 "The change must be uploaded to Rietveld. The script needs to be " |
142 "run from the branch associated with the change.") | 163 "run from the branch associated with the change.") |
| 164 parser.add_argument( |
| 165 "--upload-symbols", action="store_true", |
| 166 help="Indicates that this should also upload all symbols.") |
143 args = parser.parse_args() | 167 args = parser.parse_args() |
144 | 168 |
145 if args.service not in SERVICES: | 169 if args.service not in SERVICES: |
146 print args.service + " is not one of the recognized services:" | 170 print args.service + " is not one of the recognized services:" |
147 print SERVICES | 171 print SERVICES |
148 return 1 | 172 return 1 |
149 | 173 |
150 version_name = get_version_name(args.custom_build) | 174 version_name = get_version_name(args.custom_build) |
151 if args.custom_build and not version_name: | 175 if args.custom_build and not version_name: |
152 print ("When uploading a custom build, the corresponding change to source " | 176 print ("When uploading a custom build, the corresponding change to source " |
153 "code must be uploaded to Rietveld. Besides, this script needs to " | 177 "code must be uploaded to Rietveld. Besides, this script needs to " |
154 "be run from the branch associated with the change.") | 178 "be run from the branch associated with the change.") |
155 return 1 | 179 return 1 |
156 | 180 |
157 if args.service in MOJOMS_IN_DIR: | 181 if args.service in MOJOMS_IN_DIR: |
158 script_dir = os.path.dirname(os.path.realpath(__file__)) | 182 script_dir = os.path.dirname(os.path.realpath(__file__)) |
159 absolute_mojom_directory_path = os.path.join(script_dir, | 183 absolute_mojom_directory_path = os.path.join(script_dir, |
160 MOJOMS_IN_DIR[args.service]) | 184 MOJOMS_IN_DIR[args.service]) |
161 upload_mojoms(version_name, args.service, absolute_mojom_directory_path, | 185 upload_mojoms(version_name, args.service, absolute_mojom_directory_path, |
162 args.dry_run) | 186 args.dry_run) |
163 | 187 |
164 if args.linux_x64_binary_dir: | 188 if args.linux_x64_binary_dir: |
165 upload_binary(version_name, args.service, args.linux_x64_binary_dir, | 189 upload_binary(version_name, args.service, args.linux_x64_binary_dir, |
166 "linux-x64", args.dry_run) | 190 "linux-x64", args.dry_run) |
| 191 if args.upload_symbols: |
| 192 upload_symbols(args.linux_x64_binary_dir, args.dry_run) |
167 | 193 |
168 if args.android_arm_binary_dir: | 194 if args.android_arm_binary_dir: |
169 upload_binary(version_name, args.service, args.android_arm_binary_dir, | 195 upload_binary(version_name, args.service, args.android_arm_binary_dir, |
170 "android-arm", args.dry_run) | 196 "android-arm", args.dry_run) |
| 197 if args.upload_symbols: |
| 198 upload_symbols(args.android_arm_binary_dir, args.dry_run) |
171 | 199 |
172 if not args.dry_run: | 200 if not args.dry_run: |
173 print "Uploaded artifacts for version %s" % (version_name, ) | 201 print "Uploaded artifacts for version %s" % (version_name, ) |
174 else: | 202 else: |
175 print "No artifacts uploaded (dry run)" | 203 print "No artifacts uploaded (dry run)" |
176 return 0 | 204 return 0 |
177 | 205 |
178 if __name__ == '__main__': | 206 if __name__ == '__main__': |
179 sys.exit(main()) | 207 sys.exit(main()) |
OLD | NEW |