oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 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 |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 10 | """WebRTC iOS XCFramework build script. |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 11 | Each architecture is compiled separately before being merged together. |
| 12 | By default, the library is created in out_ios_libs/. (Change with -o.) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 13 | """ |
| 14 | |
| 15 | import argparse |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 16 | import logging |
| 17 | import os |
| 18 | import shutil |
| 19 | import subprocess |
| 20 | import sys |
| 21 | |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 22 | os.environ['PATH'] = '/usr/libexec' + os.pathsep + os.environ['PATH'] |
| 23 | |
| 24 | SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
Henrik Kjellander | ec57e05 | 2017-10-17 21:36:01 +0200 | [diff] [blame] | 25 | SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, '..', '..')) |
| 26 | sys.path.append(os.path.join(SRC_DIR, 'build')) |
| 27 | import find_depot_tools |
| 28 | |
| 29 | SDK_OUTPUT_DIR = os.path.join(SRC_DIR, 'out_ios_libs') |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 30 | SDK_FRAMEWORK_NAME = 'WebRTC.framework' |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 31 | SDK_DSYM_NAME = 'WebRTC.dSYM' |
| 32 | SDK_XCFRAMEWORK_NAME = 'WebRTC.xcframework' |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 33 | |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 34 | ENABLED_ARCHS = [ |
| 35 | 'device:arm64', 'simulator:arm64', 'simulator:x64', |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 36 | 'catalyst:arm64', 'catalyst:x64', |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 37 | 'arm64', 'x64' |
| 38 | ] |
| 39 | DEFAULT_ARCHS = [ |
| 40 | 'device:arm64', 'simulator:arm64', 'simulator:x64' |
| 41 | ] |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 42 | IOS_DEPLOYMENT_TARGET = { |
| 43 | 'device': '12.0', |
| 44 | 'simulator': '12.0', |
| 45 | 'catalyst': '14.0' |
| 46 | } |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 47 | LIBVPX_BUILD_VP9 = False |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 48 | |
sakal | 67e414c | 2017-09-05 00:16:15 -0700 | [diff] [blame] | 49 | sys.path.append(os.path.join(SCRIPT_DIR, '..', 'libs')) |
| 50 | from generate_licenses import LicenseBuilder |
| 51 | |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 52 | |
| 53 | def _ParseArgs(): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 54 | parser = argparse.ArgumentParser(description=__doc__) |
| 55 | parser.add_argument('--build_config', |
| 56 | default='release', |
| 57 | choices=['debug', 'release'], |
| 58 | help='The build config. Can be "debug" or "release". ' |
| 59 | 'Defaults to "release".') |
| 60 | parser.add_argument( |
| 61 | '--arch', |
| 62 | nargs='+', |
| 63 | default=DEFAULT_ARCHS, |
| 64 | choices=ENABLED_ARCHS, |
| 65 | help='Architectures to build. Defaults to %(default)s.') |
| 66 | parser.add_argument( |
| 67 | '-c', |
| 68 | '--clean', |
| 69 | action='store_true', |
| 70 | default=False, |
| 71 | help='Removes the previously generated build output, if any.') |
| 72 | parser.add_argument( |
| 73 | '-p', |
| 74 | '--purify', |
| 75 | action='store_true', |
| 76 | default=False, |
| 77 | help='Purifies the previously generated build output by ' |
| 78 | 'removing the temporary results used when (re)building.') |
| 79 | parser.add_argument( |
| 80 | '-o', |
| 81 | '--output-dir', |
Yura Yaroshevich | 686ad4f | 2021-02-10 22:32:20 +0300 | [diff] [blame] | 82 | type=os.path.abspath, |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 83 | default=SDK_OUTPUT_DIR, |
| 84 | help='Specifies a directory to output the build artifacts to. ' |
| 85 | 'If specified together with -c, deletes the dir.') |
| 86 | parser.add_argument( |
| 87 | '-r', |
| 88 | '--revision', |
| 89 | type=int, |
| 90 | default=0, |
| 91 | help='Specifies a revision number to embed if building the framework.') |
| 92 | parser.add_argument('-e', |
| 93 | '--bitcode', |
| 94 | action='store_true', |
| 95 | default=False, |
| 96 | help='Compile with bitcode.') |
| 97 | parser.add_argument('--verbose', |
| 98 | action='store_true', |
| 99 | default=False, |
| 100 | help='Debug logging.') |
| 101 | parser.add_argument('--use-goma', |
| 102 | action='store_true', |
| 103 | default=False, |
| 104 | help='Use goma to build.') |
| 105 | parser.add_argument( |
| 106 | '--extra-gn-args', |
| 107 | default=[], |
| 108 | nargs='*', |
| 109 | help='Additional GN args to be used during Ninja generation.') |
mbonadei | 585209b | 2017-02-13 04:59:27 -0800 | [diff] [blame] | 110 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 111 | return parser.parse_args() |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 112 | |
| 113 | |
| 114 | def _RunCommand(cmd): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 115 | logging.debug('Running: %r', cmd) |
| 116 | subprocess.check_call(cmd, cwd=SRC_DIR) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 117 | |
| 118 | |
| 119 | def _CleanArtifacts(output_dir): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 120 | if os.path.isdir(output_dir): |
| 121 | logging.info('Deleting %s', output_dir) |
| 122 | shutil.rmtree(output_dir) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 123 | |
| 124 | |
VladimirTechMan | 7b188e8 | 2017-03-14 03:12:35 -0700 | [diff] [blame] | 125 | def _CleanTemporary(output_dir, architectures): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 126 | if os.path.isdir(output_dir): |
| 127 | logging.info('Removing temporary build files.') |
| 128 | for arch in architectures: |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 129 | arch_lib_path = os.path.join(output_dir, arch) |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 130 | if os.path.isdir(arch_lib_path): |
| 131 | shutil.rmtree(arch_lib_path) |
VladimirTechMan | 7b188e8 | 2017-03-14 03:12:35 -0700 | [diff] [blame] | 132 | |
| 133 | |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 134 | def _ParseArchitecture(architectures): |
| 135 | result = dict() |
| 136 | for arch in architectures: |
| 137 | if ":" in arch: |
| 138 | target_environment, target_cpu = arch.split(":") |
| 139 | else: |
| 140 | logging.warning('The environment for build is not specified.') |
| 141 | logging.warning('It is assumed based on cpu type.') |
| 142 | logging.warning('See crbug.com/1138425 for more details.') |
| 143 | if arch == "x64": |
| 144 | target_environment = "simulator" |
| 145 | else: |
| 146 | target_environment = "device" |
| 147 | target_cpu = arch |
| 148 | archs = result.get(target_environment) |
| 149 | if archs is None: |
| 150 | result[target_environment] = {target_cpu} |
| 151 | else: |
| 152 | archs.add(target_cpu) |
| 153 | |
| 154 | return result |
| 155 | |
| 156 | |
| 157 | def BuildWebRTC(output_dir, target_environment, target_arch, flavor, |
| 158 | gn_target_name, ios_deployment_target, libvpx_build_vp9, |
| 159 | use_bitcode, use_goma, extra_gn_args): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 160 | gn_args = [ |
| 161 | 'target_os="ios"', 'ios_enable_code_signing=false', |
Mirko Bonadei | 58678a0 | 2020-12-01 10:54:40 +0100 | [diff] [blame] | 162 | 'use_xcode_clang=true', 'is_component_build=false', |
Mirko Bonadei | bc7666b | 2021-09-19 12:37:28 +0200 | [diff] [blame] | 163 | 'rtc_include_tests=false', 'use_lld=false', |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 164 | ] |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 165 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 166 | # Add flavor option. |
| 167 | if flavor == 'debug': |
| 168 | gn_args.append('is_debug=true') |
| 169 | elif flavor == 'release': |
| 170 | gn_args.append('is_debug=false') |
| 171 | else: |
| 172 | raise ValueError('Unexpected flavor type: %s' % flavor) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 173 | |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 174 | gn_args.append('target_environment="%s"' % target_environment) |
| 175 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 176 | gn_args.append('target_cpu="%s"' % target_arch) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 177 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 178 | gn_args.append('ios_deployment_target="%s"' % ios_deployment_target) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 179 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 180 | gn_args.append('rtc_libvpx_build_vp9=' + |
| 181 | ('true' if libvpx_build_vp9 else 'false')) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 182 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 183 | gn_args.append('enable_ios_bitcode=' + |
| 184 | ('true' if use_bitcode else 'false')) |
| 185 | gn_args.append('use_goma=' + ('true' if use_goma else 'false')) |
Mirko Bonadei | 5f07845 | 2021-07-30 22:32:55 +0200 | [diff] [blame] | 186 | gn_args.append('rtc_enable_objc_symbol_export=true') |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 187 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 188 | args_string = ' '.join(gn_args + extra_gn_args) |
| 189 | logging.info('Building WebRTC with args: %s', args_string) |
mbonadei | 8714b8f | 2017-02-15 13:18:57 -0800 | [diff] [blame] | 190 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 191 | cmd = [ |
| 192 | sys.executable, |
| 193 | os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gn.py'), |
| 194 | 'gen', |
| 195 | output_dir, |
| 196 | '--args=' + args_string, |
| 197 | ] |
| 198 | _RunCommand(cmd) |
| 199 | logging.info('Building target: %s', gn_target_name) |
mbonadei | 8714b8f | 2017-02-15 13:18:57 -0800 | [diff] [blame] | 200 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 201 | cmd = [ |
| 202 | os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'ninja'), |
| 203 | '-C', |
| 204 | output_dir, |
| 205 | gn_target_name, |
| 206 | ] |
| 207 | if use_goma: |
| 208 | cmd.extend(['-j', '200']) |
| 209 | _RunCommand(cmd) |
| 210 | |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 211 | |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 212 | def main(): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 213 | args = _ParseArgs() |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 214 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 215 | logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 216 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 217 | if args.clean: |
| 218 | _CleanArtifacts(args.output_dir) |
| 219 | return 0 |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 220 | |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 221 | # architectures is typed as Dict[str, Set[str]], |
| 222 | # where key is for the environment (device or simulator) |
| 223 | # and value is for the cpu type. |
| 224 | architectures = _ParseArchitecture(args.arch) |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 225 | gn_args = args.extra_gn_args |
VladimirTechMan | 7b188e8 | 2017-03-14 03:12:35 -0700 | [diff] [blame] | 226 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 227 | if args.purify: |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 228 | _CleanTemporary(args.output_dir, architectures.keys()) |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 229 | return 0 |
VladimirTechMan | 7b188e8 | 2017-03-14 03:12:35 -0700 | [diff] [blame] | 230 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 231 | gn_target_name = 'framework_objc' |
| 232 | if not args.bitcode: |
| 233 | gn_args.append('enable_dsyms=true') |
| 234 | gn_args.append('enable_stripping=true') |
Kári Tristan Helgason | 1edbda0 | 2017-06-13 10:45:42 +0200 | [diff] [blame] | 235 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 236 | # Build all architectures. |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 237 | framework_paths = [] |
| 238 | all_lib_paths = [] |
| 239 | for (environment, archs) in architectures.items(): |
| 240 | framework_path = os.path.join(args.output_dir, environment) |
| 241 | framework_paths.append(framework_path) |
| 242 | lib_paths = [] |
| 243 | for arch in archs: |
| 244 | lib_path = os.path.join(framework_path, arch + '_libs') |
| 245 | lib_paths.append(lib_path) |
| 246 | BuildWebRTC(lib_path, environment, arch, args.build_config, |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 247 | gn_target_name, IOS_DEPLOYMENT_TARGET[environment], |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 248 | LIBVPX_BUILD_VP9, args.bitcode, args.use_goma, gn_args) |
| 249 | all_lib_paths.extend(lib_paths) |
Kári Tristan Helgason | 1edbda0 | 2017-06-13 10:45:42 +0200 | [diff] [blame] | 250 | |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 251 | # Combine the slices. |
| 252 | dylib_path = os.path.join(SDK_FRAMEWORK_NAME, 'WebRTC') |
| 253 | # Dylibs will be combined, all other files are the same across archs. |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 254 | shutil.rmtree( |
| 255 | os.path.join(framework_path, SDK_FRAMEWORK_NAME), |
| 256 | ignore_errors=True) |
| 257 | shutil.copytree( |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 258 | os.path.join(lib_paths[0], SDK_FRAMEWORK_NAME), |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 259 | os.path.join(framework_path, SDK_FRAMEWORK_NAME), |
| 260 | symlinks=True) |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 261 | logging.info('Merging framework slices for %s.', environment) |
| 262 | dylib_paths = [os.path.join(path, dylib_path) for path in lib_paths] |
| 263 | out_dylib_path = os.path.join(framework_path, dylib_path) |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 264 | if os.path.islink(out_dylib_path): |
| 265 | out_dylib_path = os.path.join(os.path.dirname(out_dylib_path), |
| 266 | os.readlink(out_dylib_path)) |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 267 | try: |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 268 | os.remove(out_dylib_path) |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 269 | except OSError: |
| 270 | pass |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 271 | cmd = ['lipo'] + dylib_paths + ['-create', '-output', out_dylib_path] |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 272 | _RunCommand(cmd) |
| 273 | |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 274 | # Merge the dSYM slices. |
| 275 | lib_dsym_dir_path = os.path.join(lib_paths[0], SDK_DSYM_NAME) |
| 276 | if os.path.isdir(lib_dsym_dir_path): |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 277 | shutil.rmtree( |
| 278 | os.path.join(framework_path, SDK_DSYM_NAME), |
| 279 | ignore_errors=True) |
| 280 | shutil.copytree( |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 281 | lib_dsym_dir_path, os.path.join(framework_path, SDK_DSYM_NAME)) |
| 282 | logging.info('Merging dSYM slices.') |
| 283 | dsym_path = os.path.join(SDK_DSYM_NAME, 'Contents', 'Resources', |
| 284 | 'DWARF', 'WebRTC') |
| 285 | lib_dsym_paths = [ |
| 286 | os.path.join(path, dsym_path) for path in lib_paths |
| 287 | ] |
| 288 | out_dsym_path = os.path.join(framework_path, dsym_path) |
| 289 | try: |
| 290 | os.remove(out_dsym_path) |
| 291 | except OSError: |
| 292 | pass |
| 293 | cmd = ['lipo' |
| 294 | ] + lib_dsym_paths + ['-create', '-output', out_dsym_path] |
| 295 | _RunCommand(cmd) |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 296 | |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 297 | # Check for Mac-style WebRTC.framework/Resources/ (for Catalyst)... |
| 298 | resources_dir = os.path.join(framework_path, SDK_FRAMEWORK_NAME, |
| 299 | 'Resources') |
| 300 | if not os.path.exists(resources_dir): |
| 301 | # ...then fall back to iOS-style WebRTC.framework/ |
| 302 | resources_dir = os.path.dirname(resources_dir) |
| 303 | |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 304 | # Modify the version number. |
| 305 | # Format should be <Branch cut MXX>.<Hotfix #>.<Rev #>. |
| 306 | # e.g. 55.0.14986 means |
| 307 | # branch cut 55, no hotfixes, and revision 14986. |
Jordan Rose | 4a3296d | 2021-07-23 15:06:19 -0700 | [diff] [blame] | 308 | infoplist_path = os.path.join(resources_dir, 'Info.plist') |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 309 | cmd = [ |
| 310 | 'PlistBuddy', '-c', 'Print :CFBundleShortVersionString', |
| 311 | infoplist_path |
| 312 | ] |
| 313 | major_minor = subprocess.check_output(cmd).strip() |
| 314 | version_number = '%s.%s' % (major_minor, args.revision) |
| 315 | logging.info('Substituting revision number: %s', version_number) |
| 316 | cmd = [ |
| 317 | 'PlistBuddy', '-c', 'Set :CFBundleVersion ' + version_number, |
| 318 | infoplist_path |
| 319 | ] |
| 320 | _RunCommand(cmd) |
| 321 | _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) |
| 322 | |
| 323 | xcframework_dir = os.path.join(args.output_dir, SDK_XCFRAMEWORK_NAME) |
| 324 | if os.path.isdir(xcframework_dir): |
| 325 | shutil.rmtree(xcframework_dir) |
| 326 | |
| 327 | logging.info('Creating xcframework.') |
| 328 | cmd = ['xcodebuild', '-create-xcframework', '-output', xcframework_dir] |
| 329 | |
| 330 | # Apparently, xcodebuild needs absolute paths for input arguments |
| 331 | for framework_path in framework_paths: |
| 332 | cmd += [ |
| 333 | '-framework', |
| 334 | os.path.abspath(os.path.join(framework_path, SDK_FRAMEWORK_NAME)), |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 335 | ] |
Byoungchan Lee | 750948b | 2021-08-14 08:36:32 +0900 | [diff] [blame] | 336 | dsym_full_path = os.path.join(framework_path, SDK_DSYM_NAME) |
| 337 | if os.path.exists(dsym_full_path): |
| 338 | cmd += ['-debug-symbols', os.path.abspath(dsym_full_path)] |
Byoungchan Lee | c41093b | 2021-07-06 18:52:21 +0900 | [diff] [blame] | 339 | |
| 340 | _RunCommand(cmd) |
| 341 | |
| 342 | # Generate the license file. |
| 343 | logging.info('Generate license file.') |
| 344 | gn_target_full_name = '//sdk:' + gn_target_name |
| 345 | builder = LicenseBuilder(all_lib_paths, [gn_target_full_name]) |
| 346 | builder.GenerateLicenseText( |
| 347 | os.path.join(args.output_dir, SDK_XCFRAMEWORK_NAME)) |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 348 | |
| 349 | logging.info('Done.') |
| 350 | return 0 |
oprypin | 7a2d8ca | 2017-02-06 07:53:41 -0800 | [diff] [blame] | 351 | |
| 352 | |
| 353 | if __name__ == '__main__': |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame] | 354 | sys.exit(main()) |