Transforms the process type under Mac OS X (darwin platform) in foreground mode if we're running with the windowed loader: this allows to both have focus and a dock icon for the running application, while the unpacker helper application still doesn't get a dock icon - to do so and still have a non-Carbon loader for console apps, this patch adds a windowed loader (with specific cflags and ldflags) and its debug counterpart.

git-svn-id: http://svn.pyinstaller.org/trunk@848 8dd32b29-ccff-0310-8a9a-9233e24343b1
This commit is contained in:
lmancini
2010-06-08 10:44:27 +00:00
parent c2670235a6
commit 1a187b2df6
4 changed files with 39 additions and 10 deletions
+4 -3
View File
@@ -1114,9 +1114,10 @@ class BUNDLE(Target):
# Setting this to 1 will cause Mac OS X *not* to show
# a dock icon for the PyInstaller process which
# decompresses the real executable's contents -
# actually, it's not clear why the real executable
# gets instead an icon doing so.
# decompresses the real executable's contents. As a
# side effect, the main application doesn't get one
# as well, but at startup time the loader will take
# care of transforming the process type.
"LSBackgroundOnly": "1",
}
+23 -3
View File
@@ -120,9 +120,11 @@ def main():
pprint.pprint(config, configf)
configf.close()
targets = [None, None]
targets = [None, None, None, None]
targets[0] = os.path.join('../../support/loader/', 'run')
targets[1] = os.path.join('../../support/loader/', 'run_d')
targets[2] = os.path.join('../../support/loader/', 'runw')
targets[3] = os.path.join('../../support/loader/', 'runw_d')
# include local 'common' dir
includes.append('-I../common')
@@ -184,11 +186,29 @@ def main():
files + \
['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)', '-lz'] # XXX zlib not always -lz
## Windowed and debug need per-target cflags and ldflags, we'll pass them to
# makemakefile.writerules.
flagsw = '-DWINDOWED'
flags_d = '-D_DEBUG -DLAUNCH_DEBUG'
ldflagsw = ''
ldflags_d = ''
if sys.platform.startswith("darwin"):
flagsw += " -I/Developer/Headers/FlatCarbon"
ldflagsw += " -framework Carbon"
flagsw_d = ' '.join([flagsw, flags_d])
ldflagsw_d = ' '.join([ldflagsw, ldflags_d])
##
outfp = bkfile.open('Makefile', 'w')
try:
makemakefile.writevars(outfp, somevars, string.join(targets))
makemakefile.writerules(outfp, files[:], '', '', targets[0])
makemakefile.writerules(outfp, files[:], '_d', '-D_DEBUG -DLAUNCH_DEBUG', targets[1])
makemakefile.writerules(outfp, files[:], '', '', '', targets[0])
makemakefile.writerules(outfp, files[:], '_d', flags_d, ldflags_d, targets[1])
makemakefile.writerules(outfp, files[:], 'w', flagsw, ldflagsw, targets[2])
makemakefile.writerules(outfp, files[:], 'w_d', flagsw_d, ldflagsw_d, targets[3])
finally:
outfp.close()
+9 -1
View File
@@ -29,6 +29,11 @@
#include "getpath.h"
#include <sys/wait.h>
// To call TransformProcessType in the child process
#if defined(__APPLE__) && defined(WINDOWED)
#include "Processes.h"
#endif
#ifdef FREEZE_EXCEPTIONS
extern unsigned char M_exceptions[];
static struct _frozen _PyImport_FrozenModules[] = {
@@ -113,6 +118,10 @@ int main(int argc, char* argv[])
if (workpath) {
/* we're the "child" process */
#if defined(__APPLE__) && defined(WINDOWED)
ProcessSerialNumber psn = { 0, kCurrentProcess };
OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication);
#endif
VS("Already have a workpath - running!\n");
rc = doIt(argc, argv);
}
@@ -147,4 +156,3 @@ int main(int argc, char* argv[])
}
return rc;
}
+3 -3
View File
@@ -29,7 +29,7 @@ def writevars(outfp, makevars, target):
outfp.write("\nall: %s\n\n" % target)
outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target)
def writerules(outfp, files, suffix, dflag, target):
def writerules(outfp, files, suffix, dflag, lflag, target):
deps = []
for i in range(len(files)):
file = files[i]
@@ -42,5 +42,5 @@ def writerules(outfp, files, suffix, dflag, target):
deps.append(dest)
outfp.write("\n%s: %s\n" % (target, string.join(deps)))
outfp.write("\t$(CC) %s -o %s $(LDLAST)\n" %
(string.join(files), target))
outfp.write("\t$(CC) %s -o %s %s $(LDLAST)\n\n\n" %
(string.join(files), target, lflag))