From d5dfbe38438b0cb093cb029a886d219058aef81c Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Apr 2011 08:50:32 +0000 Subject: [PATCH] add p3dembedw on windows, hide console window in pdeployed executables by default --- direct/src/p3d/DeploymentTools.py | 11 +++++-- direct/src/p3d/coreapi.pdef | 3 ++ direct/src/p3d/pdeploy.py | 3 +- direct/src/plugin_standalone/Sources.pp | 29 +++++++++++++++++++ direct/src/plugin_standalone/p3dEmbedMain.cxx | 10 ++++++- makepanda/makepanda.py | 22 ++++++++++++++ 6 files changed, 74 insertions(+), 4 deletions(-) diff --git a/direct/src/p3d/DeploymentTools.py b/direct/src/p3d/DeploymentTools.py index 5b6e3598b5..1de0e009ac 100644 --- a/direct/src/p3d/DeploymentTools.py +++ b/direct/src/p3d/DeploymentTools.py @@ -125,7 +125,14 @@ class Standalone: # Figure out where p3dembed might be now. if package.platform.startswith("win"): - p3dembed = Filename(self.host.hostDir, "p3dembed/%s/p3dembed.exe" % package.platform) + # Use p3dembedw unless console_environment was set. + if extraTokens.get("console_environment", self.tokens.get("console_environment", 0)) != 0: + p3dembed = Filename(self.host.hostDir, "p3dembed/%s/p3dembed.exe" % package.platform) + else: + p3dembed = Filename(self.host.hostDir, "p3dembed/%s/p3dembedw.exe" % package.platform) + # Fallback for older p3dembed versions + if not vfs.exists(p3dembed): + Filename(self.host.hostDir, "p3dembed/%s/p3dembed.exe" % package.platform) else: p3dembed = Filename(self.host.hostDir, "p3dembed/%s/p3dembed" % package.platform) @@ -195,7 +202,7 @@ class Standalone: filenames = [] vfs = VirtualFileSystem.getGlobalPtr() for e in package.extracts: - if e.basename not in ["p3dembed", "p3dembed.exe", "p3dembed.exe.manifest"]: + if e.basename not in ["p3dembed", "p3dembed.exe", "p3dembed.exe.manifest", "p3dembedw.exe", "p3dembedw.exe.manifest"]: filename = Filename(package.getPackageDir(), e.filename) filename.makeAbsolute() if vfs.exists(filename): diff --git a/direct/src/p3d/coreapi.pdef b/direct/src/p3d/coreapi.pdef index 8012ac3b35..c3a2086401 100644 --- a/direct/src/p3d/coreapi.pdef +++ b/direct/src/p3d/coreapi.pdef @@ -119,3 +119,6 @@ class p3dembed(package): config(platform_specific = True) file('p3dembed.exe', required = True) + + if platform.startswith('win'): + file('p3dembedw.exe', required = True) diff --git a/direct/src/p3d/pdeploy.py b/direct/src/p3d/pdeploy.py index 50d4bf4565..8800d7f16f 100644 --- a/direct/src/p3d/pdeploy.py +++ b/direct/src/p3d/pdeploy.py @@ -64,7 +64,8 @@ Options: Defines a web token or parameter to pass to the application. Use this to configure how the application will be run. You can pass as many -t options as you need. Some examples of - tokens are width, height, log_basename, auto_start and hidden. + useful token names are width, height, log_basename, auto_start, + hidden and console_environment. -P platform If this option is provided, it should specify a comma- diff --git a/direct/src/plugin_standalone/Sources.pp b/direct/src/plugin_standalone/Sources.pp index 381e2da6f4..c36a0a8465 100644 --- a/direct/src/plugin_standalone/Sources.pp +++ b/direct/src/plugin_standalone/Sources.pp @@ -111,4 +111,33 @@ #end bin_target +#begin bin_target + // On Windows, we also need to build p3dembedw.exe, the non-console + // version of p3dembed.exe. + + #define BUILD_TARGET $[and $[HAVE_JPEG],$[HAVE_PNG],$[WINDOWS_PLATFORM]] + #define USE_PACKAGES openssl zlib + #define TARGET p3dembedw + #define LOCAL_LIBS plugin_common p3d_plugin_static + + // We need to define this, even though we are not creating a DLL, + // because we need the symbols to be "exported" so we can find them in + // our own address space. + #define EXTRA_CDEFS BUILDING_P3D_PLUGIN P3DEMBEDW + + #define OTHER_LIBS \ + prc:c dtoolutil:c dtoolbase:c dtool:m \ + interrogatedb:c dconfig:c dtoolconfig:m \ + pandabase:c downloader:c express:c pandaexpress:m \ + pystub p3tinyxml + + #define SOURCES \ + panda3dBase.cxx panda3dBase.h panda3dBase.I \ + p3dEmbed.cxx p3dEmbedMain.cxx + + #define WIN_RESOURCE_FILE panda3d.rc + #define WIN_SYS_LIBS user32.lib gdi32.lib shell32.lib comctl32.lib msimg32.lib ole32.lib + +#end bin_target + #include $[THISDIRPREFIX]panda3d.rc.pp diff --git a/direct/src/plugin_standalone/p3dEmbedMain.cxx b/direct/src/plugin_standalone/p3dEmbedMain.cxx index 00360d7f88..27db63cd78 100644 --- a/direct/src/plugin_standalone/p3dEmbedMain.cxx +++ b/direct/src/plugin_standalone/p3dEmbedMain.cxx @@ -14,8 +14,12 @@ #include "p3dEmbed.h" +#ifdef P3DEMBEDW +#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") +#endif + #ifdef _WIN32 -volatile unsigned long p3d_offset = 0xFF3D3D00; +volatile unsigned __int32 p3d_offset = 0xFF3D3D00; #else #include volatile uint32_t p3d_offset = 0xFF3D3D00; @@ -23,7 +27,11 @@ volatile uint32_t p3d_offset = 0xFF3D3D00; int main(int argc, char *argv[]) { +#ifdef P3DEMBEDW + P3DEmbed program(false); +#else P3DEmbed program(true); +#endif return program.run_embedded(p3d_offset, argc, argv); } diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index b94404bdd0..6fa4a95f5d 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3994,6 +3994,28 @@ if (RTDIST): TargetAdd('p3dembed.exe', input='libp3d_plugin_static.ilb') TargetAdd('p3dembed.exe', opts=['NOICON', 'NOSTRIP', 'WINGDI', 'WINSOCK2', 'ZLIB', 'WINUSER', 'OPENSSL', 'JPEG', 'WINOLE', 'CARBON', 'MSIMG', 'WINCOMCTL', 'ADVAPI', 'WINSHELL', 'X11', 'PNG']) + if (sys.platform.startswith("win")): + OPTS.append("P3DEMBEDW") + DefSymbol("P3DEMBEDW", "P3DEMBEDW", "") + TargetAdd('plugin_standalone_p3dEmbedWinMain.obj', opts=OPTS, input='p3dEmbedMain.cxx') + TargetAdd('p3dembedw.exe', input='plugin_standalone_panda3dBase.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_p3dEmbedWinMain.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_p3dEmbed.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_pystub.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_dtoolbase_composite1.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_dtoolbase_composite2.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_lookup3.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_indent.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_dtoolutil_composite.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_prc_composite.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_dconfig_composite.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_express_composite.obj') + TargetAdd('p3dembedw.exe', input='plugin_standalone_downloader_composite.obj') + TargetAdd('p3dembedw.exe', input='plugin_common.obj') + TargetAdd('p3dembedw.exe', input='libp3tinyxml.ilb') + TargetAdd('p3dembedw.exe', input='libp3d_plugin_static.ilb') + TargetAdd('p3dembedw.exe', opts=['NOICON', 'NOSTRIP', 'WINGDI', 'WINSOCK2', 'ZLIB', 'WINUSER', 'OPENSSL', 'JPEG', 'WINOLE', 'MSIMG', 'WINCOMCTL', 'ADVAPI', 'WINSHELL', 'PNG']) + # # DIRECTORY: pandatool/src/pandatoolbase/ #