Lenard Lindstrom avatar Lenard Lindstrom committed 49fce47

Updated Windows config modules

Comments (0)

Files changed (16)

Default_Setup_Win.in

 SMPEG = -Iprebuilt/include/smpeg -lsmpeg
 PNG = -lpng
 JPEG = -ljpeg
-SCRAP = -luser32 -lgdi32
 COPYLIB_SDL -Lprebuilt/lib/SDL.dll
 COPYLIB_SDL_ttf -lSDL -lz -Lprebuilt/lib/SDL_ttf.dll
 COPYLIB_SDL_image -lSDL -ljpeg -lpng -ltiff -Lprebuilt/lib/SDL_image.dll

Setup_Win_Common.in

+# Windows specific flags for Pygame modules.
+SCRAP = -luser32 -lgdi32
 # Requires Python 2.4 or better and win32api.
 
-"""Config on Msys mingw"""
+"""Config on Msys mingw
+
+This version expects the Pygame 1.9.0 dependencies as built by
+msys_build_deps.py
+"""
 
 import dll
+from setup_win_common import get_definitions
 import msys
 import os, sys, string
 from glob import glob
         else:
             print_(self.name + '        '[len(self.name):] + ': not found')
 
-class DependencyWin:
-    needs_dll = False
-    def __init__(self, name, libs):
-        self.name = name
-        self.inc_dir = None
-        self.lib_dir = None
-        self.libs = libs
-        self.found = 1
-        self.cflags = ''
-        
-    def configure(self, incdirs, libdirs):
-        pass
-
 class DependencyDLL:
     needs_dll = False
     def __init__(self, name, libs=None):
         if libs is None:
-            libs = [dll.name_to_root(name)]
-        self.name = 'COPYLIB_' + name
+            libs = dll.libraries(name)
+        self.name = 'COPYLIB_' + dll.name_to_root(name)
         self.inc_dir = None
         self.lib_dir = '_'
         self.libs = libs
         # Not found
         return False
 
+class DependencyWin:
+    needs_dll = False
+    def __init__(self, name, cflags):
+        self.name = name
+        self.inc_dir = None
+        self.lib_dir = None
+        self.libs = []
+        self.found = 1
+        self.cflags = cflags
+        
+    def configure(self, incdirs, libdirs):
+        pass
+
 
 def main():
     m = msys.Msys(require_mingw=False)
     print_('\nHunting dependencies...')
     DEPS = [
-        DependencyProg('SDL', 'SDL_CONFIG', 'sdl-config', '1.2', m),
+        DependencyProg('SDL', 'SDL_CONFIG', 'sdl-config', '1.2.13', m),
         Dependency('FONT', 'SDL_ttf.h', 'libSDL_ttf.dll.a'),
         Dependency('IMAGE', 'SDL_image.h', 'libSDL_image.dll.a'),
         Dependency('MIXER', 'SDL_mixer.h', 'libSDL_mixer.dll.a'),
         DependencyProg('SMPEG', 'SMPEG_CONFIG', 'smpeg-config', '0.4.3', m),
         Dependency('PNG', 'png.h', 'libpng12.dll.a'),
         Dependency('JPEG', 'jpeglib.h', 'libjpeg.dll.a'),
-        DependencyWin('SCRAP', ['user32', 'gdi32']),
         DependencyDLL('TIFF'),
         DependencyDLL('VORBISFILE'),
         DependencyDLL('VORBIS'),
             dll_deps.append(dll_dep)
 
     DEPS += dll_deps
+    for d in get_definitions():
+        DEPS.append(DependencyWin(d.name, d.value))
     for d in DEPS:
         if isinstance(d, DependencyDLL):
             if d.lib_dir == '':
 """Config on Windows"""
 
-# **** The search part is broken. Only the prebuilt section creates
-# a correct Setup file.
+# **** The search part is broken. For instance, the png Visual Studio project
+# places to dll in a directory not checked by this module.
 
-import dll
+from setup_win_common import get_definitions
+
 import os, sys
+import re
 from glob import glob
 from distutils.sysconfig import get_python_inc
 
     lib_hunt = ['VisualC\\SDL\\Release', 'VisualC\\Release', 'Release', 'lib']
     def __init__(self, name, wildcards, libs=None, required = 0):
         if libs is None:
-            libs = [dll.name_to_root(name)]
+            libs = []
         self.name = name
         self.wildcards = wildcards
         self.required = required
 
 
 class DependencyDLL(Dependency):
-    def __init__(self, name=None, wildcards=None, link=None, libs=None):
-        if libs is None:
-            if name is not None:
-                libs = [dll.name_to_root(name)]
-            elif link is not None:
-                libs = link.libs
-            else:
-                libs = []
-        if name is None:
-            name = link.name
-        Dependency.__init__(self, 'COPYLIB_' + name, wildcards, libs)
-        self.lib_name = name
-        self.test = dll.tester(name)
+    def __init__(self, dll_regex, lib=None, wildcards=None, libs=None, link=None):
+        if lib is None:
+            lib = link.libs[0]
+        Dependency.__init__(self, 'COPYLIB_' + lib, wildcards, libs)
+        self.lib_name = lib
+        self.test = re.compile(dll_regex, re.I).match
         self.lib_dir = '_'
         self.found = 1
         self.link = link
                         return
         print "DLL for %s not found" % self.lib_name
 
-                    
 class DependencyWin(object):
-    def __init__(self, name, libs):
+    def __init__(self, name, cflags):
         self.name = name
         self.inc_dir = None
         self.lib_dir = None
-        self.libs = libs
+        self.libs = []
         self.found = 1
-        self.cflags = ''
+        self.cflags = cflags
         
     def configure(self):
         pass
 
+class DependencyGroup(object):
+    def __init__(self):
+        self.dependencies =[]
+        self.dlls = []
 
-DEPS = [
-    Dependency('SDL', ['SDL-[1-9].*'], required=1),
-    Dependency('FONT', ['SDL_ttf-[2-9].*']),
-    Dependency('IMAGE', ['SDL_image-[1-9].*']),
-    Dependency('MIXER', ['SDL_mixer-[1-9].*']),
-    Dependency('SMPEG', ['smpeg-[0-9].*', 'smpeg']),
-    DependencyWin('SCRAP', ['user32', 'gdi32']),
-    Dependency('JPEG', ['jpeg-[6-9]*']),
-    Dependency('PNG', ['libpng-[1-9].*']),
-    DependencyDLL('TIFF', ['tiff-[3-9].*']),
-    DependencyDLL('VORBIS', ['libvorbis-[1-9].*']),
-    DependencyDLL('OGG', ['libogg-[1-9].*']),
-    DependencyDLL('Z', ['zlib-[1-9].*']),
-]
+    def add(self, name, lib, wildcards, dll_regex, libs=None, required=0):
+        if libs is None:
+            libs = []
+        dep = Dependency(name, wildcards, [lib], required)
+        self.dependencies.append(dep)
+        self.dlls.append(DependencyDLL(dll_regex, link=dep, libs=libs))
 
-DEPS += [DependencyDLL(link=dep) for dep in DEPS[:] if type(dep) is Dependency]
-DEPS += [DependencyDLL('VORBISFILE', link=DEPS[9])]
+    def add_win(self, name, cflags):
+        self.dependencies.append(DependencyWin(name, cflags))
+                                 
+    def add_dll(self, dll_regex, lib=None, wildcards=None, libs=None, link_lib=None):
+        link = None
+        if link_lib is not None:
+            name = 'COPYLIB_' + link_lib
+            for d in self.dlls:
+                if d.name == name:
+                    link = d
+                    break
+            else:
+                raise KeyError("Link lib %s not found" % link_lib)
+        self.dlls.append(DependencyDLL(dll_regex, lib, wildcards, libs, link))
+
+    def configure(self):
+        for d in self:
+            d.configure()
+
+    def __iter__(self):
+        for d in self.dependencies:
+            yield d
+        for d in self.dlls:
+            yield d
+
+DEPS = DependencyGroup()
+DEPS.add('SDL', 'SDL', ['SDL-[1-9].*'], r'(lib){0,1}SDL\.dll$', required=1)
+DEPS.add('FONT', 'SDL_ttf', ['SDL_ttf-[2-9].*'], r'(lib){0,1}SDL_ttf\.dll$', ['SDL', 'z'])
+DEPS.add('IMAGE', 'SDL_image', ['SDL_image-[1-9].*'], r'(lib){0,1}SDL_image\.dll$',
+         ['SDL', 'jpeg', 'png', 'tiff'], 0),
+DEPS.add('MIXER', 'SDL_mixer', ['SDL_mixer-[1-9].*'], r'(lib){0,1}SDL_mixer\.dll$',
+         ['SDL', 'vorbisfile', 'smpeg'])
+DEPS.add('SMPEG', 'smpeg', ['smpeg-[0-9].*', 'smpeg'], r'smpeg\.dll$', ['SDL'])
+DEPS.add('PNG', 'png', ['libpng-[1-9].*'], r'(png|libpng13)\.dll$', ['z'])
+DEPS.add('JPEG', 'jpeg', ['jpeg-[6-9]*'], r'(lib){0,1}jpeg\.dll$')
+DEPS.add_dll(r'(lib){0,1}tiff\.dll$', 'tiff', ['tiff-[3-9].*'], ['jpeg', 'z'])
+DEPS.add_dll(r'(z|zlib1)\.dll$', 'z', ['zlib-[1-9].*'])
+DEPS.add_dll(r'(libvorbis-0|vorbis)\.dll$', 'vorbis', ['libvorbis-[1-9].*'],
+             ['ogg'])
+DEPS.add_dll(r'(libvorbisfile-3|vorbisfile)\.dll$', 'vorbisfile',
+             link_lib='vorbis', libs=['vorbis'])
+DEPS.add_dll(r'(libogg-0|ogg)\.dll$', 'ogg', ['libogg-[1-9].*'])
+for d in get_definitions():
+    DEPS.add_win(d.name, d.value)
+
 
 def setup_prebuilt():
     setup = open('Setup', 'w')
                 if line.startswith('#--StartConfig'):
                     do_copy = False
                     setup.write(setup_win_in.read())
+                    try:
+                        setup_win_common_in = open('Setup_Win_Common.in')
+                    except:
+                        pass
+                    else:
+                        try:
+                            setup.write(setup_win_common_in.read())
+                        finally:
+                            setup_win_common_in.close()
                 elif line.startswith('#--EndConfig'):
                     do_copy = True
                 elif do_copy:
             raise SystemExit()
 
     global DEPS
-    for d in DEPS:
-        d.configure()
     
-    return DEPS
+    DEPS.configure()
+    return list(DEPS)
 
 if __name__ == '__main__':
     print """This is the configuration subscript for Windows.

configtest/Setup_Win_Common.in

+# Windows specific flags for Pygame modules.
+SCRAP = -luser32 -lgdi32

configtest/test-sdl-config

+#!/bin/sh
+ARGS="$@"
+if [ "$ARGS" = '--version --cflags --libs' ]; then
+  echo '1.2.13'
+  echo '-I./SDL/include -DSDL_MACRO=1 -Wl,sdl_1,sdl_2'
+  echo '-L./SDL/lib -lSDL'
+fi

configtest/test-smpeg-config

+#!/bin/sh
+ARGS="$@"
+if [ "$ARGS" = '--version --cflags --libs' ]; then
+  echo '0.4.5'
+  echo '-I./smpeg/include -DSMPEG_MACRO=1 -Wl,smpeg_xlinker'
+  echo '-L./smpeg/lib -lsmpeg'
+fi

configtest/test_config_msys.py

 
 """Test config_msys.py against a dummy directory structure.
 
-This test must be performed on an MSYS console.
+This test requires MSYS. It is specific to the Pygame 1.9.0 dependencies
+as built by msys_build_deps.py.
 """
 
 import os
 
 import dll
 import config_msys
+import msys
 
 import unittest
-    
+
+cwd = os.getcwd()
+m = msys.Msys(require_mingw=False)
+os.environ['SDL_CONFIG'] = m.windows_to_msys(os.path.join(cwd, 'test-sdl-config'))
+os.environ['SMPEG_CONFIG'] = m.windows_to_msys(os.path.join(cwd, 'test-smpeg-config'))
 dependencies = dict([(dep.name, dep) for dep in config_msys.main()])
+del m
 
+class Dependency(object):
+    # Holds dependency info
+    def __init__(self, name=None, inc_dir_rel=None, lib_dir_rel=None, libs=None, cflags=None):
+        if libs is None:
+            if name is None:
+                libs = []
+            else:
+                libs = [dll.name_to_root(name)]
+        if cflags is None:
+            cflags = ''
+        self.libs = libs
+        self.inc_dir = None
+        self.lib_dir = None
+        if inc_dir_rel is not None:
+            self.inc_dir = '%s/%s' % (test_dir, inc_dir_rel)
+        if lib_dir_rel is not None:
+            self.lib_dir = '%s/%s' % (test_dir, lib_dir_rel)
+        self.cflags = cflags
+
+class DependencyDLL(Dependency):
+    def __init__(self, name=None, inc_dir_rel=None, lib_dir_rel=None, libs=None):
+        if libs is None:
+            if name is not None:
+                libs = dll.libraries(name)
+        super(DependencyDLL, self).__init__(name, inc_dir_rel, lib_dir_rel, libs)
 
 class RunConfigTestCase(unittest.TestCase):
     """Test dependencies returned by config_msys.main()"""
 
-    class Dependency(object):
-        # Holds dependency info
-        def __init__(self, name=None, inc_dir_rel=None, lib_dir_rel=None, libs=None):
-            if libs is None:
-                if name is None:
-                    libs = []
-                else:
-                    libs = [dll.name_to_root(name)]
-            self.libs = libs
-            self.inc_dir = None
-            self.lib_dir = None
-            if inc_dir_rel is not None:
-                self.inc_dir = '%s/%s' % (test_dir, inc_dir_rel)
-            if lib_dir_rel is not None:
-                self.lib_dir = '%s/%s' % (test_dir, lib_dir_rel)
-
     # Pygame dependencies
     expectations = {
-        'SDL': Dependency('SDL', 'include/sdl', 'lib'),  # ? uses sdl-config script
+        'SDL': Dependency('SDL', 'include/sdl', 'lib',
+                          cflags='-I./SDL/include -DSDL_MACRO=1 '
+                                 '-Xlinker -Wl,sdl_1,sdl_2 '
+                                 '-L./SDL/lib -lSDL '),  # uses test-sdl-config script
         'FONT': Dependency('FONT', 'include/sdl', 'lib'),
         'IMAGE': Dependency('IMAGE', 'include/sdl', 'lib'),
         'MIXER': Dependency('MIXER', 'include', 'lib'),  # A deviant include dir
-        'SMPEG': Dependency('SMPEG', 'include', 'lib'),  # ? uses smpeg-config script
+        'SMPEG': Dependency('SMPEG', 'include', 'lib',
+                            cflags='-I./smpeg/include -DSMPEG_MACRO=1 '
+                                   '-Xlinker -Wl,smpeg_xlinker '
+                                   '-L./smpeg/lib -lsmpeg '),  # uses test-smpeg-config script
         'PNG': Dependency('PNG', 'include/libpng12', 'lib'),
         'JPEG': Dependency('JPEG', 'include/sdl', 'lib'),  # A deviant include dir
-        'SCRAP': Dependency(libs=['user32', 'gdi32']),
-        'COPYLIB_SDL': Dependency('SDL', lib_dir_rel='bin/sdl.dll'),
-        'COPYLIB_FONT': Dependency('FONT', lib_dir_rel='bin/sdl_ttf.dll'),  # Where DLLs likely are
-        'COPYLIB_IMAGE': Dependency('IMAGE', lib_dir_rel='bin/sdl_image.dll'),
-        'COPYLIB_MIXER': Dependency('MIXER', lib_dir_rel='lib/sdl_mixer.dll'),  # Where the search starts
-        'COPYLIB_SMPEG': Dependency('SMPEG', lib_dir_rel='bin/smpeg.dll'),
-        'COPYLIB_TIFF': Dependency('TIFF', lib_dir_rel='bin/libtiff.dll'),
-        'COPYLIB_PNG': Dependency('PNG', lib_dir_rel='bin/libpng12-0.dll'),
-        'COPYLIB_JPEG': Dependency('JPEG', lib_dir_rel='bin/jpeg.dll'),
-        'COPYLIB_Z': Dependency('Z', lib_dir_rel='bin/zlib1.dll'),
-        'COPYLIB_VORBISFILE': Dependency('VORBISFILE', lib_dir_rel='bin/libvorbisfile-3.dll'),
-        'COPYLIB_VORBIS': Dependency('VORBIS', lib_dir_rel='bin/libvorbis-0.dll'),
-        'COPYLIB_OGG': Dependency('OGG', lib_dir_rel='bin/libogg-0.dll'),
-        'COPYLIB_FREETYPE': Dependency('FREETYPE', lib_dir_rel='bin/libfreetype-6.dll'),
+        'SCRAP': Dependency(cflags='-luser32 -lgdi32'),
+        'COPYLIB_SDL': DependencyDLL('SDL', lib_dir_rel='bin/sdl.dll'),
+        'COPYLIB_SDL_ttf': DependencyDLL('FONT', lib_dir_rel='bin/sdl_ttf.dll'),  # Where DLLs likely are
+        'COPYLIB_SDL_image': DependencyDLL('IMAGE', lib_dir_rel='bin/sdl_image.dll'),
+        'COPYLIB_SDL_mixer': DependencyDLL('MIXER', lib_dir_rel='lib/sdl_mixer.dll'),  # Where the search starts
+        'COPYLIB_smpeg': DependencyDLL('SMPEG', lib_dir_rel='bin/smpeg.dll'),
+        'COPYLIB_tiff': DependencyDLL('TIFF', lib_dir_rel='bin/libtiff.dll'),
+        'COPYLIB_png12': DependencyDLL('PNG', lib_dir_rel='bin/libpng12-0.dll'),
+        'COPYLIB_jpeg': DependencyDLL('JPEG', lib_dir_rel='bin/jpeg.dll'),
+        'COPYLIB_z': DependencyDLL('Z', lib_dir_rel='bin/zlib1.dll'),
+        'COPYLIB_vorbisfile': DependencyDLL('VORBISFILE', lib_dir_rel='bin/libvorbisfile-3.dll'),
+        'COPYLIB_vorbis': DependencyDLL('VORBIS', lib_dir_rel='bin/libvorbis-0.dll'),
+        'COPYLIB_ogg': DependencyDLL('OGG', lib_dir_rel='bin/libogg-0.dll'),
+        'COPYLIB_freetype': DependencyDLL('FREETYPE', lib_dir_rel='bin/libfreetype-6.dll'),
         }
 
     def test_dependencies(self):
     def test_dll_match(self):
         """Ensure DLLs match with dll.py."""
         for name in dll.regexs:
-            self.failUnless('COPYLIB_' + name in dependencies, name)
+            self.failUnless('COPYLIB_' + dll.name_to_root(name) in dependencies, name)
 
     def test_found(self):
         """Ensure all dependencies were found"""
             elib_dir = self.expectations[name].lib_dir
             self.failUnlessEqual(dlib_dir, elib_dir, "%s: %s != %s" % (name, dlib_dir, elib_dir))
 
+    def test_cflags(self):
+        """Ensure the cflags are properly set"""
+        for name, dep in dependencies.items():
+            dcflags = dep.cflags
+            ecflags = self.expectations[name].cflags
+            self.failUnlessEqual(dcflags, ecflags, "%s: '%s' != '%s'" % (name, dcflags, ecflags))
+
 if __name__ == '__main__':
     unittest.main()

configtest/test_config_win.py

 import sys
 sys.path.append('..')
 import config_win
-import dll
 
 import unittest
 import os
 
     class Dependency(object):
         # Holds dependency info
-        def __init__(self, name=None, inc_dir_rel=None, lib_dir_rel=None, libs=None):
+        def __init__(self, lib=None, inc_dir_rel=None, lib_dir_rel=None, libs=None, cflags=None):
             if libs is None:
-                if name is None:
+                if libs is not None:
+                    libs = libs
+                elif lib is not None:
+                    libs = [lib]
+                else:
                     libs = []
-                else:
-                    libs = [dll.name_to_root(name)]
+            if cflags is  None:
+                cflags = ''
             self.libs = libs
             self.inc_dir = None
             self.lib_dir = None
                 self.inc_dir = '%s/%s' % ('..', inc_dir_rel)
             if lib_dir_rel is not None:
                 self.lib_dir = '%s/%s' % ('..', lib_dir_rel)
+            self.cflags = cflags
 
     # Pygame dependencies
     expectations = {
         'SDL': Dependency('SDL', 'sdl-1.2/include', 'sdl-1.2/visualc/sdl/release'),
-        'FONT': Dependency('FONT', 'sdl_ttf-2.0.9', 'sdl_ttf-2.0.9/release'),
-        'IMAGE': Dependency('IMAGE', 'sdl_image-1.2.6', 'sdl_image-1.2.6/visualc/release'),
-        'MIXER': Dependency('MIXER', 'sdl_mixer-1.2', 'sdl_mixer-1.2/release'),
-        'SMPEG': Dependency('SMPEG', 'smpeg', 'smpeg/release'),
-        'PNG': Dependency('PNG', 'libpng-1.2.32', 'libpng-1.2.32/lib'),
-        'JPEG': Dependency('JPEG', 'jpeg-6b', 'jpeg-6b/release'),
-        'SCRAP': Dependency(libs=['user32', 'gdi32']),
-        'COPYLIB_SDL': Dependency('SDL',
-                                  lib_dir_rel='sdl-1.2/visualc/sdl/release/sdl.dll'),
-        'COPYLIB_FONT': Dependency('FONT',
-                                   lib_dir_rel='sdl_ttf-2.0.9/release/sdl_ttf.dll'),
-        'COPYLIB_IMAGE': Dependency('IMAGE',
-                                    lib_dir_rel='sdl_image-1.2.6/visualc/release/sdl_image.dll'),
-        'COPYLIB_MIXER': Dependency('MIXER',
-                                    lib_dir_rel='sdl_mixer-1.2/release/sdl_mixer.dll'),
-        'COPYLIB_SMPEG': Dependency('SMPEG', lib_dir_rel='smpeg/release/smpeg.dll'),
-        'COPYLIB_TIFF': Dependency('TIFF', lib_dir_rel='tiff-3.8.2/release/libtiff.dll'),
-        'COPYLIB_PNG': Dependency('PNG', lib_dir_rel='libpng-1.2.32/lib/libpng13.dll'),
-        'COPYLIB_JPEG': Dependency('JPEG', lib_dir_rel='jpeg-6b/release/jpeg.dll'),
-        'COPYLIB_Z': Dependency('Z', lib_dir_rel='zlib-1.2.3/release/zlib1.dll'),
-        'COPYLIB_VORBISFILE': Dependency('VORBISFILE',
+        'FONT': Dependency('SDL_ttf', 'sdl_ttf-2.0.9', 'sdl_ttf-2.0.9/release'),
+        'IMAGE': Dependency('SDL_image', 'sdl_image-1.2.6', 'sdl_image-1.2.6/visualc/release'),
+        'MIXER': Dependency('SDL_mixer','sdl_mixer-1.2', 'sdl_mixer-1.2/release'),
+        'SMPEG': Dependency('smpeg', 'smpeg', 'smpeg/release'),
+        'PNG': Dependency('png', 'libpng-1.2.32', 'libpng-1.2.32/lib'),
+        'JPEG': Dependency('jpeg', 'jpeg-6b', 'jpeg-6b/release'),
+        'SCRAP': Dependency(cflags=' -luser32 -lgdi32'),
+        'COPYLIB_SDL': Dependency(lib_dir_rel='sdl-1.2/visualc/sdl/release/sdl.dll'),
+        'COPYLIB_SDL_ttf': Dependency(libs=['SDL', 'z'],
+                                      lib_dir_rel='sdl_ttf-2.0.9/release/sdl_ttf.dll'),
+        'COPYLIB_SDL_image': Dependency(libs=['SDL', 'png', 'jpeg', 'tiff'],
+                                        lib_dir_rel='sdl_image-1.2.6/visualc/release/sdl_image.dll'),
+        'COPYLIB_SDL_mixer': Dependency(libs=['SDL', 'vorbisfile', 'smpeg'],
+                                        lib_dir_rel='sdl_mixer-1.2/release/sdl_mixer.dll'),
+        'COPYLIB_smpeg': Dependency(libs=['SDL'], lib_dir_rel='smpeg/release/smpeg.dll'),
+        'COPYLIB_tiff': Dependency(libs=['jpeg', 'z'], lib_dir_rel='tiff-3.8.2/release/libtiff.dll'),
+        'COPYLIB_png': Dependency(libs=['z'], lib_dir_rel='libpng-1.2.32/lib/libpng13.dll'),
+        'COPYLIB_jpeg': Dependency(lib_dir_rel='jpeg-6b/release/jpeg.dll'),
+        'COPYLIB_z': Dependency(lib_dir_rel='zlib-1.2.3/release/zlib1.dll'),
+        'COPYLIB_vorbisfile': Dependency(libs=['vorbis'],
                                          lib_dir_rel='libvorbis-1.2.0/release/libvorbisfile-3.dll'),
-        'COPYLIB_VORBIS': Dependency('VORBIS',
+        'COPYLIB_vorbis': Dependency(libs=['ogg'],
                                      lib_dir_rel='libvorbis-1.2.0/release/libvorbis-0.dll'),
-        'COPYLIB_OGG': Dependency('OGG', lib_dir_rel='libogg-1.1.3/release/libogg-0.dll'),
-        'COPYLIB_FREETYPE': Dependency('FREETYPE',
-                                       lib_dir_rel='freetype-2.3.7/objs/freetype.dll'),
+        'COPYLIB_ogg': Dependency(lib_dir_rel='libogg-1.1.3/release/libogg-0.dll'),
         }
 
     def test_dependencies(self):
         for name in self.expectations:
             self.failUnless(name in dependencies, name)
 
-    def test_dll_match(self):
-        """Ensure DLLs match with dll.py."""
-        for name in dll.regexs:
-            self.failUnless('COPYLIB_' + name in dependencies, name)
-
     def test_found(self):
         """Ensure all dependencies were found"""
         for dep in dependencies.values():
     def test_libs(self):
         """Ensure each dependency has the proper libraries"""
         for name, dep in dependencies.items():
-            dlibs = dep.libs
-            elibs = self.expectations[name].libs
+            dlibs = set(dep.libs)
+            elibs = set(self.expectations[name].libs)
             self.failUnlessEqual(dlibs, elibs, "%s: %s != %s" % (name, dlibs, elibs))
 
     def test_proper_include_paths(self):
             elib_dir = self.expectations[name].lib_dir
             self.failUnlessEqual(dlib_dir, elib_dir, "%s: %s != %s" % (name, dlib_dir, elib_dir))
 
+    def test_cflags(self):
+        """Ensure the cflags are properly set"""
+        for name, dep in dependencies.items():
+            dcflags = dep.cflags
+            ecflags = self.expectations[name].cflags
+            self.failUnlessEqual(dcflags, ecflags, "%s: %s != %s" % (name, dcflags, ecflags))
+        
 if __name__ == '__main__':
     unittest.main()

configtest/testdir/freetype-2.3.7/objs/freetype.dll

-A bogus DLL

configtest/testdir/lib/libpng.dll.a

-A bogus DLL

configtest/testdir/lib/libpng12.dll.a

+A bogus DLL
 # dll.py module
 
-"""DLL specifics"""
+"""DLL specifics
+
+Configured for the Pygame 1.9.0 dependencies as built by msys_build_deps.py.
+"""
 
 # Some definitions:
 #   Library name (name): An internal identifier, a string, for a library.
 import re
 
 # Table of dependencies.
-# name, root, File regex, Dependency list of file root names
+# name, root, File regex, Dependency list of names
 libraries = [
-    ('MIXER', 'SDL_mixer', r'(lib){0,1}SDL_mixer\.dll$',
-     ['SDL', 'vorbisfile', 'smpeg']),
-    ('VORBISFILE', 'vorbisfile',  r'(lib){0,1}vorbisfile(-3){0,1}\.dll$',
-     ['vorbis']),
-    ('VORBIS', 'vorbis', r'(lib){0,1}vorbis(-0){0,1}\.dll$', ['ogg']),
-    ('OGG', 'ogg', r'(lib){0,1}ogg(-0){0,1}\.dll$', []),
-    ('SMPEG', 'smpeg', r'(lib){0,1}smpeg\.dll$', ['SDL']),
-    ('IMAGE', 'SDL_image', r'(lib){0,1}SDL_image\.dll$',
-     ['SDL', 'jpeg', 'png', 'tiff']),
-    ('TIFF', 'tiff', r'(lib){0,1}tiff\.dll$',  ['jpeg', 'z']),
-    ('JPEG', 'jpeg', r'(lib){0,1}jpeg\.dll$', []),
-    ('PNG', 'png', r'(lib){0,1}png(1[23])\.dll$', ['z']),
-    ('FONT', 'SDL_ttf', r'(lib){0,1}SDL_ttf\.dll$', ['SDL', 'z']),
+    ('MIXER', 'SDL_mixer', r'SDL_mixer\.dll$',
+     ['SDL', 'VORBISFILE', 'SMPEG']),
+    ('VORBISFILE', 'vorbisfile',  r'libvorbisfile-3\.dll$',
+     ['VORBIS']),
+    ('VORBIS', 'vorbis', r'libvorbis-0\.dll$', ['OGG']),
+    ('OGG', 'ogg', r'libogg-0\.dll$', []),
+    ('SMPEG', 'smpeg', r'smpeg\.dll$', ['SDL']),
+    ('IMAGE', 'SDL_image', r'SDL_image\.dll$',
+     ['SDL', 'JPEG', 'PNG', 'TIFF']),
+    ('TIFF', 'tiff', r'libtiff\.dll$',  ['JPEG', 'Z']),
+    ('JPEG', 'jpeg', r'jpeg\.dll$', []),
+    ('PNG', 'png12', r'libpng12-0\.dll$', ['Z']),
+    ('FONT', 'SDL_ttf', r'SDL_ttf\.dll$', ['SDL']),
+    ('FREETYPE', 'freetype', r'libfreetype-6\.dll$', ['Z']),
     ('Z', 'z', r'zlib1\.dll$', []),
-    ('SDL', 'SDL', r'(lib){0,1}SDL\.dll$', [])
+    ('SDL', 'SDL', r'SDL\.dll$', [])
 ]
 
 # regexs: Maps name to DLL file name regex.
 regexs = {}
 lib_dependencies = {}
 file_root_names = {}
+for name, root, ignore1, ignore2 in libraries:
+    file_root_names[name] = root
 for name, root, regex, deps in libraries:
     regexs[name] = regex
-    lib_dependencies[root] = deps
-    file_root_names[name] = root
-del name, root, regex, deps
+    lib_dependencies[root] = [file_root_names[d] for d in deps]
+del name, root, regex, deps, ignore1, ignore2
 
 def tester(name):
     """For a library name return a function which tests dll file names"""
     test.library_name = name  # Available for debugging.
     return test
 
-def dependencies(roots):
-    """Return a set of dependencies for the list of library file roots
-
-    The return set is a dictionary keyed on library root name with values of 1.
-    """
-
-    root_set = {}
-    for root in roots:
-        try:
-            deps = lib_dependencies[root]
-        except KeyError:
-            pass
-        else:
-            root_set[root] = 1
-            root_set.update(dependencies(deps))
-    return root_set
-
 def name_to_root(name):
     """Return the library file root for the library name"""
     
     return file_root_names[name]
+
+def libraries(name):
+    """Return the library file roots this library links too"""
+
+    return lib_dependencies[name_to_root(name)]
-# This is a work in progress
-
 import msys
 from distutils.extension import read_setup_file
 

prebuilt-template/Setup_Win.in

 SMPEG = -Iprebuilt/include/smpeg -lsmpeg
 PNG = -Iprebuilt/include/libpng12 -lpng12
 JPEG = -ljpeg
-SCRAP = -luser32 -lgdi32
 COPYLIB_SDL -Lprebuilt/lib/SDL.dll
 COPYLIB_SDL_ttf -lSDL -lfreetype -Lprebuilt/lib/SDL_ttf.dll
 COPYLIB_SDL_image -lSDL -ljpef -lpng12 -ltiff -Lprebuilt/lib/SDL_image.dll

setup_win_common.py

+# -*- encoding: utf-8 -*-
+
+# module setup_win_common.py
+
+"""A module for reading the information common to all Windows setups.
+
+Exports read and get_definitions.
+"""
+
+path = 'Setup_Win_Common.in'
+
+class Definition(object):
+    def __init__(self, name, value):
+        self.name = name
+        self.value = value
+
+def read():
+    """Return the contents of the Windows Common Setup as a string"""
+
+    setup_in = open(path)
+    try:
+        return setup_in.read()
+    finally:
+        setup_in.close()
+
+def get_definitions():
+    """Return a list of definitions in the Windows Common Setup
+
+    Each macro definition object has a 'name' and 'value' attribute.
+    """
+    import re
+    
+    setup_in = open(path)
+    try:
+        deps = []
+        match = re.compile(r'([a-zA-Z0-9_]+) += +(.+)$').match
+        for line in setup_in:
+            m = match(line)
+            if m is not None:
+                deps.append(Definition(m.group(1), m.group(2)))
+        return deps
+    finally:
+        setup_in.close()
+
+__all__= ['read', 'get_dependencies']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.