2002-11-22 11:10:49 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
# XXX This will be replaced by a main program in Mac/Lib/bundlebuilder.py,
|
|
|
|
# but for now this is kept so Jack won't need to change his scripts...
|
|
|
|
|
|
|
|
|
|
|
|
"""\
|
|
|
|
buildappbundle creates an application bundle
|
|
|
|
Usage:
|
|
|
|
buildappbundle [options] executable
|
|
|
|
Options:
|
|
|
|
--output o Output file; default executable with .app appended, short -o
|
2002-11-22 11:45:42 +00:00
|
|
|
--link Symlink the executable instead of copying it, short -l
|
2002-11-22 11:10:49 +00:00
|
|
|
--plist file Plist file (default: generate one), short -p
|
|
|
|
--nib file Main nib file or lproj folder for Cocoa program, short -n
|
|
|
|
--resource r Extra resource file to be copied to Resources, short -r
|
|
|
|
--creator c 4-char creator code (default: '????'), short -c
|
|
|
|
--verbose increase verbosity level (default: quiet), short -v
|
|
|
|
--help This message, short -? or -h
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2002-11-06 23:15:51 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import getopt
|
2002-11-22 11:10:49 +00:00
|
|
|
from bundlebuilder import AppBuilder
|
|
|
|
from plistlib import Plist
|
|
|
|
|
2002-11-06 23:15:51 +00:00
|
|
|
|
|
|
|
def usage():
|
2002-11-22 11:10:49 +00:00
|
|
|
print __doc__
|
2002-11-06 23:15:51 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
2002-11-22 11:10:49 +00:00
|
|
|
|
2002-11-06 23:15:51 +00:00
|
|
|
def main():
|
2002-11-22 11:10:49 +00:00
|
|
|
output = None
|
|
|
|
symlink = 0
|
|
|
|
creator = "????"
|
|
|
|
plist = None
|
|
|
|
nib = None
|
|
|
|
resources = []
|
|
|
|
verbosity = 0
|
|
|
|
SHORTOPTS = "o:ln:r:p:c:v?h"
|
|
|
|
LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help",
|
|
|
|
"verbose")
|
2002-11-06 23:15:51 +00:00
|
|
|
try:
|
|
|
|
options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS)
|
|
|
|
except getopt.error:
|
|
|
|
usage()
|
|
|
|
if len(args) != 1:
|
|
|
|
usage()
|
2002-11-22 11:10:49 +00:00
|
|
|
executable = args[0]
|
2002-11-06 23:15:51 +00:00
|
|
|
for opt, arg in options:
|
|
|
|
if opt in ('-o', '--output'):
|
|
|
|
output = arg
|
|
|
|
elif opt in ('-l', '--link'):
|
2002-11-22 11:10:49 +00:00
|
|
|
symlink = 1
|
2002-11-06 23:15:51 +00:00
|
|
|
elif opt in ('-n', '--nib'):
|
|
|
|
nib = arg
|
|
|
|
elif opt in ('-r', '--resource'):
|
|
|
|
resources.append(arg)
|
|
|
|
elif opt in ('-c', '--creator'):
|
|
|
|
creator = arg
|
|
|
|
elif opt in ('-p', '--plist'):
|
|
|
|
plist = arg
|
2002-11-22 11:10:49 +00:00
|
|
|
elif opt in ('-v', '--verbose'):
|
|
|
|
verbosity += 1
|
|
|
|
elif opt in ('-?', '-h', '--help'):
|
2002-11-06 23:15:51 +00:00
|
|
|
usage()
|
2002-11-22 11:10:49 +00:00
|
|
|
if output is not None:
|
|
|
|
builddir, bundlename = os.path.split(output)
|
|
|
|
else:
|
|
|
|
builddir = os.curdir
|
|
|
|
bundlename = None # will be derived from executable
|
|
|
|
if plist is not None:
|
|
|
|
plist = Plist.fromFile(plist)
|
|
|
|
|
|
|
|
builder = AppBuilder(name=bundlename, executable=executable,
|
|
|
|
builddir=builddir, creator=creator, plist=plist, resources=resources,
|
2002-11-22 11:45:42 +00:00
|
|
|
symlink_exec=symlink, verbosity=verbosity)
|
2002-11-22 11:10:49 +00:00
|
|
|
|
|
|
|
if nib is not None:
|
|
|
|
resources.append(nib)
|
|
|
|
nibname, ext = os.path.splitext(os.path.basename(nib))
|
|
|
|
if ext == '.lproj':
|
|
|
|
# Special case: if the main nib is a .lproj we assum a directory
|
|
|
|
# and use the first nib from there. XXX Look: an arbitrary pick ;-)
|
|
|
|
files = os.listdir(nib)
|
|
|
|
for f in files:
|
|
|
|
if f[-4:] == '.nib':
|
|
|
|
nibname = os.path.split(f)[1][:-4]
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
nibname = ""
|
|
|
|
if nibname:
|
|
|
|
builder.plist.NSMainNibFile = nibname
|
|
|
|
if not hasattr(builder.plist, "NSPrincipalClass"):
|
|
|
|
builder.plist.NSPrincipalClass = "NSApplication"
|
|
|
|
builder.setup()
|
|
|
|
builder.build()
|
|
|
|
|
|
|
|
|
2002-11-06 23:15:51 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|