Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: tools_webrtc/android/build_aar.py

Issue 3011613002: License generation script for build_aar.py. (Closed)
Patch Set: Skip deps without license Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(
kjellander_webrtc 2017/09/01 08:44:52 You can remove this now as it's unused.
sakal 2017/09/01 11:02:30 Done.
47 SCRIPT_DIR, '..', 'generate_licenses.py')
48
49 sys.path.append(os.path.join(SCRIPT_DIR, '..', 'libs'))
50 from generate_licenses import LicenseBuilder
45 51
46 52
47 def _ParseArgs(): 53 def _ParseArgs():
48 parser = argparse.ArgumentParser(description='libwebrtc.aar generator.') 54 parser = argparse.ArgumentParser(description='libwebrtc.aar generator.')
49 parser.add_argument('--output', default='libwebrtc.aar', 55 parser.add_argument('--output', default='libwebrtc.aar',
50 help='Output file of the script.') 56 help='Output file of the script.')
51 parser.add_argument('--arch', default=DEFAULT_ARCHS, nargs='*', 57 parser.add_argument('--arch', default=DEFAULT_ARCHS, nargs='*',
52 help='Architectures to build. Defaults to %(default)s.') 58 help='Architectures to build. Defaults to %(default)s.')
53 parser.add_argument('--use-goma', action='store_true', default=False, 59 parser.add_argument('--use-goma', action='store_true', default=False,
54 help='Use goma.') 60 help='Use goma.')
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 121
116 122
117 def Build(tmp_dir, arch, use_goma, extra_gn_args): 123 def Build(tmp_dir, arch, use_goma, extra_gn_args):
118 """Generates target architecture using GN and builds it using ninja.""" 124 """Generates target architecture using GN and builds it using ninja."""
119 logging.info('Building: %s', arch) 125 logging.info('Building: %s', arch)
120 output_directory = _GetOutputDirectory(tmp_dir, arch) 126 output_directory = _GetOutputDirectory(tmp_dir, arch)
121 gn_args = { 127 gn_args = {
122 'target_os': 'android', 128 'target_os': 'android',
123 'is_debug': False, 129 'is_debug': False,
124 'is_component_build': False, 130 'is_component_build': False,
131 'rtc_include_tests': False,
125 'target_cpu': _GetTargetCpu(arch), 132 'target_cpu': _GetTargetCpu(arch),
126 'use_goma': use_goma 133 'use_goma': use_goma
127 } 134 }
128 arm_version = _GetArmVersion(arch) 135 arm_version = _GetArmVersion(arch)
129 if arm_version: 136 if arm_version:
130 gn_args['arm_version'] = arm_version 137 gn_args['arm_version'] = arm_version
131 gn_args_str = '--args=' + ' '.join([ 138 gn_args_str = '--args=' + ' '.join([
132 k + '=' + _EncodeForGN(v) for k, v in gn_args.items()] + extra_gn_args) 139 k + '=' + _EncodeForGN(v) for k, v in gn_args.items()] + extra_gn_args)
133 140
134 _RunGN(['gen', output_directory, gn_args_str]) 141 _RunGN(['gen', output_directory, gn_args_str])
(...skipping 16 matching lines...) Expand all
151 """Collects architecture specific files into the .aar-archive.""" 158 """Collects architecture specific files into the .aar-archive."""
152 logging.info('Collecting: %s', arch) 159 logging.info('Collecting: %s', arch)
153 output_directory = _GetOutputDirectory(tmp_dir, arch) 160 output_directory = _GetOutputDirectory(tmp_dir, arch)
154 161
155 abi_dir = os.path.join('jni', arch) 162 abi_dir = os.path.join('jni', arch)
156 for so_file in NEEDED_SO_FILES: 163 for so_file in NEEDED_SO_FILES:
157 aar_file.write(os.path.join(output_directory, so_file), 164 aar_file.write(os.path.join(output_directory, so_file),
158 os.path.join(abi_dir, so_file)) 165 os.path.join(abi_dir, so_file))
159 166
160 167
168 def GenerateLicenses(output_dir, tmp_dir, archs):
169 builder = LicenseBuilder(
170 [_GetOutputDirectory(tmp_dir, arch) for arch in archs], TARGETS)
171 builder.GenerateLicenseText(output_dir)
172
173
161 def main(): 174 def main():
162 args = _ParseArgs() 175 args = _ParseArgs()
163 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) 176 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
164 177
165 tmp_dir = tempfile.mkdtemp() 178 tmp_dir = tempfile.mkdtemp()
166 179
167 for arch in args.arch: 180 for arch in args.arch:
168 Build(tmp_dir, arch, args.use_goma, args.extra_gn_args) 181 Build(tmp_dir, arch, args.use_goma, args.extra_gn_args)
169 182
170 with zipfile.ZipFile(args.output, 'w') as aar_file: 183 with zipfile.ZipFile(args.output, 'w') as aar_file:
171 # Architecture doesn't matter here, arbitrarily using the first one. 184 # Architecture doesn't matter here, arbitrarily using the first one.
172 CollectCommon(aar_file, tmp_dir, args.arch[0]) 185 CollectCommon(aar_file, tmp_dir, args.arch[0])
173 for arch in args.arch: 186 for arch in args.arch:
174 Collect(aar_file, tmp_dir, arch) 187 Collect(aar_file, tmp_dir, arch)
175 188
189 license_dir = os.path.dirname(os.path.realpath(args.output))
190 GenerateLicenses(license_dir, tmp_dir, args.arch)
191
176 shutil.rmtree(tmp_dir, True) 192 shutil.rmtree(tmp_dir, True)
177 193
178 194
179 if __name__ == '__main__': 195 if __name__ == '__main__':
180 sys.exit(main()) 196 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools_webrtc/ios/build_ios_libs.py » ('j') | tools_webrtc/libs/generate_licenses.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698