2018-11-30 20:30:09 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
# Copyright 2018 Google LLC.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2019-08-07 19:02:59 +00:00
|
|
|
from subprocess import call, check_output, CalledProcessError
|
2018-11-30 20:30:09 +00:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
|
2018-12-03 17:49:51 +00:00
|
|
|
HEADER = '''<!DOCTYPE html>
|
2018-11-30 20:30:09 +00:00
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>SkQP Pre-built APKs</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
font-family:sans-serif;
|
2018-12-03 17:49:51 +00:00
|
|
|
max-width:50em;
|
2018-11-30 20:30:09 +00:00
|
|
|
margin:8px auto;
|
|
|
|
padding:0 8px;
|
|
|
|
}
|
2018-12-03 17:49:51 +00:00
|
|
|
table { max-width:100%; border-collapse: collapse; }
|
|
|
|
td { padding:12px 8px; vertical-align:top; }
|
|
|
|
tr:nth-child(even) {background: #F2F2F2; color:#000;}
|
|
|
|
tr:nth-child(odd) {background: #FFFFFF; color:#000;}
|
2018-11-30 20:30:09 +00:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>SkQP Pre-built APKs</h1>
|
|
|
|
'''
|
2018-12-03 17:49:51 +00:00
|
|
|
FOOTER = '</body>\n</html>\n'
|
|
|
|
|
|
|
|
BUCKET = 'skia-skqp'
|
|
|
|
|
|
|
|
NAME_FMT = 'skqp-universal-%s.apk'
|
|
|
|
|
|
|
|
def get_existing_files():
|
|
|
|
cmd = ['gsutil', 'ls', 'gs://' + BUCKET]
|
|
|
|
try:
|
|
|
|
output = check_output(cmd)
|
|
|
|
except (OSError, CalledProcessError):
|
|
|
|
sys.stderr.write('command: "%s" failed.\n' % ' '.join(cmd))
|
|
|
|
sys.exit(1)
|
|
|
|
result = set()
|
|
|
|
regex = re.compile('gs://%s/%s' % (BUCKET, NAME_FMT % '([0-9a-f]+)'))
|
|
|
|
for line in output.split('\n'):
|
|
|
|
m = regex.match(line.strip())
|
|
|
|
if m is not None:
|
|
|
|
result.add(m.group(1))
|
|
|
|
return result
|
|
|
|
|
|
|
|
def find(v, extant):
|
|
|
|
l = min(16, len(v))
|
|
|
|
while l > 8:
|
|
|
|
if v[:l] in extant:
|
|
|
|
return v[:l]
|
|
|
|
l -= 1
|
2018-11-30 20:30:09 +00:00
|
|
|
return None
|
|
|
|
|
2018-12-03 17:49:51 +00:00
|
|
|
def nowrap(s):
|
|
|
|
return (s.replace(' ', u'\u00A0'.encode('utf-8'))
|
|
|
|
.replace('-', u'\u2011'.encode('utf-8')))
|
|
|
|
|
2019-08-07 19:02:59 +00:00
|
|
|
def rev_parse(arg):
|
|
|
|
if isinstance(arg, tuple):
|
|
|
|
remote_url, branch = arg
|
|
|
|
for remote in check_output(['git', 'remote']).strip().split('\n'):
|
|
|
|
remote = remote.strip()
|
|
|
|
url = check_output(['git', 'remote', 'get-url', remote]).strip()
|
|
|
|
if url == remote_url:
|
|
|
|
arg = remote + '/' + branch
|
|
|
|
break
|
|
|
|
return check_output(['git', 'rev-parse', arg]).strip()
|
|
|
|
|
|
|
|
|
|
|
|
def table(o, remote, branch, excludes):
|
2018-11-30 20:30:09 +00:00
|
|
|
env_copy = os.environ.copy()
|
|
|
|
env_copy['TZ'] = ''
|
2018-12-03 17:49:51 +00:00
|
|
|
extant = get_existing_files()
|
2019-08-07 19:02:59 +00:00
|
|
|
|
|
|
|
commits = [rev_parse((remote, branch))]
|
|
|
|
for exclude in excludes:
|
|
|
|
commits.append('^' + rev_parse(exclude))
|
|
|
|
|
|
|
|
o.write('<h2>Remote: %s<br>Branch: %s</h2>\n' % (remote, branch))
|
2018-11-30 20:30:09 +00:00
|
|
|
o.write('<table>\n<tr><th>APK</th><th>Date</th><th>Commit</th></tr>\n')
|
2018-12-03 17:49:51 +00:00
|
|
|
git_cmd = ['git', 'log', '--format=%H;%cd;%<(100,trunc)%s',
|
2019-08-07 19:02:59 +00:00
|
|
|
'--date=format-local:%Y-%m-%d %H:%M:%S %Z'] + commits
|
2018-12-03 17:49:51 +00:00
|
|
|
commits = check_output(git_cmd, env=env_copy)
|
|
|
|
for line in commits.split('\n'):
|
|
|
|
line = line.strip()
|
|
|
|
if not line:
|
2018-11-30 20:30:09 +00:00
|
|
|
continue
|
2018-12-03 17:49:51 +00:00
|
|
|
commit, date, subj = line.split(';', 2)
|
|
|
|
short = find(commit, extant)
|
|
|
|
if short is not None:
|
|
|
|
apk_name = NAME_FMT % short
|
|
|
|
url = 'https://storage.googleapis.com/%s/%s' % (BUCKET, apk_name)
|
2018-11-30 20:30:09 +00:00
|
|
|
else:
|
2018-12-03 17:49:51 +00:00
|
|
|
apk_name, url = '', ''
|
2019-08-07 19:02:59 +00:00
|
|
|
commit_url = '%s/+/%s' % (remote, commit)
|
2018-11-30 20:30:09 +00:00
|
|
|
o.write('<tr>\n<td><a href="%s">%s</a></td>\n'
|
|
|
|
'<td>%s</td>\n<td><a href="%s">%s</a></td>\n</tr>\n' %
|
2018-12-03 17:49:51 +00:00
|
|
|
(url, nowrap(apk_name), nowrap(date), commit_url, subj))
|
2018-11-30 20:30:09 +00:00
|
|
|
o.write('</table>\n')
|
|
|
|
|
2018-12-03 17:49:51 +00:00
|
|
|
def main():
|
2019-08-07 19:02:59 +00:00
|
|
|
origin = 'https://skia.googlesource.com/skia'
|
|
|
|
aosp_skqp = 'https://android.googlesource.com/platform/external/skqp'
|
|
|
|
|
2018-12-03 17:49:51 +00:00
|
|
|
assert '/' in [os.sep, os.altsep] and '..' == os.pardir
|
|
|
|
os.chdir(os.path.join(os.path.dirname(__file__), '../..'))
|
2018-11-30 20:30:09 +00:00
|
|
|
d = tempfile.mkdtemp()
|
|
|
|
path = os.path.join(d, 'apklist.html')
|
|
|
|
with open(path, 'w') as o:
|
2018-12-03 17:49:51 +00:00
|
|
|
o.write(HEADER)
|
2019-08-07 19:02:59 +00:00
|
|
|
table(o, origin, 'skqp/dev', [(origin, 'master'), '3e34285f2a0'])
|
|
|
|
table(o, origin, 'skqp/release', [(origin, 'master'), '09ab171c5c0'])
|
|
|
|
table(o, aosp_skqp, 'pie-cts-dev', ['f084c17322'])
|
2018-12-03 17:49:51 +00:00
|
|
|
o.write(FOOTER)
|
2018-11-30 20:30:09 +00:00
|
|
|
print path
|
2019-08-07 19:02:59 +00:00
|
|
|
call([sys.executable, 'bin/sysopen', path])
|
2018-12-03 17:49:51 +00:00
|
|
|
gscmd = 'gsutil -h "Content-Type:text/html" cp "%s" gs://skia-skqp/apklist'
|
|
|
|
print gscmd % path
|
2018-11-30 20:30:09 +00:00
|
|
|
|
2018-12-03 17:49:51 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
2018-11-30 20:30:09 +00:00
|
|
|
|