Chromium Code Reviews| Index: build/config/ios/ios_app.py |
| diff --git a/build/config/ios/ios_app.py b/build/config/ios/ios_app.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6b1b21340e3f3585473aed6ffc778589d0aff2a0 |
| --- /dev/null |
| +++ b/build/config/ios/ios_app.py |
| @@ -0,0 +1,109 @@ |
| +# Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import argparse |
| +import os |
|
sdefresne
2015/07/25 19:15:30
nit: sort
Dirk Pranke
2015/07/31 21:27:40
Done.
|
| +import errno |
| +import subprocess |
| +import sys |
| + |
| +PLUTIL = [ |
|
sdefresne
2015/07/25 19:15:30
nit: why use a global for a constant that is only
Dirk Pranke
2015/07/31 21:27:40
Good catch. Fixed.
|
| + '/usr/bin/env', |
| + 'xcrun', |
| + 'plutil' |
| +] |
| + |
| + |
| +def ProcessInfoPlist(args): |
| + output_plist_file = os.path.abspath(os.path.join(args.output, 'Info.plist')) |
| + return subprocess.check_call( PLUTIL + [ |
| + '-convert', |
| + 'binary1', |
| + '-o', |
| + output_plist_file, |
| + '--', |
| + args.input, |
| + ]) |
| + |
| + |
| +def PerformCodeSigning(args): |
| + return subprocess.check_call([ |
| + '/usr/bin/env', |
| + 'xcrun', |
| + 'codesign', |
| + '--entitlements', |
| + args.entitlements_path, |
| + '--sign', |
| + args.identity, |
| + '-f', |
| + args.application_path, |
| + ]) |
| + |
| + |
| +def MakeDirectories(path): |
| + try: |
| + os.makedirs(path) |
| + except OSError as exc: |
| + if exc.errno == errno.EEXIST and os.path.isdir(path): |
| + return 0 |
| + else: |
| + return -1 |
| + |
| + return 0 |
| + |
| + |
| +def GenerateProjectStructure(args): |
| + application_path = os.path.join( args.dir, args.name + ".app" ) |
|
sdefresne
2015/07/25 19:15:30
style: no space after "(" nor before ")"
Dirk Pranke
2015/07/31 21:27:40
Done.
|
| + return MakeDirectories( application_path ) |
| + |
| + |
| +def Main(): |
|
sdefresne
2015/07/25 19:15:30
nit: even though Python style guide recommends cap
Dirk Pranke
2015/07/31 21:27:40
Done.
|
| + parser = argparse.ArgumentParser(description='A script that aids in ' |
| + 'the creation of an iOS application') |
| + |
| + subparsers = parser.add_subparsers() |
| + |
| + # Plist Parser |
| + |
| + plist_parser = subparsers.add_parser('plist', |
| + help='Process the Info.plist') |
| + plist_parser.set_defaults(func=ProcessInfoPlist) |
| + |
| + plist_parser.add_argument('-i', dest='input', help='The input plist path') |
| + plist_parser.add_argument('-o', dest='output', help='The output plist dir') |
| + |
| + # Directory Structure Parser |
| + |
| + dir_struct_parser = subparsers.add_parser('structure', |
| + help='Creates the directory of an iOS application') |
| + |
| + dir_struct_parser.set_defaults(func=GenerateProjectStructure) |
| + |
| + dir_struct_parser.add_argument('-d', dest='dir', help='Out directory') |
| + dir_struct_parser.add_argument('-n', dest='name', help='App name') |
| + |
| + # Code Signing |
| + |
| + code_signing_parser = subparsers.add_parser('codesign', |
| + help='Code sign the specified application') |
| + |
| + code_signing_parser.set_defaults(func=PerformCodeSigning) |
| + |
| + code_signing_parser.add_argument('-p', dest='application_path', required=True, |
| + help='The application path') |
| + code_signing_parser.add_argument('-i', dest='identity', required=True, |
| + help='The code signing identity to use') |
| + code_signing_parser.add_argument('-e', dest='entitlements_path', |
| + required=True, |
| + help='The path to the entitlements .xcent') |
| + |
| + # Engage! |
| + |
| + args = parser.parse_args() |
| + |
|
sdefresne
2015/07/25 19:15:30
nit: remove newline
Dirk Pranke
2015/07/31 21:27:40
Done (removed a few others as well).
|
| + return args.func(args) |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(Main()) |