3 # XXX This will be replaced by a main program in Mac/Lib/bundlebuilder.py,
4 # but for now this is kept so Jack won't need to change his scripts...
8 buildappbundle creates an application bundle
10 buildappbundle [options] executable
12 --output o Output file; default executable with .app appended, short -o
13 --link Symlink the executable instead of copying it, short -l
14 --plist file Plist file (default: generate one), short -p
15 --nib file Main nib file or lproj folder for Cocoa program, short -n
16 --resource r Extra resource file to be copied to Resources, short -r
17 --creator c 4-char creator code (default: '????'), short -c
18 --verbose increase verbosity level (default: quiet), short -v
19 --help This message, short -? or -h
26 from bundlebuilder
import AppBuilder
27 from plistlib
import Plist
43 SHORTOPTS
= "o:ln:r:p:c:v?h"
44 LONGOPTS
=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help",
47 options
, args
= getopt
.getopt(sys
.argv
[1:], SHORTOPTS
, LONGOPTS
)
53 for opt
, arg
in options
:
54 if opt
in ('-o', '--output'):
56 elif opt
in ('-l', '--link'):
58 elif opt
in ('-n', '--nib'):
60 elif opt
in ('-r', '--resource'):
62 elif opt
in ('-c', '--creator'):
64 elif opt
in ('-p', '--plist'):
66 elif opt
in ('-v', '--verbose'):
68 elif opt
in ('-?', '-h', '--help'):
70 if output
is not None:
71 builddir
, bundlename
= os
.path
.split(output
)
74 bundlename
= None # will be derived from executable
76 plist
= Plist
.fromFile(plist
)
78 builder
= AppBuilder(name
=bundlename
, executable
=executable
,
79 builddir
=builddir
, creator
=creator
, plist
=plist
, resources
=resources
,
80 symlink_exec
=symlink
, verbosity
=verbosity
)
84 nibname
, ext
= os
.path
.splitext(os
.path
.basename(nib
))
86 # Special case: if the main nib is a .lproj we assum a directory
87 # and use the first nib from there. XXX Look: an arbitrary pick ;-)
88 files
= os
.listdir(nib
)
91 nibname
= os
.path
.split(f
)[1][:-4]
96 builder
.plist
.NSMainNibFile
= nibname
97 if not hasattr(builder
.plist
, "NSPrincipalClass"):
98 builder
.plist
.NSPrincipalClass
= "NSApplication"
103 if __name__
== '__main__':