blob: 1945557d281dd68eee781d443f45baea874d25d3 [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001#!/usr/bin/env python
2# Copyright (c) 2016, 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# Wrapper script for running gradle.
7# Will make sure we pulled down gradle before running, and will use the pulled
8# down version to have a consistent developer experience.
9
10import os
11import subprocess
12import sys
13import utils
14
15GRADLE_DIR = os.path.join(utils.REPO_ROOT, 'third_party', 'gradle')
16GRADLE_SHA1 = os.path.join(GRADLE_DIR, 'gradle.tar.gz.sha1')
17GRADLE = os.path.join(GRADLE_DIR, 'gradle', 'bin', 'gradle')
18
19def PrintCmd(s):
20 if type(s) is list:
21 s = ' '.join(s)
22 print 'Running: %s' % s
23 # I know this will hit os on windows eventually if we don't do this.
24 sys.stdout.flush()
25
26def EnsureGradle():
27 if not os.path.exists(GRADLE):
28 # Bootstrap gradle, everything else is controlled using gradle.
29 utils.DownloadFromGoogleCloudStorage(GRADLE_SHA1)
30 else:
31 print 'gradle.py: Gradle binary present'
32
33def RunGradle(args):
34 EnsureGradle()
35 cmd = [GRADLE]
36 cmd.extend(args)
37 utils.PrintCmd(cmd)
38 with utils.ChangedWorkingDirectory(utils.REPO_ROOT):
39 subprocess.check_call(cmd)
40
41def Main():
42 RunGradle(sys.argv[1:])
43
44if __name__ == '__main__':
45 sys.exit(Main())