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