Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 JAR_FILE = 'lib.java/webrtc/sdk/android/libwebrtc.jar' | 39 JAR_FILE = 'lib.java/webrtc/sdk/android/libwebrtc.jar' |
| 40 MANIFEST_FILE = 'webrtc/sdk/android/AndroidManifest.xml' | 40 MANIFEST_FILE = 'webrtc/sdk/android/AndroidManifest.xml' |
| 41 TARGETS = [ | 41 TARGETS = [ |
| 42 'webrtc/sdk/android:libwebrtc', | 42 'webrtc/sdk/android:libwebrtc', |
| 43 'webrtc/sdk/android:libjingle_peerconnection_so', | 43 'webrtc/sdk/android:libjingle_peerconnection_so', |
| 44 ] | 44 ] |
| 45 | 45 |
| 46 | 46 |
| 47 def _ParseArgs(): | 47 def _ParseArgs(): |
| 48 parser = argparse.ArgumentParser(description='libwebrtc.aar generator.') | 48 parser = argparse.ArgumentParser(description='libwebrtc.aar generator.') |
| 49 parser.add_argument('--build-dir', | |
| 50 help='Build dir. By default will create and use temporary dir.') | |
| 49 parser.add_argument('--output', default='libwebrtc.aar', | 51 parser.add_argument('--output', default='libwebrtc.aar', |
| 50 help='Output file of the script.') | 52 help='Output file of the script.') |
| 51 parser.add_argument('--arch', default=DEFAULT_ARCHS, nargs='*', | 53 parser.add_argument('--arch', default=DEFAULT_ARCHS, nargs='*', |
| 52 help='Architectures to build. Defaults to %(default)s.') | 54 help='Architectures to build. Defaults to %(default)s.') |
| 53 parser.add_argument('--use-goma', action='store_true', default=False, | 55 parser.add_argument('--use-goma', action='store_true', default=False, |
| 54 help='Use goma.') | 56 help='Use goma.') |
| 55 parser.add_argument('--verbose', action='store_true', default=False, | 57 parser.add_argument('--verbose', action='store_true', default=False, |
| 56 help='Debug logging.') | 58 help='Debug logging.') |
| 57 parser.add_argument('--extra-gn-args', default=[], nargs='*', | 59 parser.add_argument('--extra-gn-args', default=[], nargs='*', |
| 58 help='Additional GN args to be used during Ninja generation.') | 60 help='Additional GN args to be used during Ninja generation.') |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 abi_dir = os.path.join('jni', arch) | 157 abi_dir = os.path.join('jni', arch) |
| 156 for so_file in NEEDED_SO_FILES: | 158 for so_file in NEEDED_SO_FILES: |
| 157 aar_file.write(os.path.join(output_directory, so_file), | 159 aar_file.write(os.path.join(output_directory, so_file), |
| 158 os.path.join(abi_dir, so_file)) | 160 os.path.join(abi_dir, so_file)) |
| 159 | 161 |
| 160 | 162 |
| 161 def main(): | 163 def main(): |
| 162 args = _ParseArgs() | 164 args = _ParseArgs() |
| 163 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) | 165 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) |
| 164 | 166 |
| 165 tmp_dir = tempfile.mkdtemp() | 167 if not args.build_dir: |
| 168 tmp_dir = tempfile.mkdtemp() | |
| 169 else: | |
| 170 tmp_dir = args.build_dir | |
|
sakal
2017/08/31 08:42:07
nit: I would to call this build_dir because it is
kjellander_webrtc
2017/08/31 08:48:11
+1 to that.
korniltsev
2017/08/31 09:49:46
Done.
| |
| 166 | 171 |
| 167 for arch in args.arch: | 172 for arch in args.arch: |
| 168 Build(tmp_dir, arch, args.use_goma, args.extra_gn_args) | 173 Build(tmp_dir, arch, args.use_goma, args.extra_gn_args) |
| 169 | 174 |
| 170 with zipfile.ZipFile(args.output, 'w') as aar_file: | 175 with zipfile.ZipFile(args.output, 'w') as aar_file: |
| 171 # Architecture doesn't matter here, arbitrarily using the first one. | 176 # Architecture doesn't matter here, arbitrarily using the first one. |
| 172 CollectCommon(aar_file, tmp_dir, args.arch[0]) | 177 CollectCommon(aar_file, tmp_dir, args.arch[0]) |
| 173 for arch in args.arch: | 178 for arch in args.arch: |
| 174 Collect(aar_file, tmp_dir, arch) | 179 Collect(aar_file, tmp_dir, arch) |
| 175 | 180 |
| 176 shutil.rmtree(tmp_dir, True) | 181 if not args.build_dir: |
| 182 shutil.rmtree(tmp_dir, True) | |
| 177 | 183 |
| 178 | 184 |
| 179 if __name__ == '__main__': | 185 if __name__ == '__main__': |
| 180 sys.exit(main()) | 186 sys.exit(main()) |
| OLD | NEW |