blob: 2d8a83b8c2d2e911b691587976cfae0b3f8a52cc [file] [log] [blame]
Morten Krogh-Jespersen54090862019-02-19 11:31:10 +01001#!/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
6import os
7import run_on_as_app
8import shutil
Rico Windec283b52019-04-03 15:16:55 +02009import subprocess
Morten Krogh-Jespersen54090862019-02-19 11:31:10 +010010import sys
Morten Krogh-Jespersen54090862019-02-19 11:31:10 +010011import utils
12
13def main():
Morten Krogh-Jespersen54090862019-02-19 11:31:10 +010014 working_dir = run_on_as_app.WORKING_DIR
15
16 print 'Removing directories that do not match checked out revision'
Rico Windec283b52019-04-03 15:16:55 +020017 if not os.path.exists(working_dir):
18 os.makedirs(working_dir)
19 else:
Christoffer Quist Adamsen03332992019-03-07 15:19:09 +010020 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-Jespersen54090862019-02-19 11:31:10 +010026
27 print 'Downloading all missing apps'
Christoffer Quist Adamsen03332992019-03-07 15:19:09 +010028 run_on_as_app.clone_repositories(quiet=False)
Morten Krogh-Jespersen54090862019-02-19 11:31:10 +010029
Rico Windec283b52019-04-03 15:16:55 +020030 # 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-Jespersenbee9bec2019-10-30 09:18:39 +010036 # 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 Windec283b52019-04-03 15:16:55 +020047 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-Jespersen54090862019-02-19 11:31:10 +010053
Morten Krogh-Jespersen271e75c2019-03-15 12:23:17 +010054 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-Jespersen54090862019-02-19 11:31:10 +010058
59if __name__ == '__main__':
60 sys.exit(main())