Преглед изворни кода

plugin - make p3dpython binary name configurable (non-osx)

Ken Patel пре 15 година
родитељ
комит
9f8714254c
2 измењених фајлова са 22 додато и 4 уклоњено
  1. 7 3
      direct/src/p3d/Packager.py
  2. 15 1
      direct/src/plugin/p3dSession.cxx

+ 7 - 3
direct/src/p3d/Packager.py

@@ -3095,7 +3095,7 @@ class Packager:
 
         self.currentPackage.signParams.append((certificate, chain, pkey, password))
 
-    def do_setupPanda3D(self):
+    def do_setupPanda3D(self, p3dpythonName=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
@@ -3160,9 +3160,13 @@ class Packager:
 
         else:
             # Anywhere else, we just ship the executable file p3dpython.exe.
-            self.do_file('p3dpython.exe')
+            if p3dpythonName is None:
+                p3dpythonName = 'p3dpython'
+            else:
+                self.do_config(p3dpython_name=p3dpythonName)
+            self.do_file('p3dpython.exe', newName=p3dpythonName+'.exe')
             if self.platform.startswith('win'):
-                self.do_file('p3dpythonw.exe')
+                self.do_file('p3dpythonw.exe', newName=p3dpythonName+'w.exe')
                 
         self.do_file('libp3dpython.dll')
 

+ 15 - 1
direct/src/plugin/p3dSession.cxx

@@ -825,7 +825,20 @@ start_p3dpython(P3DInstance *inst) {
   // can fall back to loading and running the library directly.
   _p3dpython_exe = P3D_PLUGIN_P3DPYTHON;
   if (_p3dpython_exe.empty()) {
-    _p3dpython_exe = _python_root_dir + "/p3dpython";
+    string p3dpython_name = "p3dpython";
+
+    // Allow package to override the name of the p3dpython executable.
+    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;
+      }
+    }
+
+    // Build full executable path.
+    _p3dpython_exe = _python_root_dir + "/" + p3dpython_name;
 #ifdef __APPLE__
     // On OSX, run from the packaged bundle, if it exists.
     string bundle_exe = _python_root_dir + "/P3DPython.app/Contents/MacOS/p3dpython";
@@ -841,6 +854,7 @@ start_p3dpython(P3DInstance *inst) {
   }
   _p3dpython_exe += ".exe";
 #endif
+  nout << "_p3dpython_exe: " << _p3dpython_exe << "\n";
 
   // Populate the new process' environment.
   _env = string();