mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #24146 from drodriguez/android-faster-adb-push
[android] Make ADB push use sync if available.
This commit is contained in:
@@ -44,10 +44,24 @@ def rmdir(path):
|
||||
shell(['rm', '-rf', '{}/*'.format(path)])
|
||||
|
||||
|
||||
def push(local_path, device_path):
|
||||
"""Move the file at the given local path to the path on the device."""
|
||||
return subprocess.check_output(['adb', 'push', local_path, device_path],
|
||||
stderr=subprocess.STDOUT).strip()
|
||||
def push(local_paths, device_path):
|
||||
"""Move the files at the given local paths to the path on the device."""
|
||||
if isinstance(local_paths, str):
|
||||
local_paths = [local_paths]
|
||||
try:
|
||||
# In recent versions of ADB, push supports --sync, which checksums the
|
||||
# files to be transmitted and skip the ones that haven't changed, which
|
||||
# improves the effective transfer speed.
|
||||
return subprocess.check_output(
|
||||
['adb', 'push', '--sync'] + local_paths + [device_path],
|
||||
stderr=subprocess.STDOUT).strip()
|
||||
except subprocess.CalledProcessError as e:
|
||||
if "unrecognized option '--sync'" in e.output:
|
||||
return subprocess.check_output(
|
||||
['adb', 'push'] + local_paths + [device_path],
|
||||
stderr=subprocess.STDOUT).strip()
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
def reboot():
|
||||
|
||||
@@ -53,9 +53,9 @@ def argument_parser():
|
||||
return parser
|
||||
|
||||
|
||||
def _push(source, destination):
|
||||
print('Pushing "{}" to device path "{}".'.format(source, destination))
|
||||
print(adb.commands.push(source, destination))
|
||||
def _push(sources, destination):
|
||||
print('Pushing "{}" to device path "{}".'.format(sources, destination))
|
||||
print(adb.commands.push(sources, destination))
|
||||
|
||||
|
||||
def main():
|
||||
@@ -70,8 +70,10 @@ def main():
|
||||
|
||||
for path in args.paths:
|
||||
if os.path.isdir(path):
|
||||
for basename in glob.glob(os.path.join(path, '*.so')):
|
||||
_push(os.path.join(path, basename), args.destination)
|
||||
full_paths = [
|
||||
os.path.join(path, basename)
|
||||
for basename in glob.glob(os.path.join(path, '*.so'))]
|
||||
_push(full_paths, args.destination)
|
||||
else:
|
||||
_push(path, args.destination)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user