Kaydet (Commit) 16aebf77 authored tarafından Just van Rossum's avatar Just van Rossum

Added --link-exec option: make a symlink for the executable only, copy all other files.

üst 224405fc
...@@ -212,16 +212,18 @@ class AppBuilder(BundleBuilder): ...@@ -212,16 +212,18 @@ class AppBuilder(BundleBuilder):
it will simply be used as the main executable. it will simply be used as the main executable.
nibname: The name of the main nib, for Cocoa apps. Defaults nibname: The name of the main nib, for Cocoa apps. Defaults
to None, but must be specified when building a Cocoa app. to None, but must be specified when building a Cocoa app.
symlink_exec: Symlink the executable instead of copying it.
For the other keyword arguments see the BundleBuilder doc string. For the other keyword arguments see the BundleBuilder doc string.
""" """
def __init__(self, name=None, mainprogram=None, executable=None, def __init__(self, name=None, mainprogram=None, executable=None,
nibname=None, **kwargs): nibname=None, symlink_exec=0, **kwargs):
"""See the class doc string for a description of the arguments.""" """See the class doc string for a description of the arguments."""
self.mainprogram = mainprogram self.mainprogram = mainprogram
self.executable = executable self.executable = executable
self.nibname = nibname self.nibname = nibname
self.symlink_exec = symlink_exec
BundleBuilder.__init__(self, name=name, **kwargs) BundleBuilder.__init__(self, name=name, **kwargs)
def setup(self): def setup(self):
...@@ -254,7 +256,10 @@ class AppBuilder(BundleBuilder): ...@@ -254,7 +256,10 @@ class AppBuilder(BundleBuilder):
execpath = pathjoin(self.execdir, self.name) execpath = pathjoin(self.execdir, self.name)
else: else:
execpath = pathjoin(resdir, os.path.basename(self.executable)) execpath = pathjoin(resdir, os.path.basename(self.executable))
self.files.append((self.executable, execpath)) if not self.symlink_exec:
self.files.append((self.executable, execpath))
else:
self.execpath = execpath
# For execve wrapper # For execve wrapper
setexecutable = setExecutableTemplate % os.path.basename(self.executable) setexecutable = setExecutableTemplate % os.path.basename(self.executable)
else: else:
...@@ -272,6 +277,14 @@ class AppBuilder(BundleBuilder): ...@@ -272,6 +277,14 @@ class AppBuilder(BundleBuilder):
open(mainwrapperpath, "w").write(mainWrapperTemplate % locals()) open(mainwrapperpath, "w").write(mainWrapperTemplate % locals())
os.chmod(mainwrapperpath, 0777) os.chmod(mainwrapperpath, 0777)
def postProcess(self):
if self.symlink_exec and self.executable:
self.message("Symlinking executable %s to %s" % (self.executable,
self.execpath), 2)
dst = pathjoin(self.bundlepath, self.execpath)
makedirs(os.path.dirname(dst))
os.symlink(os.path.abspath(self.executable), dst)
def copy(src, dst, mkdirs=0): def copy(src, dst, mkdirs=0):
"""Copy a file or a directory.""" """Copy a file or a directory."""
...@@ -329,6 +342,7 @@ Options: ...@@ -329,6 +342,7 @@ Options:
--nib=NAME main nib name --nib=NAME main nib name
-c, --creator=CCCC 4-char creator code (default: '????') -c, --creator=CCCC 4-char creator code (default: '????')
-l, --link symlink files/folder instead of copying them -l, --link symlink files/folder instead of copying them
--link-exec symlink the executable instead of copying it
-v, --verbose increase verbosity level -v, --verbose increase verbosity level
-q, --quiet decrease verbosity level -q, --quiet decrease verbosity level
-h, --help print this message -h, --help print this message
...@@ -346,8 +360,8 @@ def main(builder=None): ...@@ -346,8 +360,8 @@ def main(builder=None):
shortopts = "b:n:r:e:m:c:plhvq" shortopts = "b:n:r:e:m:c:plhvq"
longopts = ("builddir=", "name=", "resource=", "executable=", longopts = ("builddir=", "name=", "resource=", "executable=",
"mainprogram=", "creator=", "nib=", "plist=", "link", "help", "mainprogram=", "creator=", "nib=", "plist=", "link",
"verbose", "quiet") "link-exec", "help", "verbose", "quiet")
try: try:
options, args = getopt.getopt(sys.argv[1:], shortopts, longopts) options, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
...@@ -373,6 +387,8 @@ def main(builder=None): ...@@ -373,6 +387,8 @@ def main(builder=None):
builder.plist = Plist.fromFile(arg) builder.plist = Plist.fromFile(arg)
elif opt in ('-l', '--link'): elif opt in ('-l', '--link'):
builder.symlink = 1 builder.symlink = 1
elif opt == '--link-exec':
builder.symlink_exec = 1
elif opt in ('-h', '--help'): elif opt in ('-h', '--help'):
usage() usage()
elif opt in ('-v', '--verbose'): elif opt in ('-v', '--verbose'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment