Import Cobalt 21.master.0.253153
diff --git a/src/third_party/skia/bin/droid b/src/third_party/skia/bin/droid
index c633181..53deb5b 100755
--- a/src/third_party/skia/bin/droid
+++ b/src/third_party/skia/bin/droid
@@ -8,15 +8,23 @@
#
# See https://skia.org/user/quick/gn for build instructions.
-path=$1
-name=$(basename $1)
+dst_dir=/data/local/tmp
+path="$1"
+name="$(basename "$path")"
shift
-args=$@
+
+if ! [ -d resources ]; then
+ echo run this from the skia tree
+ exit 1
+fi
+
+dirs=''
+for dir in $(find resources -type d); do dirs="$dirs \"${dir}\""; done
set -e
set -x
-adb push $path //data/local/tmp/
-adb push resources //data/local/tmp/
-adb shell "chmod +x //data/local/tmp/$name"
-adb shell "cd //data/local/tmp; ./$name $args"
+adb shell "cd \"$dst_dir\"; mkdir -p $dirs"
+adb push --sync resources "${dst_dir}/"
+adb push --sync "$path" "${dst_dir}/${name}"
+adb shell "cd \"$dst_dir\"; chmod +x \"$name\"; \"./$name\" $*"
diff --git a/src/third_party/skia/bin/fetch-clang-format b/src/third_party/skia/bin/fetch-clang-format
index 78b5c05..98216d8 100755
--- a/src/third_party/skia/bin/fetch-clang-format
+++ b/src/third_party/skia/bin/fetch-clang-format
@@ -19,7 +19,11 @@
'buildtools/mac/' + target if 'darwin' in sys.platform else \
'buildtools/win/'+ target + '.exe'
- sha1 = open(target_path + '.sha1').read().strip()
+ sha1_path = target_path + '.sha1'
+ if not os.path.exists(sha1_path):
+ print sha1_path, 'is missing. Did you run `tools/git-sync-deps`?'
+ exit(1)
+ sha1 = open(sha1_path).read().strip()
def sha1_of_file(path):
h = hashlib.sha1()
diff --git a/src/third_party/skia/bin/fetch-gn b/src/third_party/skia/bin/fetch-gn
index d5de7e4..5d03fd3 100755
--- a/src/third_party/skia/bin/fetch-gn
+++ b/src/third_party/skia/bin/fetch-gn
@@ -14,11 +14,11 @@
os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
-gn_path = 'buildtools/linux64/gn' if 'linux' in sys.platform else \
- 'buildtools/mac/gn' if 'darwin' in sys.platform else \
- 'buildtools/win/gn.exe'
+dst = 'bin/gn.exe' if 'win32' in sys.platform else 'bin/gn'
-sha1 = open(gn_path + '.sha1').read().strip()
+sha1 = '3523d50538357829725d4ed74b777a572ce0ac74' if 'linux' in sys.platform else \
+ 'd43122f6140d0711518aa909980cb009c4fbce3d' if 'darwin' in sys.platform else \
+ 'e20768d93a6b4400de0d03bb8ceb46facdbe3883' # Windows
def sha1_of_file(path):
h = hashlib.sha1()
@@ -27,15 +27,17 @@
h.update(f.read())
return h.hexdigest()
-if sha1_of_file(gn_path) != sha1:
- with open(gn_path, 'wb') as f:
+if sha1_of_file(dst) != sha1:
+ with open(dst, 'wb') as f:
f.write(urllib2.urlopen('https://chromium-gn.storage-download.googleapis.com/' + sha1).read())
- os.chmod(gn_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
- stat.S_IRGRP | stat.S_IXGRP |
- stat.S_IROTH | stat.S_IXOTH )
+ os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
+ stat.S_IRGRP | stat.S_IXGRP |
+ stat.S_IROTH | stat.S_IXOTH )
-gn_copy_path = os.path.join('bin', os.path.basename(gn_path))
-if sha1_of_file(gn_copy_path) != sha1:
- shutil.copy(gn_path, gn_copy_path)
-
+# We'll also copy to a path that depot_tools' GN wrapper will expect to find the binary.
+copy_path = 'buildtools/linux64/gn' if 'linux' in sys.platform else \
+ 'buildtools/mac/gn' if 'darwin' in sys.platform else \
+ 'buildtools/win/gn.exe'
+if os.path.isdir(os.path.dirname(copy_path)):
+ shutil.copy(dst, copy_path)
diff --git a/src/third_party/skia/bin/fetch-skps b/src/third_party/skia/bin/fetch-skps
index 19f46e3..e576859 100755
--- a/src/third_party/skia/bin/fetch-skps
+++ b/src/third_party/skia/bin/fetch-skps
@@ -1,6 +1,8 @@
#!/bin/sh
# Copies the latest bot-generated SKP set to ./skps.
+# If you are having trouble, please refer to the instructions at:
+# https://sites.google.com/a/google.com/skia/key-resources/skps
set -x
set -e
diff --git a/src/third_party/skia/bin/fetch-svgs b/src/third_party/skia/bin/fetch-svgs
new file mode 100755
index 0000000..a58d74e
--- /dev/null
+++ b/src/third_party/skia/bin/fetch-svgs
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Copies the latest bot-generated SVG set to ./svgs.
+
+set -x
+set -e
+
+DOWNLOAD_SCRIPT=$(cd $(dirname $0)/..; pwd)/infra/bots/assets/svg/download.py
+python ${DOWNLOAD_SCRIPT} -t $(pwd)/svgs
diff --git a/src/third_party/skia/bin/gerrit-number b/src/third_party/skia/bin/gerrit-number
new file mode 100755
index 0000000..d9707c0
--- /dev/null
+++ b/src/third_party/skia/bin/gerrit-number
@@ -0,0 +1,61 @@
+#!/usr/bin/env python2
+# Copyright 2017 Google Inc.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import re
+import subprocess
+import sys
+import urllib
+
+# TODO(halcanary): document functions and script usage.
+
+def retrieve_changeid(commit_or_branch):
+ try:
+ cmd = ['git', 'log', '-1', '--format=%B', commit_or_branch, '--']
+ body = subprocess.check_output(cmd)
+ except OSError:
+ raise Exception('git not found')
+ except subprocess.CalledProcessError:
+ raise Exception('`%s` failed' % ' '.join(cmd))
+ match = re.search(r'^Change-Id: *(.*) *$', body, re.MULTILINE)
+ if match is None:
+ raise Exception('Change-Id field missing from commit %s' % commit_or_branch)
+ return match.group(1)
+
+
+def gerrit_change_id_to_number(site, cid):
+ url = 'https://%s/changes/?q=change:%s' % (site, cid)
+ try:
+ content = urllib.urlopen(url).read()
+ except IOError:
+ raise Exception('error reading "%s"' % url)
+ try:
+ parsed = json.loads(content[content.find('['):])
+ except ValueError:
+ raise Exception('unable to parse content\n"""\n%s\n"""' % content)
+ try:
+ return parsed[0]['_number']
+ except (IndexError, KeyError):
+ raise Exception('Content missing\n"""\n%s\n"""' %
+ json.dumps(parsed, indent=2))
+
+
+def args_to_changeid(argv):
+ if len(argv) == 2 and len(argv[1]) == 41 and argv[1][0] == 'I':
+ return argv[1]
+ else:
+ return retrieve_changeid(argv[1] if len(argv) == 2 else 'HEAD')
+
+
+if __name__ == '__main__':
+ try:
+ sys.stdout.write('%d\n' %
+ gerrit_change_id_to_number('skia-review.googlesource.com',
+ args_to_changeid(sys.argv)))
+ except Exception as e:
+ sys.stderr.write('%s\n' % e)
+ sys.exit(1)
+
+
diff --git a/src/third_party/skia/bin/list-skia-bots b/src/third_party/skia/bin/list-skia-bots
old mode 100644
new mode 100755
diff --git a/src/third_party/skia/bin/sync b/src/third_party/skia/bin/sync
index 163584d..c75cdbd 100755
--- a/src/third_party/skia/bin/sync
+++ b/src/third_party/skia/bin/sync
@@ -1,53 +1,16 @@
#!/usr/bin/env python
-
# Copyright 2016 Google Inc.
-#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# This script will update Skia's dependencies as necessary.
+"""
+Calls `GIT_SYNC_DEPS_QUIET=T tools/git-sync-deps`.
+"""
-# Depends on: Python and Git
-
-# To retreive and use all optional deps:
-#
-# python bin/sync --deps=all
-
-import hashlib
import os
import subprocess
import sys
-HASH_FILE = '.deps_sha1'
-DEPS_FLAG = '--deps='
-DEPS_FILE = 'DEPS'
-
-skia_opt_deps = [arg[len(DEPS_FLAG):] for arg in sys.argv[1:] if arg.startswith(DEPS_FLAG)]
-
-os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
-
-if not os.path.isfile(DEPS_FILE):
- sys.stderr.write('DEPS file missing')
- exit(1)
-
-deps_hasher = hashlib.sha1()
-with open(DEPS_FILE, 'r') as f:
- deps_hasher.update(f.read())
-deps_hasher.update(repr(skia_opt_deps))
-deps_hash = deps_hasher.hexdigest()
-current_deps_hash = None
-if os.path.isfile(HASH_FILE):
- with open(HASH_FILE, 'r') as f:
- current_deps_hash = f.read().strip()
-
-if current_deps_hash != deps_hash:
- if os.path.isfile(HASH_FILE):
- os.remove(HASH_FILE)
- command = [sys.executable, os.path.join('tools', 'git-sync-deps')]
- command.extend(skia_opt_deps)
- sys.stdout.write('%r\n' % command)
- sys.stdout.flush()
- subprocess.check_call(command)
- # Only write hash after a successful sync.
- with open(HASH_FILE, 'w') as o:
- o.write(deps_hash)
+path = os.path.dirname(__file__) + '/../tools/git-sync-deps'
+subprocess.check_call([sys.executable, path] + sys.argv[:1],
+ env=dict(os.environ, GIT_SYNC_DEPS_QUIET='T'))
diff --git a/src/third_party/skia/bin/sysopen b/src/third_party/skia/bin/sysopen
new file mode 100755
index 0000000..84100c2
--- /dev/null
+++ b/src/third_party/skia/bin/sysopen
@@ -0,0 +1,25 @@
+#! /usr/bin/env python2
+# Copyright 2017 Google Inc.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import subprocess
+import sys
+
+def spawn(cmd):
+ with open(os.devnull, 'w') as o:
+ subprocess.Popen(cmd, stdout=o, stderr=o)
+
+def sysopen(arg):
+ plat = sys.platform
+ if plat.startswith('darwin'):
+ spawn(["open", arg])
+ elif plat.startswith('win'):
+ os.startfile(arg)
+ else:
+ spawn(["xdg-open", arg])
+
+if __name__ == '__main__':
+ for a in sys.argv[1:]:
+ sysopen(a)
diff --git a/src/third_party/skia/bin/try b/src/third_party/skia/bin/try
new file mode 100755
index 0000000..6bc08bd
--- /dev/null
+++ b/src/third_party/skia/bin/try
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+# Copyright 2017 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+base_dir=$(dirname "$0")
+
+python "$base_dir/try.py" "$@"
diff --git a/src/third_party/skia/bin/try-clients b/src/third_party/skia/bin/try-clients
new file mode 100755
index 0000000..8d9f9b4
--- /dev/null
+++ b/src/third_party/skia/bin/try-clients
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+# Copyright 2019 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+base_dir=$(dirname "$0")
+
+python "$base_dir/try.py" "mac_chromium_compile_dbg|G3_Framework|Android_Framework|Build-.*-Flutter"
diff --git a/src/third_party/skia/bin/try.bat b/src/third_party/skia/bin/try.bat
new file mode 100644
index 0000000..a0685c7
--- /dev/null
+++ b/src/third_party/skia/bin/try.bat
@@ -0,0 +1,6 @@
+@echo off
+:: Copyright 2017 Google Inc.
+::
+:: Use of this source code is governed by a BSD-style license that can be
+:: found in the LICENSE file.
+python "%~dp0\try.py" %*
diff --git a/src/third_party/skia/bin/try.py b/src/third_party/skia/bin/try.py
new file mode 100755
index 0000000..f86f2cd
--- /dev/null
+++ b/src/third_party/skia/bin/try.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python
+
+# Copyright 2017 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+"""Submit one or more try jobs."""
+
+
+import argparse
+import json
+import os
+import re
+import subprocess
+import sys
+import tempfile
+
+
+BUCKET_SKIA_PRIMARY = 'skia.primary'
+BUCKET_SKIA_INTERNAL = 'skia.internal'
+CHECKOUT_ROOT = os.path.realpath(os.path.join(
+ os.path.dirname(os.path.abspath(__file__)), os.pardir))
+INFRA_BOTS = os.path.join(CHECKOUT_ROOT, 'infra', 'bots')
+JOBS_JSON = os.path.join(INFRA_BOTS, 'jobs.json')
+REPO_INTERNAL = 'https://skia.googlesource.com/internal_test.git'
+TMP_DIR = os.path.join(tempfile.gettempdir(), 'sktry')
+
+sys.path.insert(0, INFRA_BOTS)
+
+import update_meta_config
+import utils
+
+
+def get_jobs(repo):
+ """Obtain the list of jobs from the given repo."""
+ # Maintain a copy of the repo in the temp dir.
+ if not os.path.isdir(TMP_DIR):
+ os.mkdir(TMP_DIR)
+ with utils.chdir(TMP_DIR):
+ dirname = repo.split('/')[-1]
+ if not os.path.isdir(dirname):
+ subprocess.check_call([
+ utils.GIT, 'clone', '--mirror', repo, dirname])
+ with utils.chdir(dirname):
+ subprocess.check_call([utils.GIT, 'remote', 'update'])
+ jobs = json.loads(subprocess.check_output([
+ utils.GIT, 'show', 'master:infra/bots/jobs.json']))
+ return (BUCKET_SKIA_INTERNAL, jobs)
+
+
+def main():
+ # Parse arguments.
+ d = 'Helper script for triggering try jobs defined in %s.' % JOBS_JSON
+ parser = argparse.ArgumentParser(description=d)
+ parser.add_argument('--list', action='store_true', default=False,
+ help='Just list the jobs; do not trigger anything.')
+ parser.add_argument('--internal', action='store_true', default=False,
+ help=('If set, include internal jobs. You must have '
+ 'permission to view internal repos.'))
+ parser.add_argument('job', nargs='?', default=None,
+ help='Job name or regular expression to match job names.')
+ args = parser.parse_args()
+
+ # Load and filter the list of jobs.
+ jobs = []
+ with open(JOBS_JSON) as f:
+ jobs.append((BUCKET_SKIA_PRIMARY, json.load(f)))
+ if args.internal:
+ jobs.append(get_jobs(REPO_INTERNAL))
+ jobs.extend(update_meta_config.CQ_INCLUDE_CHROMIUM_TRYBOTS)
+ if args.job:
+ filtered_jobs = []
+ for bucket, job_list in jobs:
+ filtered = [j for j in job_list if re.search(args.job, j)]
+ if len(filtered) > 0:
+ filtered_jobs.append((bucket, filtered))
+ jobs = filtered_jobs
+
+ # Display the list of jobs.
+ if len(jobs) == 0:
+ print 'Found no jobs matching "%s"' % repr(args.job)
+ sys.exit(1)
+ count = 0
+ for bucket, job_list in jobs:
+ count += len(job_list)
+ print 'Found %d jobs:' % count
+ for bucket, job_list in jobs:
+ print ' %s:' % bucket
+ for j in job_list:
+ print ' %s' % j
+ if args.list:
+ return
+
+ if count > 1:
+ # Prompt before triggering jobs.
+ resp = raw_input('\nDo you want to trigger these jobs? (y/n or i for '
+ 'interactive): ')
+ print ''
+ if resp != 'y' and resp != 'i':
+ sys.exit(1)
+ if resp == 'i':
+ filtered_jobs = []
+ for bucket, job_list in jobs:
+ new_job_list = []
+ for j in job_list:
+ incl = raw_input(('Trigger %s? (y/n): ' % j))
+ if incl == 'y':
+ new_job_list.append(j)
+ if len(new_job_list) > 0:
+ filtered_jobs.append((bucket, new_job_list))
+ jobs = filtered_jobs
+
+ # Trigger the try jobs.
+ for bucket, job_list in jobs:
+ cmd = ['git', 'cl', 'try', '-B', bucket]
+ for j in job_list:
+ cmd.extend(['-b', j])
+ try:
+ subprocess.check_call(cmd)
+ except subprocess.CalledProcessError:
+ # Output from the command will fall through, so just exit here rather than
+ # printing a stack trace.
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ main()