Update broken references to image assets
[chromium-blink-merge.git] / build / config / ios / ios_app.py
blob54a68ac238f1a2071742eb4c0388efbfc054d3df
1 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import argparse
6 import errno
7 import os
8 import subprocess
9 import sys
12 def ProcessInfoPlist(args):
13 output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist'))
14 return subprocess.check_call( [
15 '/usr/bin/env',
16 'xcrun',
17 'plutil',
18 '-convert',
19 'binary1',
20 '-o',
21 output_plist_file,
22 '--',
23 args.input,
27 def PerformCodeSigning(args):
28 return subprocess.check_call([
29 '/usr/bin/env',
30 'xcrun',
31 'codesign',
32 '--entitlements',
33 args.entitlements_path,
34 '--sign',
35 args.identity,
36 '-f',
37 args.application_path,
41 def MakeDirectories(path):
42 try:
43 os.makedirs(path)
44 except OSError as exc:
45 if exc.errno == errno.EEXIST and os.path.isdir(path):
46 return 0
47 else:
48 return -1
49 return 0
52 def GenerateProjectStructure(args):
53 application_path = os.path.join(args.dir, args.name + ".app")
54 return MakeDirectories( application_path )
57 def main():
58 parser = argparse.ArgumentParser(description='A script that aids in '
59 'the creation of an iOS application')
60 subparsers = parser.add_subparsers()
62 # Plist Parser
63 plist_parser = subparsers.add_parser('plist',
64 help='Process the Info.plist')
65 plist_parser.set_defaults(func=ProcessInfoPlist)
67 plist_parser.add_argument('-i', dest='input', help='The input plist path')
68 plist_parser.add_argument('-o', dest='output', help='The output plist dir')
70 # Directory Structure Parser
71 dir_struct_parser = subparsers.add_parser('structure',
72 help='Creates the directory of an iOS application')
74 dir_struct_parser.set_defaults(func=GenerateProjectStructure)
76 dir_struct_parser.add_argument('-d', dest='dir', help='Out directory')
77 dir_struct_parser.add_argument('-n', dest='name', help='App name')
79 # Code Signing
80 code_signing_parser = subparsers.add_parser('codesign',
81 help='Code sign the specified application')
83 code_signing_parser.set_defaults(func=PerformCodeSigning)
85 code_signing_parser.add_argument('-p', dest='application_path', required=True,
86 help='The application path')
87 code_signing_parser.add_argument('-i', dest='identity', required=True,
88 help='The code signing identity to use')
89 code_signing_parser.add_argument('-e', dest='entitlements_path',
90 required=True,
91 help='The path to the entitlements .xcent')
93 # Engage!
94 args = parser.parse_args()
95 return args.func(args)
98 if __name__ == '__main__':
99 sys.exit(main())