Flutter Engine
The Flutter Engine
Functions | Variables
tweak_info_plist Namespace Reference

Functions

def Main (argv)
 

Variables

 TOP = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
 

Function Documentation

◆ Main()

def tweak_info_plist.Main (   argv)

Definition at line 199 of file tweak_info_plist.py.

199def Main(argv):
200 parser = optparse.OptionParser('%prog [options]')
201 parser.add_option(
202 '--breakpad',
203 dest='use_breakpad',
204 action='store',
205 type='int',
206 default=False,
207 help='Enable Breakpad [1 or 0]')
208 parser.add_option(
209 '--breakpad_uploads',
210 dest='breakpad_uploads',
211 action='store',
212 type='int',
213 default=False,
214 help='Enable Breakpad\'s uploading of crash dumps [1 or 0]')
215 parser.add_option(
216 '--keystone',
217 dest='use_keystone',
218 action='store',
219 type='int',
220 default=False,
221 help='Enable Keystone [1 or 0]')
222 parser.add_option(
223 '--scm',
224 dest='add_scm_info',
225 action='store',
226 type='int',
227 default=True,
228 help='Add SCM metadata [1 or 0]')
229 parser.add_option(
230 '--branding',
231 dest='branding',
232 action='store',
233 type='string',
234 default=None,
235 help='The branding of the binary')
236 parser.add_option(
237 '--bundle_id',
238 dest='bundle_identifier',
239 action='store',
240 type='string',
241 default=None,
242 help='The bundle id of the binary')
243 parser.add_option(
244 '--version',
245 dest='version',
246 action='store',
247 type='string',
248 default=None,
249 help='The version string [major.minor.build.patch]')
250 (options, args) = parser.parse_args(argv)
251
252 if len(args) > 0:
253 print(parser.get_usage(), file=sys.stderr)
254 return 1
255
256 # Read the plist into its parsed format.
257 DEST_INFO_PLIST = os.path.join(env['TARGET_BUILD_DIR'],
258 env['INFOPLIST_PATH'])
259 plist = plistlib.readPlist(DEST_INFO_PLIST)
260
261 # Insert the product version.
262 if not _AddVersionKeys(plist, version=options.version):
263 return 2
264
265 # Add Breakpad if configured to do so.
266 if options.use_breakpad:
267 if options.branding is None:
268 print('Use of Breakpad requires branding.', file=sys.stderr)
269 return 1
270 _AddBreakpadKeys(plist, options.branding)
271 if options.breakpad_uploads:
272 plist['BreakpadURL'] = 'https://clients2.google.com/cr/report'
273 else:
274 # This allows crash dumping to a file without uploading the
275 # dump, for testing purposes. Breakpad does not recognise
276 # "none" as a special value, but this does stop crash dump
277 # uploading from happening. We need to specify something
278 # because if "BreakpadURL" is not present, Breakpad will not
279 # register its crash handler and no crash dumping will occur.
280 plist['BreakpadURL'] = 'none'
281 else:
282 _RemoveBreakpadKeys(plist)
283
284 # Only add Keystone in Release builds.
285 if options.use_keystone and env['CONFIGURATION'] == 'Release':
286 if options.bundle_identifier is None:
287 print('Use of Keystone requires the bundle id.', file=sys.stderr)
288 return 1
289 _AddKeystoneKeys(plist, options.bundle_identifier)
290 else:
291 _RemoveKeystoneKeys(plist)
292
293 # Adds or removes any SCM keys.
294 if not _DoSCMKeys(plist, options.add_scm_info):
295 return 3
296
297 # Now that all keys have been mutated, rewrite the file.
298 temp_info_plist = tempfile.NamedTemporaryFile()
299 plistlib.writePlist(plist, temp_info_plist.name)
300
301 # Info.plist will work perfectly well in any plist format, but traditionally
302 # applications use xml1 for this, so convert it to ensure that it's valid.
303 proc = subprocess.Popen([
304 'plutil', '-convert', 'xml1', '-o', DEST_INFO_PLIST,
305 temp_info_plist.name
306 ])
307 proc.wait()
308 return proc.returncode
309
310
def print(*args, **kwargs)
Definition: run_tests.py:49

Variable Documentation

◆ TOP

tweak_info_plist.TOP = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))

Definition at line 32 of file tweak_info_plist.py.