Browse Source

plugin - p3dpythonw.exe name configurable independently from p3dpython.exe name

Ken Patel 15 years ago
parent
commit
5a84cbf730
2 changed files with 30 additions and 12 deletions
  1. 9 2
      direct/src/p3d/Packager.py
  2. 21 10
      direct/src/plugin/p3dSession.cxx

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

@@ -3095,7 +3095,7 @@ class Packager:
 
         self.currentPackage.signParams.append((certificate, chain, pkey, password))
 
-    def do_setupPanda3D(self, p3dpythonName=None):
+    def do_setupPanda3D(self, p3dpythonName=None, p3dpythonwName=None):
         """ A special convenience command that adds the minimum
         startup modules for a panda3d package, intended for developers
         producing their own custom panda3d for download.  Should be
@@ -3165,8 +3165,15 @@ class Packager:
             else:
                 self.do_config(p3dpython_name=p3dpythonName)
             self.do_file('p3dpython.exe', newName=p3dpythonName+'.exe')
+
+            # The "Windows" executable appends a 'w' to whatever name is used
+            # above, unless an override name is explicitly specified.
             if self.platform.startswith('win'):
-                self.do_file('p3dpythonw.exe', newName=p3dpythonName+'w.exe')
+                if p3dpythonwName is None:
+                    p3dpythonwName = p3dpythonName+'w'
+                else:
+                    self.do_config(p3dpythonw_name=p3dpythonwName)
+                self.do_file('p3dpythonw.exe', newName=p3dpythonwName+'.exe')
                 
         self.do_file('libp3dpython.dll')
 

+ 21 - 10
direct/src/plugin/p3dSession.cxx

@@ -824,21 +824,32 @@ start_p3dpython(P3DInstance *inst) {
   // and run the dynamic library.  If that fails for some reason, we
   // can fall back to loading and running the library directly.
   _p3dpython_exe = P3D_PLUGIN_P3DPYTHON;
+  string p3dpythonw_exe = _p3dpython_exe + "w";
   if (_p3dpython_exe.empty()) {
-    string p3dpython_name = "p3dpython";
-
-    // Allow package to override the name of the p3dpython executable.
+    // Allow package to override the name of the p3dpython executables.
+    const char *p3dpython_name_xconfig = NULL; 
+    const char *p3dpythonw_name_xconfig = NULL;
     const TiXmlElement *panda3d_xconfig = inst->_panda3d->get_xconfig();
     if (panda3d_xconfig != NULL) {
-      const char *p3dpython_name_x = panda3d_xconfig->Attribute("p3dpython_name");
-      if (p3dpython_name_x != NULL) {
-        nout << "p3dpython_name from panda3d xconfig: " << p3dpython_name_x << "\n";
-        p3dpython_name = p3dpython_name_x;
-      }
+        p3dpython_name_xconfig = panda3d_xconfig->Attribute("p3dpython_name");
+        p3dpythonw_name_xconfig = panda3d_xconfig->Attribute("p3dpythonw_name");
+    }
+
+    string p3dpython_name = "p3dpython";
+    if (p3dpython_name_xconfig != NULL) {
+      nout << "p3dpython_name from panda3d xconfig: " << p3dpython_name_xconfig << "\n";
+      p3dpython_name = p3dpython_name_xconfig;
+    }
+
+    string p3dpythonw_name = p3dpython_name + "w";
+    if (p3dpythonw_name_xconfig != NULL) {
+      nout << "p3dpythonw_name from panda3d xconfig: " << p3dpythonw_name_xconfig << "\n";
+      p3dpythonw_name = p3dpythonw_name_xconfig;
     }
 
     // Build full executable path.
     _p3dpython_exe = _python_root_dir + "/" + p3dpython_name;
+    p3dpythonw_exe = _python_root_dir + "/" + p3dpythonw_name;
 #ifdef __APPLE__
     // On OSX, run from the packaged bundle, if it exists.
     string bundle_exe = _python_root_dir + "/P3DPython.app/Contents/MacOS/p3dpython";
@@ -847,13 +858,13 @@ start_p3dpython(P3DInstance *inst) {
     }
 #endif
   }
-  replace_slashes(_p3dpython_exe);
 #ifdef _WIN32
   if (!inst_mgr->get_console_environment()) {
-    _p3dpython_exe += "w";
+    _p3dpython_exe = p3dpythonw_exe;
   }
   _p3dpython_exe += ".exe";
 #endif
+  replace_slashes(_p3dpython_exe);
   nout << "_p3dpython_exe: " << _p3dpython_exe << "\n";
 
   // Populate the new process' environment.