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.
11 def MakeDirectories(path
):
14 except OSError as exc
:
15 if exc
.errno
== errno
.EEXIST
and os
.path
.isdir(path
):
23 def ProcessInfoPlist(args
):
24 output_plist_file
= os
.path
.abspath(os
.path
.join(args
.output
, 'Info.plist'))
25 return subprocess
.check_call([
39 output_nib_file
= os
.path
.join(os
.path
.abspath(args
.output
),
40 "%s.nib" % os
.path
.splitext(os
.path
.basename(args
.input))[0])
42 return subprocess
.check_call([
48 '--auto-activate-custom-fonts',
53 os
.path
.abspath(args
.input),
57 def GenerateProjectStructure(args
):
58 application_path
= os
.path
.join( args
.dir, args
.name
+ ".app", "Contents" )
59 return MakeDirectories( application_path
)
63 parser
= argparse
.ArgumentParser(description
='A script that aids in '
64 'the creation of an Mac application')
66 subparsers
= parser
.add_subparsers()
69 plist_parser
= subparsers
.add_parser('plist',
70 help='Process the Info.plist')
71 plist_parser
.set_defaults(func
=ProcessInfoPlist
)
73 plist_parser
.add_argument('-i', dest
='input', help='The input plist path')
74 plist_parser
.add_argument('-o', dest
='output', help='The output plist dir')
77 plist_parser
= subparsers
.add_parser('nib',
78 help='Process a NIB file')
79 plist_parser
.set_defaults(func
=ProcessNIB
)
81 plist_parser
.add_argument('-i', dest
='input', help='The input nib path')
82 plist_parser
.add_argument('-o', dest
='output', help='The output nib dir')
83 plist_parser
.add_argument('-m', dest
='module', help='The module name')
85 # Directory Structure Parser
86 dir_struct_parser
= subparsers
.add_parser('structure',
87 help='Creates the directory of an Mac application')
89 dir_struct_parser
.set_defaults(func
=GenerateProjectStructure
)
91 dir_struct_parser
.add_argument('-d', dest
='dir', help='Out directory')
92 dir_struct_parser
.add_argument('-n', dest
='name', help='App name')
94 args
= parser
.parse_args()
95 return args
.func(args
)
98 if __name__
== '__main__':