dart-sdk/tools/download_abi_dills.py
Nate Bosch 55f81f2210 Mass format python with yapf
- Add `.style.yapf` with configuration to use Google style.
- Run `yapf` on all `.py` files in this repo.
- Manually fix one trailing space in a doc string.
- Run `git cl format runtime` to satisfy presubmit.

Change-Id: I7e6bd11e91f07926b9188362599af398551eed79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111600
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2019-08-05 20:34:31 +00:00

50 lines
1.2 KiB
Python

# Downloads dill files from CIPD for each supported ABI version.
import os
import subprocess
import sys
import utils
def procWait(p):
while p.returncode is None:
p.communicate()
p.poll()
return p.returncode
def findAbiVersion(version):
cmd = ['cipd', 'instances', 'dart/abiversions/%d' % version]
p = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=utils.IsWindows(),
cwd=utils.DART_DIR)
return procWait(p) == 0
def main():
abi_version = int(utils.GetAbiVersion())
oldest_abi_version = int(utils.GetOldestSupportedAbiVersion())
cmd = ['cipd', 'ensure', '-root', 'tools/abiversions', '-ensure-file', '-']
ensure_file = ''
for i in range(oldest_abi_version, abi_version + 1):
if findAbiVersion(i):
ensure_file += '@Subdir %d\ndart/abiversions/%d latest\n\n' % (i, i)
if not ensure_file:
return 0
p = subprocess.Popen(
cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=utils.IsWindows(),
cwd=utils.DART_DIR)
p.communicate(ensure_file)
p.stdin.close()
return procWait(p)
if __name__ == '__main__':
sys.exit(main())