| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 'Defaults to "framework".') | 43 'Defaults to "framework".') |
| 44 parser.add_argument('--build_config', default='release', | 44 parser.add_argument('--build_config', default='release', |
| 45 choices=['debug', 'release'], | 45 choices=['debug', 'release'], |
| 46 help='The build config. Can be "debug" or "release". ' | 46 help='The build config. Can be "debug" or "release". ' |
| 47 'Defaults to "release".') | 47 'Defaults to "release".') |
| 48 parser.add_argument('--arch', nargs='+', default=DEFAULT_ARCHS, | 48 parser.add_argument('--arch', nargs='+', default=DEFAULT_ARCHS, |
| 49 choices=ENABLED_ARCHS, | 49 choices=ENABLED_ARCHS, |
| 50 help='Architectures to build. Defaults to %(default)s.') | 50 help='Architectures to build. Defaults to %(default)s.') |
| 51 parser.add_argument('-c', '--clean', action='store_true', default=False, | 51 parser.add_argument('-c', '--clean', action='store_true', default=False, |
| 52 help='Removes the previously generated build output, if any.') | 52 help='Removes the previously generated build output, if any.') |
| 53 parser.add_argument('-p', '--purify', action='store_true', default=False, |
| 54 help='Purifies the previously generated build output by ' |
| 55 'removing the temporary results used when (re)building.') |
| 53 parser.add_argument('-o', '--output-dir', default=SDK_OUTPUT_DIR, | 56 parser.add_argument('-o', '--output-dir', default=SDK_OUTPUT_DIR, |
| 54 help='Specifies a directory to output the build artifacts to. ' | 57 help='Specifies a directory to output the build artifacts to. ' |
| 55 'If specified together with -c, deletes the dir.') | 58 'If specified together with -c, deletes the dir.') |
| 56 parser.add_argument('-r', '--revision', type=int, default=0, | 59 parser.add_argument('-r', '--revision', type=int, default=0, |
| 57 help='Specifies a revision number to embed if building the framework.') | 60 help='Specifies a revision number to embed if building the framework.') |
| 58 parser.add_argument('-e', '--bitcode', action='store_true', default=False, | 61 parser.add_argument('-e', '--bitcode', action='store_true', default=False, |
| 59 help='Compile with bitcode.') | 62 help='Compile with bitcode.') |
| 60 parser.add_argument('--verbose', action='store_true', default=False, | 63 parser.add_argument('--verbose', action='store_true', default=False, |
| 61 help='Debug logging.') | 64 help='Debug logging.') |
| 62 parser.add_argument('--use-goma', action='store_true', default=False, | 65 parser.add_argument('--use-goma', action='store_true', default=False, |
| 63 help='Use goma to build.') | 66 help='Use goma to build.') |
| 64 parser.add_argument('--extra-gn-args', default=[], nargs='*', | 67 parser.add_argument('--extra-gn-args', default=[], nargs='*', |
| 65 help='Additional GN args to be used during Ninja generation.') | 68 help='Additional GN args to be used during Ninja generation.') |
| 66 | 69 |
| 67 return parser.parse_args() | 70 return parser.parse_args() |
| 68 | 71 |
| 69 | 72 |
| 70 def _RunCommand(cmd): | 73 def _RunCommand(cmd): |
| 71 logging.debug('Running: %r', cmd) | 74 logging.debug('Running: %r', cmd) |
| 72 subprocess.check_call(cmd, cwd=WEBRTC_SRC_DIR) | 75 subprocess.check_call(cmd, cwd=WEBRTC_SRC_DIR) |
| 73 | 76 |
| 74 | 77 |
| 75 def _CleanArtifacts(output_dir): | 78 def _CleanArtifacts(output_dir): |
| 76 if os.path.isdir(output_dir): | 79 if os.path.isdir(output_dir): |
| 77 logging.info('Deleting %s', output_dir) | 80 logging.info('Deleting %s', output_dir) |
| 78 shutil.rmtree(output_dir) | 81 shutil.rmtree(output_dir) |
| 79 | 82 |
| 80 | 83 |
| 84 def _CleanTemporary(output_dir, architectures): |
| 85 if os.path.isdir(output_dir): |
| 86 logging.info('Removing temporary build files.') |
| 87 for arch in architectures: |
| 88 arch_lib_path = os.path.join(output_dir, arch + '_libs') |
| 89 if os.path.isdir(arch_lib_path): |
| 90 shutil.rmtree(arch_lib_path) |
| 91 |
| 92 |
| 81 def BuildWebRTC(output_dir, target_arch, flavor, build_type, | 93 def BuildWebRTC(output_dir, target_arch, flavor, build_type, |
| 82 ios_deployment_target, libvpx_build_vp9, use_bitcode, | 94 ios_deployment_target, libvpx_build_vp9, use_bitcode, |
| 83 use_goma, extra_gn_args): | 95 use_goma, extra_gn_args): |
| 84 output_dir = os.path.join(output_dir, target_arch + '_libs') | 96 output_dir = os.path.join(output_dir, target_arch + '_libs') |
| 85 gn_args = ['target_os="ios"', 'ios_enable_code_signing=false', | 97 gn_args = ['target_os="ios"', 'ios_enable_code_signing=false', |
| 86 'use_xcode_clang=true', 'is_component_build=false'] | 98 'use_xcode_clang=true', 'is_component_build=false'] |
| 87 | 99 |
| 88 # Add flavor option. | 100 # Add flavor option. |
| 89 if flavor == 'debug': | 101 if flavor == 'debug': |
| 90 gn_args.append('is_debug=true') | 102 gn_args.append('is_debug=true') |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 def main(): | 151 def main(): |
| 140 args = _ParseArgs() | 152 args = _ParseArgs() |
| 141 | 153 |
| 142 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) | 154 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) |
| 143 | 155 |
| 144 if args.clean: | 156 if args.clean: |
| 145 _CleanArtifacts(args.output_dir) | 157 _CleanArtifacts(args.output_dir) |
| 146 return 0 | 158 return 0 |
| 147 | 159 |
| 148 architectures = list(args.arch) | 160 architectures = list(args.arch) |
| 161 |
| 162 if args.purify: |
| 163 _CleanTemporary(args.output_dir, architectures) |
| 164 return 0 |
| 165 |
| 149 # Ignoring x86 except for static libraries for now because of a GN build issue | 166 # Ignoring x86 except for static libraries for now because of a GN build issue |
| 150 # where the generated dynamic framework has the wrong architectures. | 167 # where the generated dynamic framework has the wrong architectures. |
| 151 if 'x86' in architectures and args.build_type != 'static_only': | 168 if 'x86' in architectures and args.build_type != 'static_only': |
| 152 architectures.remove('x86') | 169 architectures.remove('x86') |
| 153 | 170 |
| 154 # Build all architectures. | 171 # Build all architectures. |
| 155 for arch in architectures: | 172 for arch in architectures: |
| 156 BuildWebRTC(args.output_dir, arch, args.build_config, args.build_type, | 173 BuildWebRTC(args.output_dir, arch, args.build_config, args.build_type, |
| 157 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode, | 174 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode, |
| 158 args.use_goma, args.extra_gn_args) | 175 args.use_goma, args.extra_gn_args) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 'Set :CFBundleVersion ' + version_number, infoplist_path] | 235 'Set :CFBundleVersion ' + version_number, infoplist_path] |
| 219 _RunCommand(cmd) | 236 _RunCommand(cmd) |
| 220 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) | 237 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) |
| 221 | 238 |
| 222 logging.info('Done.') | 239 logging.info('Done.') |
| 223 return 0 | 240 return 0 |
| 224 | 241 |
| 225 | 242 |
| 226 if __name__ == '__main__': | 243 if __name__ == '__main__': |
| 227 sys.exit(main()) | 244 sys.exit(main()) |
| OLD | NEW |