Commits

Anonymous committed b7f5275

Fixed msys build and Freetype2 include hunting.
Added build config entry for freetype module.

  • Participants
  • Parent commits 2c7afa3
  • Branches pgreloaded

Comments (0)

Files changed (8)

 * sdl.mouse.cursors, NOT pygame2.sdl.cursors or whatever
 * sdlext.transform.threshod_* -> clip_rect, surfaces with different sizes
 * documentation
-* get rid of os.system() output under msys (2>/dev/null does not seem to work)
 * correct argument checks in pyg_scrap* functions
 * check for clipboard resource destruction within pygame.sdlext.scrap.
 * uniform method and argument layout (see sdlext.draw and sdlgfx.primitives
 # libjpeg support
 # This is used by Surface.save() to enable JPEG saving.
 build['JPEG'] = istrue (os.getenv ("WITH_JPEG", True))
+
+# freetype (module) support
+build['FREETYPE'] = istrue (os.getenv ("WITH_FREETYPE", True))

File config/config_generic.py

     _searchdirs = []
     _libprefix = ""
 
-    def __init__(self, header_file, library_link_id,
+    def __init__(self, header_files, library_link_id,
             config_program = None, pkgconfig_name = None,
             extra_include_dirs = []):
 
-        self.header_file = header_file
+        self.header_files = header_files
 
         self.library_name = self._libprefix + library_link_id
         self.library_id = library_link_id
             Recursively search all include dirs for the specified
             header file.
         """
-
         def _fi_recurse(top):
             for (path, dirnames, filenames) in os.walk(top):
                 if name in filenames:
             the required headers and libraries in some default
             system folders.
         """
-        directory = self._find_incdir(self.header_file)
+        dirs = []
+        for h in self.header_files:
+            directory = self._find_incdir (h)
+            if directory is None:
+                return False
+            dirs.append (directory)
+        
         libdir = self._find_libdir (self.library_name)
-
-        if directory is None or libdir is None:
+        if libdir is None:
             return False
 
-        self.incdirs.append(directory)
+        self.incdirs.extend(dirs)
         self.libdirs.append(libdir)
         self.cflags.append("-DHAVE_" + self.library_id.upper())
         return True

File config/config_modules.py

 
     DEPENDENCIES = {
         'sdl' : dep(
-            'SDL.h', 'SDL',
+            ['SDL.h'], 'SDL',
             config_program='sdl-config',
             pkgconfig_name='sdl',
             extra_include_dirs = [pygame_sdl_path]),
 
         'sdl_mixer' : dep(
-            'SDL_mixer.h', 'SDL_mixer',
+            ['SDL_mixer.h'], 'SDL_mixer',
             config_program='sdl-config',
             pkgconfig_name='sdl',
             extra_include_dirs = [pygame_sdl_path]),
 
         'sdl_ttf' : dep(
-            'SDL_ttf.h', 'SDL_ttf',
+            ['SDL_ttf.h'], 'SDL_ttf',
             config_program='sdl-config',
             pkgconfig_name='sdl',
             extra_include_dirs = [pygame_sdl_path]),
 
         'sdl_gfx' : dep(
-            'SDL_framerate.h', 'SDL_gfx',
+            ['SDL_framerate.h'], 'SDL_gfx',
             config_program='sdl-config',
             pkgconfig_name='sdl',
             extra_include_dirs = [pygame_sdl_path]),
 
         'sdl_image' : dep(
-            'SDL_image.h', 'SDL_image',
+            ['SDL_image.h'], 'SDL_image',
             config_program='sdl-config',
             pkgconfig_name='sdl',
             extra_include_dirs = [pygame_sdl_path]),
 
         'png' : dep(
-            'png.h', 'png',
+            ['png.h'], 'png',
             pkgconfig_name='libpng'),
 
         'jpeg' : dep(
-            'jpeglib.h', 'jpeg',
+            ['jpeglib.h'], 'jpeg',
             pkgconfig_name='libjpeg'),
 
         'freetype' : dep(
-            'freetype.h', 'freetype',
+            ['freetype.h', 'ft2build.h'], 'freetype',
             pkgconfig_name='freetype2',
             config_program='freetype-config'),
     }

File config/config_msys.py

 import os, glob
 from config import msys, helpers, dll
-from config import config_unix, config_generic, config_win
+from config import config_unix, config_generic, config_win, libconfig
 
 try:
     msys_obj = msys.Msys (require_mingw=False)
     return config_unix.sdl_get_version()
 
 def get_sys_libs (module):
-    return config_win.get_sys_libs()
+    return config_win.get_sys_libs(module)
 
 def _hunt_libs (name, dirs):
     # Used by get_install_libs(). It resolves the dependency libraries
 
 
 class Dependency (config_unix.Dependency):
-    _searchdirs = [ "/usr", "/usr/local", "/mingw" ]
+    _searchdirs = [ "/usr", "/usr/local"]#, "/mingw" ]
     _incdirs = [ "include", "X11/include" ]
     _libdirs = [ "lib", "X11/lib" ]
-    _libprefix = ""
+    _libprefix = "lib"
 
     def _find_incdir (self, name):
         # Gets the include directory for the specified header file.
+        def _fi_recurse(top):
+            top = msys_obj.msys_to_windows (top)
+            for (path, dirnames, filenames) in os.walk (top):
+                if name in filenames:
+                    return path
+                for subfolder in dirnames:
+                    _fi_recurse(os.path.join (path, subfolder))
+
         for d in self._searchdirs:
             for g in self._incdirs:
-                p = msys_obj.msys_to_windows (os.path.join (d, g))
-                f = os.path.join (p, name)
-                if os.path.isfile (f):
-                    return p
-
+                p = _fi_recurse(os.path.join(d, g))
+                if p:
+                    return msys_obj.msys_to_windows (p)
+        
     def _find_libdir (self, name):
         # Gets the library directory for the specified library file.
         for d in self._searchdirs:
             for g in self._libdirs:
                 p = msys_obj.msys_to_windows (os.path.join (d, g))
-                f = os.path.join (p, name)
+                f = msys_obj.msys_to_windows (os.path.join (p, name))
                 if filter (os.path.isfile, glob.glob (f + '*')):
                     return p
 
+    def _configure_libconfig(self):
+        """
+            Configuration callback using a generic CONFIG tool
+        """
+        lc = self.library_config_program
+        found_header = False
+
+        if not lc or not libconfig.has_libconfig(lc):
+            return False
+
+        incdirs = libconfig.get_incdirs(lc)
+        for d in incdirs:
+            for h in self.header_files:
+                p = msys_obj.msys_to_windows (os.path.join(d, h))
+                if os.path.isfile(p):
+                    found_header = True
+                else:
+                    found_header = False
+        if not found_header:
+            return False
+
+        self.incdirs += incdirs
+        self.libdirs += libconfig.get_libdirs(lc)
+        self.libs += libconfig.get_libs(lc)
+        self.cflags += libconfig.get_cflags(lc)
+        self.lflags += libconfig.get_lflags(lc)
+        return True
+
+    _configure_libconfig.priority = 2
+
     def configure(self, cfg):
         """
             Override the generic module configuration to make sure
             that all the found paths are converted from MSYS to full
             Windows path.
         """
-        # self.incdirs and self.libdirs might be set already due to e.g.
-        # DependencySDL.
         self.incdirs = [ msys_obj.msys_to_windows (d) for d in self.incdirs ]
         self.libdirs = [ msys_obj.msys_to_windows (d) for d in self.libdirs ]
         

File config/config_unix.py

     """
     if pkgconfig.has_pkgconfig ():
         return pkgconfig.get_version ("sdl")[0]
-    elif libconfig.has_sdlconfig("sdl"):
-        return libconfig.get_version("sdl")[0]
+    elif libconfig.has_libconfig("sdl-config"):
+        return libconfig.get_version("sdl-config")[0]
 
     # TODO: SDL may be installed manually (i.e. compiled from
     # source). any way to find the version?
         """
             Configuration callback using a generic CONFIG tool
         """
-
         lc = self.library_config_program
         found_header = False
 
             return False
 
         incdirs = libconfig.get_incdirs(lc)
-
         for d in incdirs:
-            if os.path.isfile(os.path.join(d, self.header_file)):
-                found_header = True
-
+            for h in self.header_files:
+                if os.path.isfile(os.path.join(d, h)):
+                    found_header = True
+                else:
+                    found_header = False
         if not found_header:
             return False
 

File config/helpers.py

-import sys
+import sys, traceback
 
 def getversion ():
     return sys.version_info[0:3]
 
 def geterror ():
     return sys.exc_info()[1]
+
+def gettraceback ():
+    return traceback.format_exc ()
         buildsystem, buildcflags = run_checks ()
     except:
         print (helpers.geterror ())
+        print (helpers.gettraceback ())
         sys.exit (1)
 
     os.environ["CFLAGS"] = ""