OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 # | |
4 # Use of this source code is governed by a BSD-style license | |
5 # that can be found in the LICENSE file in the root of the source | |
6 # tree. An additional intellectual property rights grant can be found | |
7 # in the file PATENTS. All contributing project authors may | |
8 # be found in the AUTHORS file in the root of the source tree. | |
9 | |
10 """ | |
11 This scripts tests creating an Android Studio project using the | |
12 generate_gradle.py script and making a debug build using it. | |
13 | |
14 It expect to be given the webrtc output build directory as the first argument | |
15 all other arguments are optional. | |
16 """ | |
17 | |
18 import argparse | |
19 import logging | |
20 import os | |
21 import shutil | |
22 import subprocess | |
23 import sys | |
24 import tempfile | |
25 | |
26 | |
27 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
28 SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, | |
29 os.pardir)) | |
30 GENERATE_GRADLE_SCRIPT = os.path.join(SRC_DIR, | |
31 'build/android/gradle/generate_gradle.py') | |
32 GRADLEW_BIN = os.path.join(SCRIPT_DIR, 'third_party/gradle/gradlew') | |
33 | |
34 | |
35 def _RunCommand(argv, cwd=SRC_DIR, **kwargs): | |
36 logging.info('Running %r', argv) | |
37 subprocess.check_call(argv, cwd=cwd, **kwargs) | |
38 | |
39 | |
40 def _ParseArgs(): | |
41 parser = argparse.ArgumentParser( | |
42 description='Test generating Android gradle project.') | |
43 parser.add_argument('build_dir_android', | |
44 help='The path to the build directory for Android.') | |
45 parser.add_argument('--project_dir', | |
46 help='A temporary directory to put the output.') | |
47 | |
48 args = parser.parse_args() | |
49 return args | |
50 | |
51 | |
52 def main(): | |
53 logging.basicConfig(level=logging.INFO) | |
54 args = _ParseArgs() | |
55 | |
56 project_dir = args.project_dir | |
57 if not project_dir: | |
58 project_dir = tempfile.mkdtemp() | |
59 | |
60 output_dir = os.path.abspath(args.build_dir_android) | |
61 project_dir = os.path.abspath(project_dir) | |
62 | |
63 try: | |
64 _RunCommand([GENERATE_GRADLE_SCRIPT, '--output-directory', output_dir, | |
65 '--target', '//webrtc/examples:AppRTCMobile', | |
66 '--project-dir', project_dir, | |
67 '--use-gradle-process-resources', '--split-projects']) | |
68 _RunCommand([GRADLEW_BIN, 'assembleDebug'], project_dir) | |
69 finally: | |
70 shutil.rmtree(project_dir, True) | |
kjellander_webrtc
2017/05/11 05:21:32
Hmm, I was going to try this script locally and I
| |
71 | |
72 | |
73 if __name__ == '__main__': | |
74 sys.exit(main()) | |
OLD | NEW |