Allow for downloading open source apps as an x20 dependency
This reduces what needs to be downloaded on builders and runners.
Change-Id: Ia494dc0058e06c7a042704c3fdddcb88d849a24e
diff --git a/tools/download_all_benchmark_dependencies.py b/tools/download_all_benchmark_dependencies.py
new file mode 100755
index 0000000..43ec0ab
--- /dev/null
+++ b/tools/download_all_benchmark_dependencies.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+# Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+# Utility script to make it easier to update what golem builds.
+
+import gradle
+import sys
+import utils
+
+BUILD_TARGETS = ['downloadDeps', 'downloadAndroidCts', 'downloadDx']
+
+def Main():
+ gradle.RunGradle(BUILD_TARGETS)
+ # Download opensource_apps and place in build.
+ utils.DownloadFromX20(utils.OPENSOURCE_APPS_SHA_FILE)
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/tools/run_on_as_app.py b/tools/run_on_as_app.py
index fd1bacf..f1948db 100755
--- a/tools/run_on_as_app.py
+++ b/tools/run_on_as_app.py
@@ -18,12 +18,15 @@
import as_utils
SHRINKERS = ['r8', 'r8-full', 'pg']
-WORKING_DIR = utils.BUILD
+WORKING_DIR = os.path.join(utils.BUILD, 'opensource_apps')
if ('R8_BENCHMARK_DIR' in os.environ
and os.path.isdir(os.environ['R8_BENCHMARK_DIR'])):
WORKING_DIR = os.environ['R8_BENCHMARK_DIR']
+# For running on Golem all APPS are bundled as an x20-dependency and then copied
+# to WORKING_DIR. To make it easier to update the app-bundle, remove the folder
+# WORKING_DIR and then run run_on_as_app.py --download-only.
APPS = {
# 'app-name': {
# 'git_repo': ...
@@ -257,7 +260,7 @@
result = {}
- if not os.path.exists(checkout_dir):
+ if not os.path.exists(checkout_dir) and not options.golem:
with utils.ChangedWorkingDirectory(WORKING_DIR, quiet=options.quiet):
GitClone(config['git_repo'], config['revision'], checkout_dir, options)
@@ -629,6 +632,14 @@
result.add_option('--app',
help='What app to run on',
choices=APPS.keys())
+ result.add_option('--download-only', '--download_only',
+ help='Whether to download apps without any compilation',
+ default=False,
+ action='store_true')
+ result.add_option('--golem',
+ help='Running on golem, do not download',
+ default=False,
+ action='store_true')
result.add_option('--gradle-flags', '--gradle_flags',
help='Flags to pass in to gradle')
result.add_option('--ignore-versions', '--ignore_versions',
@@ -680,13 +691,34 @@
assert shrinker in SHRINKERS
return (options, args)
+def download_apps(options):
+ # Download apps and place in build
+ with utils.ChangedWorkingDirectory(WORKING_DIR):
+ for app, config in APPS.iteritems():
+ app_dir = os.path.join(WORKING_DIR, app)
+ if not os.path.exists(app_dir):
+ GitClone(config['git_repo'], config['revision'], app_dir, options)
+
+
def main(argv):
global SHRINKERS
(options, args) = ParseOptions(argv)
+ if options.golem:
+ if os.path.exists(WORKING_DIR):
+ shutil.rmtree(WORKING_DIR)
+ shutil.copytree(utils.OPENSOURCE_APPS_FOLDER, WORKING_DIR)
+
+ if not os.path.exists(WORKING_DIR):
+ os.makedirs(WORKING_DIR)
+
+ if options.download_only:
+ download_apps(options)
+ return
+
with utils.TempDir() as temp_dir:
- if not options.no_build:
+ if not options.no_build or options.golem:
gradle.RunGradle(['r8lib'])
assert os.path.isfile(utils.R8LIB_JAR), 'Cannot build without r8lib.jar'
diff --git a/tools/utils.py b/tools/utils.py
index 8d7ec14..08faec6 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -62,6 +62,10 @@
CF_SEGMENTS_TOOL = os.path.join(THIRD_PARTY, 'cf_segments')
PINNED_R8_JAR = os.path.join(REPO_ROOT, 'third_party/r8/r8.jar')
PINNED_PGR8_JAR = os.path.join(REPO_ROOT, 'third_party/r8/r8-pg6.0.1.jar')
+OPENSOURCE_APPS_SHA_FILE = os.path.join(
+ REPO_ROOT,
+ 'third_party/opensource_apps.tar.gz.sha1')
+OPENSOURCE_APPS_FOLDER = os.path.join(REPO_ROOT, 'third_party/opensource_apps/')
# Common environment setup.