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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 help='Removes the previously generated build output, if any.') | 51 help='Removes the previously generated build output, if any.') |
| 52 parser.add_argument('-o', '--output-dir', default=SDK_OUTPUT_DIR, | 52 parser.add_argument('-o', '--output-dir', default=SDK_OUTPUT_DIR, |
| 53 help='Specifies a directory to output the build artifacts to. ' | 53 help='Specifies a directory to output the build artifacts to. ' |
| 54 'If specified together with -c, deletes the dir.') | 54 'If specified together with -c, deletes the dir.') |
| 55 parser.add_argument('-r', '--revision', type=int, default=0, | 55 parser.add_argument('-r', '--revision', type=int, default=0, |
| 56 help='Specifies a revision number to embed if building the framework.') | 56 help='Specifies a revision number to embed if building the framework.') |
| 57 parser.add_argument('-e', '--bitcode', action='store_true', default=False, | 57 parser.add_argument('-e', '--bitcode', action='store_true', default=False, |
| 58 help='Compile with bitcode.') | 58 help='Compile with bitcode.') |
| 59 parser.add_argument('--verbose', action='store_true', default=False, | 59 parser.add_argument('--verbose', action='store_true', default=False, |
| 60 help='Debug logging.') | 60 help='Debug logging.') |
| 61 parser.add_argument('--use-goma', action='store_true', default=False, | |
| 62 help='Use goma to build.') | |
| 61 return parser.parse_args() | 63 return parser.parse_args() |
|
kjellander_webrtc
2017/02/13 07:21:05
For the bots, we'll need another flag --extra-gn-a
mbonadei
2017/02/13 10:21:35
Done.
| |
| 62 | 64 |
| 63 | 65 |
| 64 def _RunCommand(cmd): | 66 def _RunCommand(cmd): |
| 65 logging.debug('Running: %r', cmd) | 67 logging.debug('Running: %r', cmd) |
| 66 subprocess.check_call(cmd) | 68 subprocess.check_call(cmd) |
| 67 | 69 |
| 68 | 70 |
| 69 def _CleanArtifacts(output_dir): | 71 def _CleanArtifacts(output_dir): |
| 70 if os.path.isdir(output_dir): | 72 if os.path.isdir(output_dir): |
| 71 logging.info('Deleting %s', output_dir) | 73 logging.info('Deleting %s', output_dir) |
| 72 shutil.rmtree(output_dir) | 74 shutil.rmtree(output_dir) |
| 73 | 75 |
| 74 | 76 |
| 75 def BuildWebRTC(output_dir, target_arch, flavor, build_type, | 77 def BuildWebRTC(output_dir, target_arch, flavor, build_type, |
| 76 ios_deployment_target, libvpx_build_vp9, use_bitcode, | 78 ios_deployment_target, libvpx_build_vp9, use_bitcode, |
| 77 custom_gn_options=()): | 79 use_goma, custom_gn_options=()): |
| 78 output_dir = os.path.join(output_dir, target_arch + '_libs') | 80 output_dir = os.path.join(output_dir, target_arch + '_libs') |
| 79 gn_args = ['target_os="ios"', 'ios_enable_code_signing=false', | 81 gn_args = ['target_os="ios"', 'ios_enable_code_signing=false', |
| 80 'use_xcode_clang=true', 'is_component_build=false'] | 82 'use_xcode_clang=true', 'is_component_build=false'] |
| 81 | 83 |
| 82 # Add flavor option. | 84 # Add flavor option. |
| 83 if flavor == 'debug': | 85 if flavor == 'debug': |
| 84 gn_args.append('is_debug=true') | 86 gn_args.append('is_debug=true') |
| 85 elif flavor == 'release': | 87 elif flavor == 'release': |
| 86 gn_args.append('is_debug=false') | 88 gn_args.append('is_debug=false') |
| 87 else: | 89 else: |
| 88 raise ValueError('Unexpected flavor type: %s' % flavor) | 90 raise ValueError('Unexpected flavor type: %s' % flavor) |
| 89 | 91 |
| 90 gn_args.append('target_cpu="%s"' % target_arch) | 92 gn_args.append('target_cpu="%s"' % target_arch) |
| 91 | 93 |
| 92 gn_args.append('ios_deployment_target="%s"' % ios_deployment_target) | 94 gn_args.append('ios_deployment_target="%s"' % ios_deployment_target) |
| 93 | 95 |
| 94 gn_args.append('rtc_libvpx_build_vp9=' + | 96 gn_args.append('rtc_libvpx_build_vp9=' + |
| 95 ('true' if libvpx_build_vp9 else 'false')) | 97 ('true' if libvpx_build_vp9 else 'false')) |
| 96 | 98 |
| 97 gn_args.append('enable_ios_bitcode=' + | 99 gn_args.append('enable_ios_bitcode=' + |
| 98 ('true' if use_bitcode else 'false')) | 100 ('true' if use_bitcode else 'false')) |
| 101 gn_args.append('use_goma=' + 'true' if use_goma else 'false') | |
| 99 | 102 |
| 100 gn_args.extend(custom_gn_options) | 103 gn_args.extend(custom_gn_options) |
| 101 | 104 |
| 102 # Generate static or dynamic. | 105 # Generate static or dynamic. |
| 103 if build_type == 'static_only': | 106 if build_type == 'static_only': |
| 104 gn_target_name = 'rtc_sdk_objc' | 107 gn_target_name = 'rtc_sdk_objc' |
| 105 elif build_type == 'framework': | 108 elif build_type == 'framework': |
| 106 gn_target_name = 'rtc_sdk_framework_objc' | 109 gn_target_name = 'rtc_sdk_framework_objc' |
| 107 gn_args.append('enable_dsyms=true') | 110 gn_args.append('enable_dsyms=true') |
| 108 gn_args.append('enable_stripping=true') | 111 gn_args.append('enable_stripping=true') |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 132 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) | 135 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) |
| 133 | 136 |
| 134 if args.clean: | 137 if args.clean: |
| 135 _CleanArtifacts(args.output_dir) | 138 _CleanArtifacts(args.output_dir) |
| 136 return 0 | 139 return 0 |
| 137 | 140 |
| 138 # Build all architectures. | 141 # Build all architectures. |
| 139 for arch in ENABLED_ARCHITECTURES: | 142 for arch in ENABLED_ARCHITECTURES: |
| 140 BuildWebRTC(args.output_dir, arch, args.build_config, args.build_type, | 143 BuildWebRTC(args.output_dir, arch, args.build_config, args.build_type, |
| 141 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode, | 144 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode, |
| 142 CUSTOM_GN_OPTS) | 145 args.use_goma, CUSTOM_GN_OPTS) |
| 143 | 146 |
| 144 # Ignoring x86 except for static libraries for now because of a GN build issue | 147 # Ignoring x86 except for static libraries for now because of a GN build issue |
| 145 # where the generated dynamic framework has the wrong architectures. | 148 # where the generated dynamic framework has the wrong architectures. |
| 146 | 149 |
| 147 # Create FAT archive. | 150 # Create FAT archive. |
| 148 if args.build_type == 'static_only': | 151 if args.build_type == 'static_only': |
| 149 BuildWebRTC(args.output_dir, 'x86', args.build_config, args.build_type, | 152 BuildWebRTC(args.output_dir, 'x86', args.build_config, args.build_type, |
| 150 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode, | 153 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode, |
| 151 CUSTOM_GN_OPTS) | 154 args.use_goma, CUSTOM_GN_OPTS) |
| 152 | 155 |
| 153 arm_lib_path = os.path.join(args.output_dir, 'arm_libs', SDK_LIB_NAME) | 156 arm_lib_path = os.path.join(args.output_dir, 'arm_libs', SDK_LIB_NAME) |
| 154 arm64_lib_path = os.path.join(args.output_dir, 'arm64_libs', SDK_LIB_NAME) | 157 arm64_lib_path = os.path.join(args.output_dir, 'arm64_libs', SDK_LIB_NAME) |
| 155 x64_lib_path = os.path.join(args.output_dir, 'x64_libs', SDK_LIB_NAME) | 158 x64_lib_path = os.path.join(args.output_dir, 'x64_libs', SDK_LIB_NAME) |
| 156 x86_lib_path = os.path.join(args.output_dir, 'x86_libs', SDK_LIB_NAME) | 159 x86_lib_path = os.path.join(args.output_dir, 'x86_libs', SDK_LIB_NAME) |
| 157 | 160 |
| 158 # Combine the slices. | 161 # Combine the slices. |
| 159 cmd = ['lipo', arm_lib_path, arm64_lib_path, x64_lib_path, x86_lib_path, | 162 cmd = ['lipo', arm_lib_path, arm64_lib_path, x64_lib_path, x86_lib_path, |
| 160 '-create', '-output', os.path.join(args.output_dir, SDK_LIB_NAME)] | 163 '-create', '-output', os.path.join(args.output_dir, SDK_LIB_NAME)] |
| 161 _RunCommand(cmd) | 164 _RunCommand(cmd) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 'Set :CFBundleVersion ' + version_number, infoplist_path] | 215 'Set :CFBundleVersion ' + version_number, infoplist_path] |
| 213 _RunCommand(cmd) | 216 _RunCommand(cmd) |
| 214 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) | 217 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) |
| 215 | 218 |
| 216 logging.info('Done.') | 219 logging.info('Done.') |
| 217 return 0 | 220 return 0 |
| 218 | 221 |
| 219 | 222 |
| 220 if __name__ == '__main__': | 223 if __name__ == '__main__': |
| 221 sys.exit(main()) | 224 sys.exit(main()) |
| OLD | NEW |