| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 gn_args.append('enable_ios_bitcode=' + | 104 gn_args.append('enable_ios_bitcode=' + |
| 105 ('true' if use_bitcode else 'false')) | 105 ('true' if use_bitcode else 'false')) |
| 106 gn_args.append('use_goma=' + ('true' if use_goma else 'false')) | 106 gn_args.append('use_goma=' + ('true' if use_goma else 'false')) |
| 107 | 107 |
| 108 # Generate static or dynamic. | 108 # Generate static or dynamic. |
| 109 if build_type == 'static_only': | 109 if build_type == 'static_only': |
| 110 gn_target_name = 'rtc_sdk_objc' | 110 gn_target_name = 'rtc_sdk_objc' |
| 111 elif build_type == 'framework': | 111 elif build_type == 'framework': |
| 112 gn_target_name = 'rtc_sdk_framework_objc' | 112 gn_target_name = 'rtc_sdk_framework_objc' |
| 113 if not use_bitcode: | 113 gn_args.append('enable_dsyms=true') |
| 114 gn_args.append('enable_dsyms=true') | |
| 115 gn_args.append('enable_stripping=true') | 114 gn_args.append('enable_stripping=true') |
| 116 else: | 115 else: |
| 117 raise ValueError('Build type "%s" is not supported.' % build_type) | 116 raise ValueError('Build type "%s" is not supported.' % build_type) |
| 118 | 117 |
| 119 args_string = ' '.join(gn_args + extra_gn_args) | 118 args_string = ' '.join(gn_args + extra_gn_args) |
| 120 logging.info('Building WebRTC with args: %s', args_string) | 119 logging.info('Building WebRTC with args: %s', args_string) |
| 121 | 120 |
| 122 cmd = ['gn', 'gen', output_dir, '--args=' + args_string] | 121 cmd = ['gn', 'gen', output_dir, '--args=' + args_string] |
| 123 _RunCommand(cmd) | 122 _RunCommand(cmd) |
| 124 logging.info('Building target: %s', gn_target_name) | 123 logging.info('Building target: %s', gn_target_name) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 lib_paths = [os.path.join(args.output_dir, arch + '_libs') | 170 lib_paths = [os.path.join(args.output_dir, arch + '_libs') |
| 172 for arch in architectures] | 171 for arch in architectures] |
| 173 | 172 |
| 174 # Combine the slices. | 173 # Combine the slices. |
| 175 dylib_path = os.path.join(SDK_FRAMEWORK_NAME, 'WebRTC') | 174 dylib_path = os.path.join(SDK_FRAMEWORK_NAME, 'WebRTC') |
| 176 # Dylibs will be combined, all other files are the same across archs. | 175 # Dylibs will be combined, all other files are the same across archs. |
| 177 # Use distutils instead of shutil to support merging folders. | 176 # Use distutils instead of shutil to support merging folders. |
| 178 distutils.dir_util.copy_tree( | 177 distutils.dir_util.copy_tree( |
| 179 os.path.join(lib_paths[0], SDK_FRAMEWORK_NAME), | 178 os.path.join(lib_paths[0], SDK_FRAMEWORK_NAME), |
| 180 os.path.join(args.output_dir, SDK_FRAMEWORK_NAME)) | 179 os.path.join(args.output_dir, SDK_FRAMEWORK_NAME)) |
| 180 try: |
| 181 os.remove(os.path.join(args.output_dir, dylib_path)) |
| 182 except OSError: |
| 183 pass |
| 181 logging.info('Merging framework slices.') | 184 logging.info('Merging framework slices.') |
| 182 dylib_paths = [os.path.join(path, dylib_path) for path in lib_paths] | 185 dylib_paths = [os.path.join(path, dylib_path) for path in lib_paths] |
| 183 out_dylib_path = os.path.join(args.output_dir, dylib_path) | 186 out_dylib_path = os.path.join(args.output_dir, dylib_path) |
| 184 try: | |
| 185 os.remove(out_dylib_path) | |
| 186 except OSError: | |
| 187 pass | |
| 188 cmd = ['lipo'] + dylib_paths + ['-create', '-output', out_dylib_path] | 187 cmd = ['lipo'] + dylib_paths + ['-create', '-output', out_dylib_path] |
| 189 _RunCommand(cmd) | 188 _RunCommand(cmd) |
| 190 | 189 |
| 191 # Merge the dSYM slices. | 190 # Merge the dSYM slices. |
| 192 lib_dsym_dir_path = os.path.join(lib_paths[0], 'WebRTC.dSYM') | 191 dsym_path = os.path.join('WebRTC.dSYM', 'Contents', 'Resources', 'DWARF', |
| 193 if os.path.isdir(lib_dsym_dir_path): | 192 'WebRTC') |
| 194 distutils.dir_util.copy_tree(lib_dsym_dir_path, | 193 distutils.dir_util.copy_tree(os.path.join(lib_paths[0], 'WebRTC.dSYM'), |
| 195 os.path.join(args.output_dir, 'WebRTC.dSYM')) | 194 os.path.join(args.output_dir, 'WebRTC.dSYM')) |
| 196 logging.info('Merging dSYM slices.') | 195 try: |
| 197 dsym_path = os.path.join('WebRTC.dSYM', 'Contents', 'Resources', 'DWARF', | 196 os.remove(os.path.join(args.output_dir, dsym_path)) |
| 198 'WebRTC') | 197 except OSError: |
| 199 lib_dsym_paths = [os.path.join(path, dsym_path) for path in lib_paths] | 198 pass |
| 200 out_dsym_path = os.path.join(args.output_dir, dsym_path) | 199 logging.info('Merging dSYM slices.') |
| 201 try: | 200 dsym_paths = [os.path.join(path, dsym_path) for path in lib_paths] |
| 202 os.remove(out_dsym_path) | 201 out_dsym_path = os.path.join(args.output_dir, dsym_path) |
| 203 except OSError: | 202 cmd = ['lipo'] + dsym_paths + ['-create', '-output', out_dsym_path] |
| 204 pass | 203 _RunCommand(cmd) |
| 205 cmd = ['lipo'] + lib_dsym_paths + ['-create', '-output', out_dsym_path] | |
| 206 _RunCommand(cmd) | |
| 207 | 204 |
| 208 # Modify the version number. | 205 # Modify the version number. |
| 209 # Format should be <Branch cut MXX>.<Hotfix #>.<Rev #>. | 206 # Format should be <Branch cut MXX>.<Hotfix #>.<Rev #>. |
| 210 # e.g. 55.0.14986 means branch cut 55, no hotfixes, and revision 14986. | 207 # e.g. 55.0.14986 means branch cut 55, no hotfixes, and revision 14986. |
| 211 infoplist_path = os.path.join(args.output_dir, SDK_FRAMEWORK_NAME, | 208 infoplist_path = os.path.join(args.output_dir, SDK_FRAMEWORK_NAME, |
| 212 'Info.plist') | 209 'Info.plist') |
| 213 cmd = ['PlistBuddy', '-c', | 210 cmd = ['PlistBuddy', '-c', |
| 214 'Print :CFBundleShortVersionString', infoplist_path] | 211 'Print :CFBundleShortVersionString', infoplist_path] |
| 215 major_minor = subprocess.check_output(cmd).strip() | 212 major_minor = subprocess.check_output(cmd).strip() |
| 216 version_number = '%s.%s' % (major_minor, args.revision) | 213 version_number = '%s.%s' % (major_minor, args.revision) |
| 217 logging.info('Substituting revision number: %s', version_number) | 214 logging.info('Substituting revision number: %s', version_number) |
| 218 cmd = ['PlistBuddy', '-c', | 215 cmd = ['PlistBuddy', '-c', |
| 219 'Set :CFBundleVersion ' + version_number, infoplist_path] | 216 'Set :CFBundleVersion ' + version_number, infoplist_path] |
| 220 _RunCommand(cmd) | 217 _RunCommand(cmd) |
| 221 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) | 218 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) |
| 222 | 219 |
| 223 logging.info('Done.') | 220 logging.info('Done.') |
| 224 return 0 | 221 return 0 |
| 225 | 222 |
| 226 | 223 |
| 227 if __name__ == '__main__': | 224 if __name__ == '__main__': |
| 228 sys.exit(main()) | 225 sys.exit(main()) |
| OLD | NEW |