~ubuntu-branches/ubuntu/maverick/pygame/maverick

« back to all changes in this revision

Viewing changes to dll.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-01-14 17:02:11 UTC
  • mfrom: (1.3.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100114170211-21eop2ja7mr9vdcr
Tags: 1.9.1release-0ubuntu1
* New upstream version (lp: #433304)
* debian/control:
  - build-depends on libportmidi-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# dll.py module
2
2
 
3
 
"""DLL specifics"""
 
3
"""DLL specifics
 
4
 
 
5
Configured for the Pygame 1.9.0 dependencies as built by msys_build_deps.py.
 
6
"""
4
7
 
5
8
# Some definitions:
6
9
#   Library name (name): An internal identifier, a string, for a library.
11
14
import re
12
15
 
13
16
# Table of dependencies.
14
 
# name, root, File regex, Dependency list of file root names
 
17
# name, root, File regex, Dependency list of names
15
18
libraries = [
16
 
    ('MIXER', 'SDL_mixer', r'(lib){0,1}SDL_mixer\.dll$',
17
 
     ['SDL', 'vorbisfile', 'smpeg']),
18
 
    ('VORBISFILE', 'vorbisfile',  r'(lib){0,1}vorbisfile(-3){0,1}\.dll$',
19
 
     ['vorbis']),
20
 
    ('VORBIS', 'vorbis', r'(lib){0,1}vorbis(-0){0,1}\.dll$', ['ogg']),
21
 
    ('OGG', 'ogg', r'(lib){0,1}ogg(-0){0,1}\.dll$', []),
22
 
    ('SMPEG', 'smpeg', r'(lib){0,1}smpeg\.dll$', ['SDL']),
23
 
    ('IMAGE', 'SDL_image', r'(lib){0,1}SDL_image\.dll$',
24
 
     ['SDL', 'jpeg', 'png', 'tiff']),
25
 
    ('TIFF', 'tiff', r'(lib){0,1}tiff\.dll$',  ['jpeg', 'z']),
26
 
    ('JPEG', 'jpeg', r'(lib){0,1}jpeg\.dll$', []),
27
 
    ('PNG', 'png', r'(lib){0,1}png(1[23])\.dll$', ['z']),
28
 
    ('FONT', 'SDL_ttf', r'(lib){0,1}SDL_ttf\.dll$', ['SDL', 'z']),
 
19
    ('MIXER', 'SDL_mixer', r'SDL_mixer\.dll$',
 
20
     ['SDL', 'VORBISFILE', 'SMPEG']),
 
21
    ('VORBISFILE', 'vorbisfile',  r'libvorbisfile-3\.dll$',
 
22
     ['VORBIS']),
 
23
    ('VORBIS', 'vorbis', r'libvorbis-0\.dll$', ['OGG']),
 
24
    ('OGG', 'ogg', r'libogg-0\.dll$', []),
 
25
    ('SMPEG', 'smpeg', r'smpeg\.dll$', ['SDL']),
 
26
    ('IMAGE', 'SDL_image', r'SDL_image\.dll$',
 
27
     ['SDL', 'JPEG', 'PNG', 'TIFF']),
 
28
    ('TIFF', 'tiff', r'libtiff\.dll$',  ['JPEG', 'Z']),
 
29
    ('JPEG', 'jpeg', r'jpeg\.dll$', []),
 
30
    ('PNG', 'png12', r'libpng12-0\.dll$', ['Z']),
 
31
    ('FONT', 'SDL_ttf', r'SDL_ttf\.dll$', ['SDL']),
 
32
    ('FREETYPE', 'freetype', r'libfreetype-6\.dll$', ['Z']),
29
33
    ('Z', 'z', r'zlib1\.dll$', []),
30
 
    ('SDL', 'SDL', r'(lib){0,1}SDL\.dll$', [])
 
34
    ('SDL', 'SDL', r'SDL\.dll$', []),
 
35
    ('PORTMIDI', 'portmidi', r'portmidi\.dll', []),
 
36
    ('PORTTIME', 'portmidi', r'portmidi\.dll', []),
31
37
]
32
38
 
33
39
# regexs: Maps name to DLL file name regex.
37
43
regexs = {}
38
44
lib_dependencies = {}
39
45
file_root_names = {}
 
46
for name, root, ignore1, ignore2 in libraries:
 
47
    file_root_names[name] = root
40
48
for name, root, regex, deps in libraries:
41
49
    regexs[name] = regex
42
 
    lib_dependencies[root] = deps
43
 
    file_root_names[name] = root
44
 
del name, root, regex, deps
 
50
    lib_dependencies[root] = [file_root_names[d] for d in deps]
 
51
del name, root, regex, deps, ignore1, ignore2
45
52
 
46
53
def tester(name):
47
54
    """For a library name return a function which tests dll file names"""
55
62
    test.library_name = name  # Available for debugging.
56
63
    return test
57
64
 
58
 
def dependencies(roots):
59
 
    """Return a set of dependencies for the list of library file roots
60
 
 
61
 
    The return set is a dictionary keyed on library root name with values of 1.
62
 
    """
63
 
 
64
 
    root_set = {}
65
 
    for root in roots:
66
 
        try:
67
 
            deps = lib_dependencies[root]
68
 
        except KeyError:
69
 
            pass
70
 
        else:
71
 
            root_set[root] = 1
72
 
            root_set.update(dependencies(deps))
73
 
    return root_set
74
 
 
75
65
def name_to_root(name):
76
66
    """Return the library file root for the library name"""
77
67
    
78
68
    return file_root_names[name]
 
69
 
 
70
def libraries(name):
 
71
    """Return the library file roots this library links too"""
 
72
 
 
73
    return lib_dependencies[name_to_root(name)]