Browse Source

Fixes for FreeBSD

rdb 15 years ago
parent
commit
38f5a3210d
1 changed files with 34 additions and 34 deletions
  1. 34 34
      direct/src/showutil/FreezeTool.py

+ 34 - 34
direct/src/showutil/FreezeTool.py

@@ -50,7 +50,7 @@ class CompilationEnvironment:
 
 
     def __init__(self, platform):
     def __init__(self, platform):
         self.platform = platform
         self.platform = platform
-        
+
         # The command to compile a c to an object file.  Replace %(basename)s
         # The command to compile a c to an object file.  Replace %(basename)s
         # with the basename of the source file, and an implicit .c extension.
         # with the basename of the source file, and an implicit .c extension.
         self.compileObj = 'error'
         self.compileObj = 'error'
@@ -144,11 +144,11 @@ class CompilationEnvironment:
 
 
         else:
         else:
             # Unix
             # Unix
-            self.compileObj = "gcc -fPIC -c -o %(basename)s.o -O2 %(filename)s -I %(pythonIPath)s"
-            self.linkExe = "gcc -o %(basename)s %(basename)s.o -lpython%(pythonVersion)s"
-            self.linkDll = "gcc -shared -o %(basename)s.so %(basename)s.o -lpython%(pythonVersion)s"
+            self.compileObj = "gcc -fPIC -c -o %(basename)s.o -O2 %(filename)s -I%(pythonIPath)s"
+            self.linkExe = "gcc -o %(basename)s %(basename)s.o -L/usr/local/lib -lpython%(pythonVersion)s"
+            self.linkDll = "gcc -shared -o %(basename)s.so %(basename)s.o -L/usr/local/lib -lpython%(pythonVersion)s"
 
 
-            if (platform.uname()[1]=="pcbsd"):
+            if (os.path.isdir("/usr/PCBSD/local/lib")):
                 self.linkExe += " -L/usr/PCBSD/local/lib"
                 self.linkExe += " -L/usr/PCBSD/local/lib"
                 self.linkDll += " -L/usr/PCBSD/local/lib"
                 self.linkDll += " -L/usr/PCBSD/local/lib"
 
 
@@ -314,7 +314,7 @@ void PyWinFreeze_ExeInit(void)
 
 
 /*
 /*
   Called by a frozen .EXE only, so that built-in extension
   Called by a frozen .EXE only, so that built-in extension
-  modules are cleaned up 
+  modules are cleaned up
 */
 */
 void PyWinFreeze_ExeTerm(void)
 void PyWinFreeze_ExeTerm(void)
 {
 {
@@ -332,7 +332,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
 {
     BOOL ret = TRUE;
     BOOL ret = TRUE;
     switch (dwReason) {
     switch (dwReason) {
-        case DLL_PROCESS_ATTACH: 
+        case DLL_PROCESS_ATTACH:
         {
         {
             char **modName;
             char **modName;
             for (modName = possibleModules;*modName;*modName++) {
             for (modName = possibleModules;*modName;*modName++) {
@@ -342,7 +342,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
             }
             }
             break;
             break;
         }
         }
-        case DLL_PROCESS_DETACH: 
+        case DLL_PROCESS_DETACH:
         {
         {
             // Must go backwards
             // Must go backwards
             char **modName;
             char **modName;
@@ -398,7 +398,7 @@ static PyMethodDef nullMethods[] = {
  * array of frozen modules, provided in a C-style array, at runtime.
  * array of frozen modules, provided in a C-style array, at runtime.
  * Returns the total number of frozen modules.
  * Returns the total number of frozen modules.
  */
  */
-static int 
+static int
 extend_frozen_modules(const struct _frozen *new_modules, int new_count) {
 extend_frozen_modules(const struct _frozen *new_modules, int new_count) {
   int orig_count;
   int orig_count;
   struct _frozen *realloc_FrozenModules;
   struct _frozen *realloc_FrozenModules;
@@ -644,7 +644,7 @@ class Freezer:
             modulefinder.AddPackagePath(moduleName, path)
             modulefinder.AddPackagePath(moduleName, path)
 
 
     def getModulePath(self, moduleName):
     def getModulePath(self, moduleName):
-        """ Looks for the indicated directory module and returns the 
+        """ Looks for the indicated directory module and returns the
         __path__ member: the list of directories in which its python
         __path__ member: the list of directories in which its python
         files can be found.  If the module is a .py file and not a
         files can be found.  If the module is a .py file and not a
         directory, returns None. """
         directory, returns None. """
@@ -661,7 +661,7 @@ class Freezer:
             for symbol in moduleName.split('.')[1:]:
             for symbol in moduleName.split('.')[1:]:
                 module = getattr(module, symbol)
                 module = getattr(module, symbol)
             return module.__path__
             return module.__path__
-        
+
         # If it didn't work--maybe the module is unimportable because
         # If it didn't work--maybe the module is unimportable because
         # it makes certain assumptions about the builtins, or
         # it makes certain assumptions about the builtins, or
         # whatever--then just look for file on disk.  That's usually
         # whatever--then just look for file on disk.  That's usually
@@ -673,7 +673,7 @@ class Freezer:
             path = self.getModulePath(parentName)
             path = self.getModulePath(parentName)
             if path == None:
             if path == None:
                 return None
                 return None
-            
+
         file, pathname, description = imp.find_module(baseName, path)
         file, pathname, description = imp.find_module(baseName, path)
 
 
         if not os.path.isdir(pathname):
         if not os.path.isdir(pathname):
@@ -681,7 +681,7 @@ class Freezer:
         return [pathname]
         return [pathname]
 
 
     def getModuleStar(self, moduleName):
     def getModuleStar(self, moduleName):
-        """ Looks for the indicated directory module and returns the 
+        """ Looks for the indicated directory module and returns the
         __all__ member: the list of symbols within the module. """
         __all__ member: the list of symbols within the module. """
 
 
         # First, try to import the module directly.  That's the most
         # First, try to import the module directly.  That's the most
@@ -697,7 +697,7 @@ class Freezer:
                 module = getattr(module, symbol)
                 module = getattr(module, symbol)
             if hasattr(module, '__all__'):
             if hasattr(module, '__all__'):
                 return module.__all__
                 return module.__all__
-        
+
         # If it didn't work, just open the directory and scan for *.py
         # If it didn't work, just open the directory and scan for *.py
         # files.
         # files.
         path = None
         path = None
@@ -723,7 +723,7 @@ class Freezer:
                 modules.append(basename[:-3])
                 modules.append(basename[:-3])
 
 
         return modules
         return modules
-            
+
     def addModule(self, moduleName, implicit = False, newName = None,
     def addModule(self, moduleName, implicit = False, newName = None,
                   filename = None, guess = False, fromSource = None):
                   filename = None, guess = False, fromSource = None):
         """ Adds a module to the list of modules to be exported by
         """ Adds a module to the list of modules to be exported by
@@ -802,7 +802,7 @@ class Freezer:
         writeMultifile() to dump the resulting output.  After a call
         writeMultifile() to dump the resulting output.  After a call
         to done(), you may not add any more modules until you call
         to done(), you may not add any more modules until you call
         reset(). """
         reset(). """
-        
+
         assert self.mf == None
         assert self.mf == None
 
 
         # If we are building an exe, we also need to implicitly
         # If we are building an exe, we also need to implicitly
@@ -815,7 +815,7 @@ class Freezer:
         # Excluding a parent module also excludes all its
         # Excluding a parent module also excludes all its
         # (non-explicit) children, unless the parent has allowChildren
         # (non-explicit) children, unless the parent has allowChildren
         # set.
         # set.
-        
+
         # Walk through the list in sorted order, so we reach parents
         # Walk through the list in sorted order, so we reach parents
         # before children.
         # before children.
         names = self.modules.items()
         names = self.modules.items()
@@ -877,7 +877,7 @@ class Freezer:
         for origName in self.mf.modules.keys():
         for origName in self.mf.modules.keys():
             if origName not in origToNewName:
             if origName not in origToNewName:
                 self.modules[origName] = self.ModuleDef(origName, implicit = True)
                 self.modules[origName] = self.ModuleDef(origName, implicit = True)
-                            
+
         missing = []
         missing = []
         for origName in self.mf.any_missing_maybe()[0]:
         for origName in self.mf.any_missing_maybe()[0]:
             if origName in startupModules:
             if origName in startupModules:
@@ -923,7 +923,7 @@ class Freezer:
 
 
     def __loadModule(self, mdef):
     def __loadModule(self, mdef):
         """ Adds the indicated module to the modulefinder. """
         """ Adds the indicated module to the modulefinder. """
-        
+
         if mdef.filename:
         if mdef.filename:
             # If it has a filename, then we found it as a file on
             # If it has a filename, then we found it as a file on
             # disk.  In this case, the moduleName may not be accurate
             # disk.  In this case, the moduleName may not be accurate
@@ -961,7 +961,7 @@ class Freezer:
         FreezeTool object for a new pass.  More modules may be added
         FreezeTool object for a new pass.  More modules may be added
         and dumped to a new target.  Previously-added modules are
         and dumped to a new target.  Previously-added modules are
         remembered and will not be dumped again. """
         remembered and will not be dumped again. """
-        
+
         self.mf = None
         self.mf = None
         self.previousModules = dict(self.modules)
         self.previousModules = dict(self.modules)
 
 
@@ -993,7 +993,7 @@ class Freezer:
         """ Return a list of all of the modules we will be explicitly
         """ Return a list of all of the modules we will be explicitly
         or implicitly including.  The return value is actually a list
         or implicitly including.  The return value is actually a list
         of tuples: (moduleName, moduleDef)."""
         of tuples: (moduleName, moduleDef)."""
-        
+
         moduleDefs = []
         moduleDefs = []
 
 
         for newName, mdef in self.modules.items():
         for newName, mdef in self.modules.items():
@@ -1048,7 +1048,7 @@ class Freezer:
         """ Adds all of the names on dirnames as a module directory. """
         """ Adds all of the names on dirnames as a module directory. """
         if not dirnames:
         if not dirnames:
             return
             return
-        
+
         str = '.'.join(dirnames)
         str = '.'.join(dirnames)
         if str not in moduleDirs:
         if str not in moduleDirs:
             # Add an implicit __init__.py file.
             # Add an implicit __init__.py file.
@@ -1102,7 +1102,7 @@ class Freezer:
         elif getattr(module, '__file__', None):
         elif getattr(module, '__file__', None):
             sourceFilename = Filename.fromOsSpecific(module.__file__)
             sourceFilename = Filename.fromOsSpecific(module.__file__)
             sourceFilename.setExtension("py")
             sourceFilename.setExtension("py")
-            
+
         if self.storePythonSource:
         if self.storePythonSource:
             if sourceFilename and sourceFilename.exists():
             if sourceFilename and sourceFilename.exists():
                 filename += '.py'
                 filename += '.py'
@@ -1152,7 +1152,7 @@ class Freezer:
             if not mdef.exclude:
             if not mdef.exclude:
                 self.__addPythonFile(multifile, moduleDirs, moduleName, mdef,
                 self.__addPythonFile(multifile, moduleDirs, moduleName, mdef,
                                      compressionLevel)
                                      compressionLevel)
-    
+
     def writeMultifile(self, mfname):
     def writeMultifile(self, mfname):
         """ After a call to done(), this stores all of the accumulated
         """ After a call to done(), this stores all of the accumulated
         python code into a Multifile with the indicated filename,
         python code into a Multifile with the indicated filename,
@@ -1181,7 +1181,7 @@ class Freezer:
         The return value is the newly-generated filename, including
         The return value is the newly-generated filename, including
         the filename extension.  Additional extension modules are
         the filename extension.  Additional extension modules are
         listed in self.extras. """
         listed in self.extras. """
-        
+
         if compileToExe:
         if compileToExe:
             # We must have a __main__ module to make an exe file.
             # We must have a __main__ module to make an exe file.
             if not self.__writingModule('__main__'):
             if not self.__writingModule('__main__'):
@@ -1193,7 +1193,7 @@ class Freezer:
         # Now generate the actual export table.
         # Now generate the actual export table.
         moduleDefs = []
         moduleDefs = []
         moduleList = []
         moduleList = []
-        
+
         for moduleName, mdef in self.getModuleDefs():
         for moduleName, mdef in self.getModuleDefs():
             origName = mdef.moduleName
             origName = mdef.moduleName
             if mdef.forbid:
             if mdef.forbid:
@@ -1247,7 +1247,7 @@ class Freezer:
 
 
         if not self.cenv:
         if not self.cenv:
             self.cenv = CompilationEnvironment(platform = self.platform)
             self.cenv = CompilationEnvironment(platform = self.platform)
-            
+
         if compileToExe:
         if compileToExe:
             code = self.frozenMainCode
             code = self.frozenMainCode
             if self.platform == 'win32':
             if self.platform == 'win32':
@@ -1265,13 +1265,13 @@ class Freezer:
                 target = basename
                 target = basename
 
 
             compileFunc = self.cenv.compileExe
             compileFunc = self.cenv.compileExe
-            
+
         else:
         else:
             if self.platform == 'win32':
             if self.platform == 'win32':
                 target = basename + self.cenv.dllext + '.pyd'
                 target = basename + self.cenv.dllext + '.pyd'
             else:
             else:
                 target = basename + '.so'
                 target = basename + '.so'
-            
+
             initCode = dllInitCode % {
             initCode = dllInitCode % {
                 'moduleName' : os.path.basename(basename),
                 'moduleName' : os.path.basename(basename),
                 'newcount' : len(moduleList),
                 'newcount' : len(moduleList),
@@ -1297,7 +1297,7 @@ class Freezer:
                 os.unlink(filename)
                 os.unlink(filename)
             if (os.path.exists(basename + self.objectExtension)):
             if (os.path.exists(basename + self.objectExtension)):
                 os.unlink(basename + self.objectExtension)
                 os.unlink(basename + self.objectExtension)
-        
+
         return target
         return target
 
 
     def makeModuleDef(self, mangledName, code):
     def makeModuleDef(self, mangledName, code):
@@ -1325,7 +1325,7 @@ class Freezer:
         """ Returns true if we are outputting the named module in this
         """ Returns true if we are outputting the named module in this
         pass, false if we have already output in a previous pass, or
         pass, false if we have already output in a previous pass, or
         if it is not yet on the output table. """
         if it is not yet on the output table. """
-        
+
         mdef = self.modules.get(moduleName, (None, None))
         mdef = self.modules.get(moduleName, (None, None))
         if mdef.exclude:
         if mdef.exclude:
             return False
             return False
@@ -1353,7 +1353,7 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
                 partname = libname
                 partname = libname
                 fqname = libname
                 fqname = libname
                 parent = None
                 parent = None
-                
+
         return modulefinder.ModuleFinder.import_module(self, partname, fqname, parent)
         return modulefinder.ModuleFinder.import_module(self, partname, fqname, parent)
 
 
     def find_module(self, name, path, parent=None):
     def find_module(self, name, path, parent=None):
@@ -1382,7 +1382,7 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
 
 
         message = "DLL loader cannot find %s." % (name)
         message = "DLL loader cannot find %s." % (name)
         raise ImportError, message
         raise ImportError, message
-        
+
     def load_module(self, fqname, fp, pathname, (suffix, mode, type)):
     def load_module(self, fqname, fp, pathname, (suffix, mode, type)):
         if type == imp.PY_FROZEN:
         if type == imp.PY_FROZEN:
             # It's a frozen module.
             # It's a frozen module.
@@ -1398,5 +1398,5 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
             self.scan_code(co, m)
             self.scan_code(co, m)
             self.msgout(2, "load_module ->", m)
             self.msgout(2, "load_module ->", m)
             return m
             return m
-        
+
         return modulefinder.ModuleFinder.load_module(self, fqname, fp, pathname, (suffix, mode, type))
         return modulefinder.ModuleFinder.load_module(self, fqname, fp, pathname, (suffix, mode, type))