OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 3 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license | 5 # Use of this source code is governed by a BSD-style license |
6 # that can be found in the LICENSE file in the root of the source | 6 # that can be found in the LICENSE file in the root of the source |
7 # tree. An additional intellectual property rights grant can be found | 7 # tree. An additional intellectual property rights grant can be found |
8 # in the file PATENTS. All contributing project authors may | 8 # in the file PATENTS. All contributing project authors may |
9 # be found in the AUTHORS file in the root of the source tree. | 9 # be found in the AUTHORS file in the root of the source tree. |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 import argparse | 27 import argparse |
28 import logging | 28 import logging |
29 import os | 29 import os |
30 import shutil | 30 import shutil |
31 import subprocess | 31 import subprocess |
32 import sys | 32 import sys |
33 import tempfile | 33 import tempfile |
34 import zipfile | 34 import zipfile |
35 | 35 |
36 | 36 |
37 SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) | |
37 DEFAULT_ARCHS = ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'] | 38 DEFAULT_ARCHS = ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'] |
38 NEEDED_SO_FILES = ['libjingle_peerconnection_so.so'] | 39 NEEDED_SO_FILES = ['libjingle_peerconnection_so.so'] |
39 JAR_FILE = 'lib.java/webrtc/sdk/android/libwebrtc.jar' | 40 JAR_FILE = 'lib.java/webrtc/sdk/android/libwebrtc.jar' |
40 MANIFEST_FILE = 'webrtc/sdk/android/AndroidManifest.xml' | 41 MANIFEST_FILE = 'webrtc/sdk/android/AndroidManifest.xml' |
41 TARGETS = [ | 42 TARGETS = [ |
42 'webrtc/sdk/android:libwebrtc', | 43 'webrtc/sdk/android:libwebrtc', |
43 'webrtc/sdk/android:libjingle_peerconnection_so', | 44 'webrtc/sdk/android:libjingle_peerconnection_so', |
44 ] | 45 ] |
46 GENERATE_LICENSES_SCRIPT = os.path.join( | |
47 SCRIPT_DIR, '..', 'generate_licenses.py') | |
45 | 48 |
46 | 49 |
47 def _ParseArgs(): | 50 def _ParseArgs(): |
48 parser = argparse.ArgumentParser(description='libwebrtc.aar generator.') | 51 parser = argparse.ArgumentParser(description='libwebrtc.aar generator.') |
49 parser.add_argument('--output', default='libwebrtc.aar', | 52 parser.add_argument('--output', default='libwebrtc.aar', |
50 help='Output file of the script.') | 53 help='Output file of the script.') |
51 parser.add_argument('--arch', default=DEFAULT_ARCHS, nargs='*', | 54 parser.add_argument('--arch', default=DEFAULT_ARCHS, nargs='*', |
52 help='Architectures to build. Defaults to %(default)s.') | 55 help='Architectures to build. Defaults to %(default)s.') |
53 parser.add_argument('--use-goma', action='store_true', default=False, | 56 parser.add_argument('--use-goma', action='store_true', default=False, |
54 help='Use goma.') | 57 help='Use goma.') |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 """Collects architecture specific files into the .aar-archive.""" | 154 """Collects architecture specific files into the .aar-archive.""" |
152 logging.info('Collecting: %s', arch) | 155 logging.info('Collecting: %s', arch) |
153 output_directory = _GetOutputDirectory(tmp_dir, arch) | 156 output_directory = _GetOutputDirectory(tmp_dir, arch) |
154 | 157 |
155 abi_dir = os.path.join('jni', arch) | 158 abi_dir = os.path.join('jni', arch) |
156 for so_file in NEEDED_SO_FILES: | 159 for so_file in NEEDED_SO_FILES: |
157 aar_file.write(os.path.join(output_directory, so_file), | 160 aar_file.write(os.path.join(output_directory, so_file), |
158 os.path.join(abi_dir, so_file)) | 161 os.path.join(abi_dir, so_file)) |
159 | 162 |
160 | 163 |
164 def GenerateLicenses(output_dir, tmp_dir, archs): | |
165 cmd = ['python', GENERATE_LICENSES_SCRIPT] | |
166 for target in TARGETS: | |
167 cmd.extend(['--target', target]) | |
168 cmd.append(output_dir) | |
169 for arch in archs: | |
170 cmd.append(_GetOutputDirectory(tmp_dir, arch)) | |
171 logging.debug('Running: %r', cmd) | |
172 print cmd | |
173 subprocess.check_call(cmd) | |
kjellander_webrtc
2017/08/31 09:45:21
Ideally you'd load the common code as a Python mod
sakal
2017/08/31 14:26:58
Done.
| |
174 | |
161 def main(): | 175 def main(): |
162 args = _ParseArgs() | 176 args = _ParseArgs() |
163 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) | 177 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) |
164 | 178 |
165 tmp_dir = tempfile.mkdtemp() | 179 tmp_dir = tempfile.mkdtemp() |
166 | 180 |
167 for arch in args.arch: | 181 for arch in args.arch: |
168 Build(tmp_dir, arch, args.use_goma, args.extra_gn_args) | 182 Build(tmp_dir, arch, args.use_goma, args.extra_gn_args) |
169 | 183 |
170 with zipfile.ZipFile(args.output, 'w') as aar_file: | 184 with zipfile.ZipFile(args.output, 'w') as aar_file: |
171 # Architecture doesn't matter here, arbitrarily using the first one. | 185 # Architecture doesn't matter here, arbitrarily using the first one. |
172 CollectCommon(aar_file, tmp_dir, args.arch[0]) | 186 CollectCommon(aar_file, tmp_dir, args.arch[0]) |
173 for arch in args.arch: | 187 for arch in args.arch: |
174 Collect(aar_file, tmp_dir, arch) | 188 Collect(aar_file, tmp_dir, arch) |
175 | 189 |
190 license_dir = os.path.dirname(os.path.realpath(args.output)) | |
191 GenerateLicenses(license_dir, tmp_dir, args.arch) | |
192 | |
176 shutil.rmtree(tmp_dir, True) | 193 shutil.rmtree(tmp_dir, True) |
177 | 194 |
178 | 195 |
179 if __name__ == '__main__': | 196 if __name__ == '__main__': |
180 sys.exit(main()) | 197 sys.exit(main()) |
OLD | NEW |