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

Side by Side Diff: tools-webrtc/ios/build_ios_libs.py

Issue 2740923003: Add flag to clean up temporary results after building iOS Framework or static lib (Closed)
Patch Set: Clean up temporary results after building iOS Framework or static lib Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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', '--clean-temp', action='store_true', default=False,
54 help='Removes the temporary build files from the output directory.')
kjellander_webrtc 2017/03/13 13:15:02 It's not clear to me that the script will exit aft
53 parser.add_argument('-o', '--output-dir', default=SDK_OUTPUT_DIR, 55 parser.add_argument('-o', '--output-dir', default=SDK_OUTPUT_DIR,
54 help='Specifies a directory to output the build artifacts to. ' 56 help='Specifies a directory to output the build artifacts to. '
55 'If specified together with -c, deletes the dir.') 57 'If specified together with -c, deletes the dir.')
56 parser.add_argument('-r', '--revision', type=int, default=0, 58 parser.add_argument('-r', '--revision', type=int, default=0,
57 help='Specifies a revision number to embed if building the framework.') 59 help='Specifies a revision number to embed if building the framework.')
58 parser.add_argument('-e', '--bitcode', action='store_true', default=False, 60 parser.add_argument('-e', '--bitcode', action='store_true', default=False,
59 help='Compile with bitcode.') 61 help='Compile with bitcode.')
60 parser.add_argument('--verbose', action='store_true', default=False, 62 parser.add_argument('--verbose', action='store_true', default=False,
61 help='Debug logging.') 63 help='Debug logging.')
62 parser.add_argument('--use-goma', action='store_true', default=False, 64 parser.add_argument('--use-goma', action='store_true', default=False,
63 help='Use goma to build.') 65 help='Use goma to build.')
64 parser.add_argument('--extra-gn-args', default=[], nargs='*', 66 parser.add_argument('--extra-gn-args', default=[], nargs='*',
65 help='Additional GN args to be used during Ninja generation.') 67 help='Additional GN args to be used during Ninja generation.')
66 68
67 return parser.parse_args() 69 return parser.parse_args()
68 70
69 71
70 def _RunCommand(cmd): 72 def _RunCommand(cmd):
71 logging.debug('Running: %r', cmd) 73 logging.debug('Running: %r', cmd)
72 subprocess.check_call(cmd, cwd=WEBRTC_SRC_DIR) 74 subprocess.check_call(cmd, cwd=WEBRTC_SRC_DIR)
73 75
74 76
75 def _CleanArtifacts(output_dir): 77 def _CleanArtifacts(output_dir):
76 if os.path.isdir(output_dir): 78 if os.path.isdir(output_dir):
77 logging.info('Deleting %s', output_dir) 79 logging.info('Deleting %s', output_dir)
78 shutil.rmtree(output_dir) 80 shutil.rmtree(output_dir)
79 81
80 82
83 def _CleanTemporary(output_dir, architectures):
84 if os.path.isdir(output_dir):
85 logging.info('Removing temporary build files.')
86 for arch in architectures:
87 arch_lib_path = os.path.join(output_dir, arch + '_libs')
88 if os.path.isdir(arch_lib_path):
89 shutil.rmtree(arch_lib_path)
90
91
81 def BuildWebRTC(output_dir, target_arch, flavor, build_type, 92 def BuildWebRTC(output_dir, target_arch, flavor, build_type,
82 ios_deployment_target, libvpx_build_vp9, use_bitcode, 93 ios_deployment_target, libvpx_build_vp9, use_bitcode,
83 use_goma, extra_gn_args): 94 use_goma, extra_gn_args):
84 output_dir = os.path.join(output_dir, target_arch + '_libs') 95 output_dir = os.path.join(output_dir, target_arch + '_libs')
85 gn_args = ['target_os="ios"', 'ios_enable_code_signing=false', 96 gn_args = ['target_os="ios"', 'ios_enable_code_signing=false',
86 'use_xcode_clang=true', 'is_component_build=false'] 97 'use_xcode_clang=true', 'is_component_build=false']
87 98
88 # Add flavor option. 99 # Add flavor option.
89 if flavor == 'debug': 100 if flavor == 'debug':
90 gn_args.append('is_debug=true') 101 gn_args.append('is_debug=true')
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 def main(): 150 def main():
140 args = _ParseArgs() 151 args = _ParseArgs()
141 152
142 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO) 153 logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
143 154
144 if args.clean: 155 if args.clean:
145 _CleanArtifacts(args.output_dir) 156 _CleanArtifacts(args.output_dir)
146 return 0 157 return 0
147 158
148 architectures = list(args.arch) 159 architectures = list(args.arch)
160
161 if args.clean_temp:
162 _CleanTemporary(args.output_dir, architectures)
163 return 0
164
149 # Ignoring x86 except for static libraries for now because of a GN build issue 165 # Ignoring x86 except for static libraries for now because of a GN build issue
150 # where the generated dynamic framework has the wrong architectures. 166 # where the generated dynamic framework has the wrong architectures.
151 if 'x86' in architectures and args.build_type != 'static_only': 167 if 'x86' in architectures and args.build_type != 'static_only':
152 architectures.remove('x86') 168 architectures.remove('x86')
153 169
154 # Build all architectures. 170 # Build all architectures.
155 for arch in architectures: 171 for arch in architectures:
156 BuildWebRTC(args.output_dir, arch, args.build_config, args.build_type, 172 BuildWebRTC(args.output_dir, arch, args.build_config, args.build_type,
157 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode, 173 IOS_DEPLOYMENT_TARGET, LIBVPX_BUILD_VP9, args.bitcode,
158 args.use_goma, args.extra_gn_args) 174 args.use_goma, args.extra_gn_args)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 cmd = ['PlistBuddy', '-c', 228 cmd = ['PlistBuddy', '-c',
213 'Print :CFBundleShortVersionString', infoplist_path] 229 'Print :CFBundleShortVersionString', infoplist_path]
214 major_minor = subprocess.check_output(cmd).strip() 230 major_minor = subprocess.check_output(cmd).strip()
215 version_number = '%s.%s' % (major_minor, args.revision) 231 version_number = '%s.%s' % (major_minor, args.revision)
216 logging.info('Substituting revision number: %s', version_number) 232 logging.info('Substituting revision number: %s', version_number)
217 cmd = ['PlistBuddy', '-c', 233 cmd = ['PlistBuddy', '-c',
218 'Set :CFBundleVersion ' + version_number, infoplist_path] 234 'Set :CFBundleVersion ' + version_number, infoplist_path]
219 _RunCommand(cmd) 235 _RunCommand(cmd)
220 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path]) 236 _RunCommand(['plutil', '-convert', 'binary1', infoplist_path])
221 237
238
kjellander_webrtc 2017/03/13 13:15:02 nit: Remove this blank line.
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())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698