1 # Copyright (C) 2009 Kevin Ollivier All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
12 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
13 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
16 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 # Library for functions to determine wx settings based on configuration
33 def parse_build_cfg(filename):
34 cfg_file = open(filename, 'r')
36 for cfg_line in cfg_file.readlines():
39 parts = cfg_line.split('=')
41 key = parts[0].strip()
44 value = parts[1].strip()
54 def get_wx_version(wx_root):
55 versionText = open(os.path.join(wx_root, "include", "wx", "version.h"), "r").read()
57 majorVersion = re.search("#define\swxMAJOR_VERSION\s+(\d+)", versionText).group(1)
58 minorVersion = re.search("#define\swxMINOR_VERSION\s+(\d+)", versionText).group(1)
59 releaseVersion = re.search("#define\swxRELEASE_NUMBER\s+(\d+)", versionText).group(1)
61 release = [majorVersion, minorVersion]
62 if int(minorVersion) % 2 == 1:
63 release.append(releaseVersion)
67 def get_wxmsw_settings(wx_root, shared=False, unicode=False, debug=False, wxPython=False):
68 if not os.path.exists(wx_root):
69 print "Directory %s does not exist." % wx_root
72 defines = ['__WXMSW__']
73 includes = [os.path.join(wx_root, 'include')]
78 libdir = os.path.join(wx_root, 'lib')
82 version_str_nodot = ''.join(get_wx_version(wx_root)[0:2])
85 defines.append('WXUSINGDLL')
86 libdir = os.path.join(libdir, Options.options.wx_compiler_prefix + '_dll')
88 libdir = os.path.join(libdir, Options.options.wx_compiler_prefix + '_lib')
91 defines.append('_UNICODE')
95 if wxPython and not version_str_nodot.startswith('29'):
98 elif debug and not version_str_nodot.startswith('29'):
102 configdir = os.path.join(libdir, 'msw' + ext)
105 cfg_file = os.path.join(configdir, 'build.cfg')
106 if os.path.exists(cfg_file):
107 cfg = parse_build_cfg(cfg_file)
108 if "MONOLITHIC" in cfg:
109 monolithic = cfg["MONOLITHIC"]
110 libpaths.append(libdir)
111 includes.append(configdir)
113 def get_wxlib_name(name):
115 return 'wxbase%s%s' % (version_str_nodot, ext)
117 return "wxmsw%s%s_%s" % (version_str_nodot, ext, name)
119 libs.extend(['wxzlib' + depext, 'wxjpeg' + depext, 'wxpng' + depext, 'wxexpat' + depext])
121 libs.extend(["wxmsw%s%s" % (version_str_nodot, ext)])
123 libs.extend([get_wxlib_name('base'), get_wxlib_name('core')])
125 if wxPython or debug:
126 defines.append('__WXDEBUG__')
128 return (defines, includes, libs, libpaths)