Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
run_gradle.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""
8Invokes //gradle for building the Android apps from GN/Ninja.
9"""
10
11import os
12import sys
13import subprocess
14import platform
15
16SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__))
17
18BAT = '.bat' if sys.platform.startswith(('cygwin', 'win')) else ''
19GRADLE_BIN = os.path.normpath(
20 os.path.join(SCRIPT_PATH, '..', '..', '..', 'third_party', 'gradle', 'bin', 'gradle%s' % BAT)
21)
22
23ANDROID_HOME = os.path.normpath(
24 os.path.join(SCRIPT_PATH, '..', '..', '..', 'third_party', 'android_tools', 'sdk')
25)
26
27if platform.system() == 'Darwin':
28 JAVA_HOME = os.path.normpath(
29 os.path.join(
30 SCRIPT_PATH, '..', '..', '..', 'third_party', 'java', 'openjdk', 'Contents', 'Home'
31 )
32 )
33else:
34 JAVA_HOME = os.path.normpath(
35 os.path.join(SCRIPT_PATH, '..', '..', '..', 'third_party', 'java', 'openjdk')
36 )
37
38
39def main():
40 if not os.path.isdir(ANDROID_HOME):
41 raise Exception('%s (ANDROID_HOME) is not a directory' % ANDROID_HOME)
42
43 android_dir = sys.argv[1]
44 subprocess.check_output(
45 args=[GRADLE_BIN] + sys.argv[2:],
46 cwd=android_dir,
47 env=dict(os.environ, ANDROID_HOME=ANDROID_HOME, JAVA_HOME=JAVA_HOME),
48 )
49 return 0
50
51
52if __name__ == '__main__':
53 sys.exit(main())
Definition main.py:1