public
Description: wxWidgets Python bindings
Homepage: http://code.google.com/p/wxpy
Clone URL: git://github.com/kevinwatters/wxpy.git
wxpy / wxpyconfig.py
100644 99 lines (71 sloc) 2.925 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'''
../configure --enable-unicode --enable-optimise --disable-ftp --disable-dialupman --disable-mediactrl --disable-help --disable-xrc --disable-aui --disable-constraints --disable-printarch --disable-mdi --disable-mdidoc --disable-richtext --disable-grid --disable-dataviewctrl --disable-tipdlg --disable-wizarddlg
'''
 
import os
import platform
import shlex
from path import path
 
wxpy_dir = path(os.environ['WXPYDIR'])
possible_wx_libs = 'xrc stc aui html qa adv core xml net base'.split()
use_wx_libs = 'core base adv'.split()
 
if os.name == 'nt':
    platform_name = 'msw'
elif 'Darwin' in platform.platform():
    platform_name = 'mac'
 
wxconfig = 'wx-config'
 
if platform_name in ('mac',):
    #wxconfig = path('~/src/wxWebKitBranch-2.8/macbuild/wx-config').expand()
    wxconfig = path('~/wxpython-2.8/bin/wx-config').expand()
 
    print 'using wxconfig:', str(wxconfig)
 
    if not wxconfig.exists():
        raise AssertionError('cannot find wx-config at: "%s"' % wxconfig)
 
    cxxflags = shlex.split(wxconfig.run('--cxxflags').strip()) + ['-Wall', '-ggdb']
    lflags = shlex.split(wxconfig.run('--libs %s' % ','.join(use_wx_libs)).strip())
 
    # passed as -t argument
    sip_platform = 'WXMAC'
 
elif platform_name == 'msw':
    wxdir = path(os.environ['WXDIR'])
    assert wxdir.exists()
 
    print 'using wxwidgets dir:', wxdir
 
    WX_FLAG = 'ud' # the postfix on .libs and .dlls
    WXDEBUG = True # __WXDEBUG__
    DEBUG_SYMBOLS = True # /Zi
    ENABLE_EXCEPTIONS = False
    WHOLE_PROGRAM_OPTIMIZATION = False
 
    # TODO: infer these without a wx-config binary? (bakefiles!)
    cxxflags = ('/MD /DWIN32 /GR /D__NO_VC_CRTDBG__ /D__WXMSW__ '
                '/D_UNICODE /DwxUSE_UNICODE_MSLU=1 '
                '/DwxUSE_GRAPHICS_CONTEXT=1 /DWXUSINGDLL /Ox').split()
 
    lflags = ['/LIBPATH:' + str(wxdir / 'lib/vc_dll')]
 
    if WHOLE_PROGRAM_OPTIMIZATION:
        cxxflags.append('/GL')
        lflags.append('/LTCG')
 
    if WXDEBUG:
        cxxflags.extend(['/D__WXDEBUG__', '/D__NO_VC_CRTDBG__'])
 
    if DEBUG_SYMBOLS: # debug
        cxxflags.append('/Zi')
 
    if ENABLE_EXCEPTIONS:
        cxxflags.append('/EHa')
    else:
        cxxflags.append('/DwxNO_EXCEPTIONS')
 
 
    wx_lib_dir = wxdir / 'lib/vc_dll'
    wx_config_dir = 'msw' + WX_FLAG
 
    # TODO: these too ;)
    cxxflags.extend(['/I%s' % str(wx_lib_dir / wx_config_dir),
                     '/I%s' % str(wxdir / 'include')])
 
    wx_libs = '''\
base28%s
base28%s_net
base28%s_xml
msw28%s_adv
msw28%s_aui
msw28%s_core
msw28%s_html'''.split()
 
    wx_libs = ['wx' + (s % WX_FLAG) + '.lib' for s in wx_libs]
    lflags.extend(wx_libs)
 
    if DEBUG_SYMBOLS:
        lflags.append('/DEBUG')
 
    sip_platform = 'WXMSW'
 
 
assert 'sip_platform' in locals(), "Must set sip_platform"
assert 'cxxflags' in locals(), "Must set cxxflags"
assert 'lflags' in locals(), "Must set lflags"