Browse Source

add p3dembedw on windows, hide console window in pdeployed executables by default

rdb 14 years ago
parent
commit
d5dfbe3843

+ 9 - 2
direct/src/p3d/DeploymentTools.py

@@ -125,7 +125,14 @@ class Standalone:
 
 
             # Figure out where p3dembed might be now.
             # Figure out where p3dembed might be now.
             if package.platform.startswith("win"):
             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:
             else:
                 p3dembed = Filename(self.host.hostDir, "p3dembed/%s/p3dembed" % package.platform)
                 p3dembed = Filename(self.host.hostDir, "p3dembed/%s/p3dembed" % package.platform)
 
 
@@ -195,7 +202,7 @@ class Standalone:
         filenames = []
         filenames = []
         vfs = VirtualFileSystem.getGlobalPtr()
         vfs = VirtualFileSystem.getGlobalPtr()
         for e in package.extracts:
         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 = Filename(package.getPackageDir(), e.filename)
                 filename.makeAbsolute()
                 filename.makeAbsolute()
                 if vfs.exists(filename):
                 if vfs.exists(filename):

+ 3 - 0
direct/src/p3d/coreapi.pdef

@@ -119,3 +119,6 @@ class p3dembed(package):
 
 
     config(platform_specific = True)
     config(platform_specific = True)
     file('p3dembed.exe', required = True)
     file('p3dembed.exe', required = True)
+
+    if platform.startswith('win'):
+        file('p3dembedw.exe', required = True)

+ 2 - 1
direct/src/p3d/pdeploy.py

@@ -64,7 +64,8 @@ Options:
      Defines a web token or parameter to pass to the application.
      Defines a web token or parameter to pass to the application.
      Use this to configure how the application will be run.
      Use this to configure how the application will be run.
      You can pass as many -t options as you need. Some examples of
      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
   -P platform
      If this option is provided, it should specify a comma-
      If this option is provided, it should specify a comma-

+ 29 - 0
direct/src/plugin_standalone/Sources.pp

@@ -111,4 +111,33 @@
 
 
 #end bin_target
 #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
 #include $[THISDIRPREFIX]panda3d.rc.pp

+ 9 - 1
direct/src/plugin_standalone/p3dEmbedMain.cxx

@@ -14,8 +14,12 @@
 
 
 #include "p3dEmbed.h"
 #include "p3dEmbed.h"
 
 
+#ifdef P3DEMBEDW
+#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
+#endif
+
 #ifdef _WIN32
 #ifdef _WIN32
-volatile unsigned long p3d_offset = 0xFF3D3D00;
+volatile unsigned __int32 p3d_offset = 0xFF3D3D00;
 #else
 #else
 #include <stdint.h>
 #include <stdint.h>
 volatile uint32_t p3d_offset = 0xFF3D3D00;
 volatile uint32_t p3d_offset = 0xFF3D3D00;
@@ -23,7 +27,11 @@ volatile uint32_t p3d_offset = 0xFF3D3D00;
 
 
 int
 int
 main(int argc, char *argv[]) {
 main(int argc, char *argv[]) {
+#ifdef P3DEMBEDW
+  P3DEmbed program(false);
+#else
   P3DEmbed program(true);
   P3DEmbed program(true);
+#endif
   return program.run_embedded(p3d_offset, argc, argv);
   return program.run_embedded(p3d_offset, argc, argv);
 }
 }
 
 

+ 22 - 0
makepanda/makepanda.py

@@ -3994,6 +3994,28 @@ if (RTDIST):
   TargetAdd('p3dembed.exe', input='libp3d_plugin_static.ilb')
   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'])
   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/
 # DIRECTORY: pandatool/src/pandatoolbase/
 #
 #