]> git.saurik.com Git - wxWidgets.git/blob - build/bakefiles/wxwin.py
fixes to wxBase compilation
[wxWidgets.git] / build / bakefiles / wxwin.py
1 #
2 # Helper functions for wxWindows bakefiles
3 #
4 # $Id$
5 #
6
7
8 def mk_wxid(id):
9 """Creates wxWindows library identifier from bakefile target ID that
10 follows this convention: DLLs end with 'dll', static libraries
11 end with 'lib'. If withPrefix=1, then _wxid is returned instead
12 of wxid."""
13 if id.endswith('dll') or id.endswith('lib'):
14 wxid = id[:-3]
15 else:
16 wxid = id
17 return wxid
18
19
20 # List of library names/ids for categories with different names:
21 LIBS_BASE = ['base']
22 LIBS_GUI = ['core', 'html']
23
24 def mkLibName(wxid):
25 """Returns string that can be used as library name, including name
26 suffixes, prefixes, version tags etc. This must be kept in sync
27 with variables defined in common.bkl!"""
28 if wxid == 'mono':
29 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXVERSIONTAG)'
30 if wxid in LIBS_BASE:
31 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)' % wxid
32 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)' % wxid
33
34 def mkDllName(wxid):
35 """Returns string that can be used as DLL name, including name
36 suffixes, prefixes, version tags etc. This must be kept in sync
37 with variables defined in common.bkl!"""
38 if wxid == 'mono':
39 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(WXVERSIONTAG)'
40 if wxid in LIBS_BASE:
41 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(WXVERSIONTAG)' % wxid
42 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(WXVERSIONTAG)' % wxid
43
44
45 def libToLink(wxlibname):
46 """Returns string to pass to <sys-lib> when linking against 'wxlibname'.
47 libToLink('foo') returns '$(WXLIB_FOO)' which must be defined in
48 common.bkl as either nothing (in monolithic build) or mkLibName('foo')
49 (otherwise)."""
50 return '$(WXLIB_%s)' % wxlibname.upper()
51
52
53 wxVersion = None
54 VERSION_FILE = '../../include/wx/version.h'
55
56 def getVersion():
57 """Returns wxWindows version as a tuple: (major,minor,release)."""
58 global wxVersion
59 if wxVersion == None:
60 f = open(VERSION_FILE, 'rt')
61 lines = f.readlines()
62 f.close()
63 major = minor = release = None
64 for l in lines:
65 if not l.startswith('#define'): continue
66 splitted = l.strip().split()
67 if splitted[0] != '#define': continue
68 if len(splitted) < 3: continue
69 name = splitted[1]
70 value = splitted[2]
71 if value == None: continue
72 if name == 'wxMAJOR_VERSION': major = int(value)
73 if name == 'wxMINOR_VERSION': minor = int(value)
74 if name == 'wxRELEASE_NUMBER': release = int(value)
75 if major != None and minor != None and release != None:
76 break
77 wxVersion = (major, minor, release)
78 return wxVersion
79
80 def getVersionMajor():
81 return getVersion()[0]
82 def getVersionMinor():
83 return getVersion()[1]
84 def getVersionRelease():
85 return getVersion()[2]