| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import argparse | |
| 7 import os | |
| 8 import errno | |
| 9 import subprocess | |
| 10 import sys | |
| 11 | |
| 12 PLUTIL = [ | |
| 13 '/usr/bin/env', | |
| 14 'xcrun', | |
| 15 'plutil' | |
| 16 ] | |
| 17 | |
| 18 def MakeDirectories(path): | |
| 19 try: | |
| 20 os.makedirs(path) | |
| 21 except OSError as exc: | |
| 22 if exc.errno == errno.EEXIST and os.path.isdir(path): | |
| 23 return 0 | |
| 24 else: | |
| 25 return -1 | |
| 26 | |
| 27 return 0 | |
| 28 | |
| 29 | |
| 30 def ProcessInfoPlist(args): | |
| 31 output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist')) | |
| 32 | |
| 33 if MakeDirectories(os.path.dirname(output_plist_file)) == -1: | |
| 34 return -1 | |
| 35 | |
| 36 return subprocess.check_call( PLUTIL + [ | |
| 37 '-convert', | |
| 38 'binary1', | |
| 39 '-o', | |
| 40 output_plist_file, | |
| 41 '--', | |
| 42 args.input, | |
| 43 ]) | |
| 44 | |
| 45 | |
| 46 def PerformCodeSigning(args): | |
| 47 return subprocess.check_call([ | |
| 48 '/usr/bin/env', | |
| 49 'xcrun', | |
| 50 'codesign', | |
| 51 '--entitlements', | |
| 52 args.entitlements_path, | |
| 53 '--sign', | |
| 54 args.identity, | |
| 55 '-f', | |
| 56 args.application_path, | |
| 57 ]) | |
| 58 | |
| 59 def GenerateDSYM(args): | |
| 60 return subprocess.check_call([ | |
| 61 '/usr/bin/env', | |
| 62 'xcrun', | |
| 63 'dsymutil', | |
| 64 '-o', | |
| 65 args.output, | |
| 66 args.executable_path | |
| 67 ]) | |
| 68 | |
| 69 | |
| 70 def GenerateProjectStructure(args): | |
| 71 application_path = os.path.join( args.dir, args.name + ".app" ) | |
| 72 return MakeDirectories( application_path ) | |
| 73 | |
| 74 | |
| 75 def Main(): | |
| 76 parser = argparse.ArgumentParser(description='A script that aids in ' | |
| 77 'the creation of an iOS application') | |
| 78 | |
| 79 subparsers = parser.add_subparsers() | |
| 80 | |
| 81 # Plist Parser | |
| 82 | |
| 83 plist_parser = subparsers.add_parser('plist', | |
| 84 help='Process the Info.plist') | |
| 85 plist_parser.set_defaults(func=ProcessInfoPlist) | |
| 86 | |
| 87 plist_parser.add_argument('-i', dest='input', help='The input plist path') | |
| 88 plist_parser.add_argument('-o', dest='output', help='The output plist dir') | |
| 89 | |
| 90 # Directory Structure Parser | |
| 91 | |
| 92 dir_struct_parser = subparsers.add_parser('structure', | |
| 93 help='Creates the directory of an iOS application') | |
| 94 | |
| 95 dir_struct_parser.set_defaults(func=GenerateProjectStructure) | |
| 96 | |
| 97 dir_struct_parser.add_argument('-d', dest='dir', help='Out directory') | |
| 98 dir_struct_parser.add_argument('-n', dest='name', help='App name') | |
| 99 | |
| 100 # Code Signing | |
| 101 | |
| 102 code_signing_parser = subparsers.add_parser('codesign', | |
| 103 help='Code sign the specified application') | |
| 104 | |
| 105 code_signing_parser.set_defaults(func=PerformCodeSigning) | |
| 106 | |
| 107 code_signing_parser.add_argument('-p', dest='application_path', required=True, | |
| 108 help='The application path') | |
| 109 code_signing_parser.add_argument('-i', dest='identity', required=True, | |
| 110 help='The code signing identity to use') | |
| 111 code_signing_parser.add_argument('-e', dest='entitlements_path', | |
| 112 required=True, | |
| 113 help='The path to the entitlements .xcent') | |
| 114 | |
| 115 # dSYM Generation | |
| 116 | |
| 117 dsym_generation_parser = subparsers.add_parser('dsym', | |
| 118 help='Generate a .dSYM file for an executable') | |
| 119 | |
| 120 dsym_generation_parser.set_defaults(func=GenerateDSYM) | |
| 121 | |
| 122 dsym_generation_parser.add_argument('-e', dest='executable_path', | |
| 123 required=True, | |
| 124 help='The executable path') | |
| 125 dsym_generation_parser.add_argument('-o', dest='output', | |
| 126 required=True, | |
| 127 help='The output file name') | |
| 128 | |
| 129 # Engage! | |
| 130 | |
| 131 args = parser.parse_args() | |
| 132 | |
| 133 return args.func(args) | |
| 134 | |
| 135 | |
| 136 if __name__ == '__main__': | |
| 137 sys.exit(Main()) | |
| OLD | NEW |