Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
| 6 | import os |
| 7 | import run_on_as_app |
| 8 | import shutil |
Rico Wind | ec283b5 | 2019-04-03 15:16:55 +0200 | [diff] [blame] | 9 | import subprocess |
Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 10 | import sys |
Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 11 | import utils |
| 12 | |
| 13 | def main(): |
Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 14 | working_dir = run_on_as_app.WORKING_DIR |
| 15 | |
| 16 | print 'Removing directories that do not match checked out revision' |
Rico Wind | ec283b5 | 2019-04-03 15:16:55 +0200 | [diff] [blame] | 17 | if not os.path.exists(working_dir): |
| 18 | os.makedirs(working_dir) |
| 19 | else: |
Christoffer Quist Adamsen | 0333299 | 2019-03-07 15:19:09 +0100 | [diff] [blame] | 20 | for repo in run_on_as_app.APP_REPOSITORIES: |
| 21 | repo_dir = os.path.join(working_dir, repo.name) |
| 22 | if os.path.exists(repo_dir) \ |
| 23 | and utils.get_HEAD_sha1_for_checkout(repo_dir) != repo.revision: |
| 24 | print 'Removing %s' % repo_dir |
| 25 | shutil.rmtree(repo_dir) |
Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 26 | |
| 27 | print 'Downloading all missing apps' |
Christoffer Quist Adamsen | 0333299 | 2019-03-07 15:19:09 +0100 | [diff] [blame] | 28 | run_on_as_app.clone_repositories(quiet=False) |
Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 29 | |
Rico Wind | ec283b5 | 2019-04-03 15:16:55 +0200 | [diff] [blame] | 30 | # Package all files as cloud dependency |
| 31 | print 'Creating archive for opensource_apps (this may take some time)' |
| 32 | if os.path.exists(utils.OPENSOURCE_APPS_FOLDER): |
| 33 | shutil.rmtree(utils.OPENSOURCE_APPS_FOLDER) |
| 34 | for repo in run_on_as_app.APP_REPOSITORIES: |
| 35 | repo_dir = os.path.join(working_dir, repo.name) |
Morten Krogh-Jespersen | bee9bec | 2019-10-30 09:18:39 +0100 | [diff] [blame] | 36 | # Ensure there is a local gradle user home in the folder |
| 37 | for app in repo.apps: |
| 38 | app_checkout_dir = (os.path.join(repo_dir, app.dir) |
| 39 | if app.dir else repo_dir) |
| 40 | gradle_user_home = os.path.join( |
| 41 | app_checkout_dir, run_on_as_app.GRADLE_USER_HOME) |
| 42 | if not os.path.exists(gradle_user_home): |
| 43 | print 'Could not find the local gradle cache at %s. You should run ' \ |
| 44 | 'run_on_as_app for app %s at least once.' \ |
| 45 | % (gradle_user_home, repo.name) |
| 46 | sys.exit(1) |
Rico Wind | ec283b5 | 2019-04-03 15:16:55 +0200 | [diff] [blame] | 47 | dst = os.path.join(utils.OPENSOURCE_APPS_FOLDER, repo.name) |
| 48 | shutil.copytree(repo_dir, dst) |
| 49 | |
| 50 | with utils.ChangedWorkingDirectory(utils.THIRD_PARTY): |
| 51 | subprocess.check_call(['upload_to_google_storage.py', '-a', '--bucket', |
| 52 | 'r8-deps', 'opensource_apps']) |
Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 53 | |
Morten Krogh-Jespersen | 271e75c | 2019-03-15 12:23:17 +0100 | [diff] [blame] | 54 | print 'To have apps benchmarked on Golem, the updated apps have to be ' \ |
| 55 | 'downloaded to the runners by ssh\'ing into each runner and do:\n' \ |
| 56 | 'cd ../golem\n' \ |
| 57 | 'update_dependencies.sh\n' |
Morten Krogh-Jespersen | 5409086 | 2019-02-19 11:31:10 +0100 | [diff] [blame] | 58 | |
| 59 | if __name__ == '__main__': |
| 60 | sys.exit(main()) |