]>
Commit | Line | Data |
---|---|---|
ddf98968 VS |
1 | # |
2 | # Helper functions for wxWindows bakefiles | |
3 | # | |
4 | # $Id$ | |
5 | # | |
6 | ||
7 | ||
cff5df9f VS |
8 | import 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): | |
14 | def __noopSubst(func, opt): | |
15 | return '$(%s)' % opt.name | |
16 | utils.addSubstituteCallback('CFG', __noopSubst) | |
17 | ||
18 | ||
ddf98968 VS |
19 | def 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: | |
e6978d5b VS |
32 | LIBS_NOGUI = [''] |
33 | LIBS_GUI = ['core', 'html'] | |
ddf98968 VS |
34 | |
35 | def 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)' | |
e6978d5b VS |
41 | if wxid == 'base': |
42 | return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)$(WXVERSIONTAG)' | |
43 | if wxid in LIBS_NOGUI: | |
ddf98968 VS |
44 | return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)' % wxid |
45 | return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)' % wxid | |
46 | ||
47 | def mkDllName(wxid): | |
48 | """Returns string that can be used as DLL name, including name | |
49 | suffixes, prefixes, version tags etc. This must be kept in sync | |
50 | with variables defined in common.bkl!""" | |
51 | if wxid == 'mono': | |
4fc5f509 | 52 | return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' |
e6978d5b VS |
53 | if wxid == 'base': |
54 | return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' | |
55 | if wxid in LIBS_NOGUI: | |
4fc5f509 VS |
56 | return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid |
57 | return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid | |
ddf98968 VS |
58 | |
59 | ||
60 | def libToLink(wxlibname): | |
61 | """Returns string to pass to <sys-lib> when linking against 'wxlibname'. | |
62 | libToLink('foo') returns '$(WXLIB_FOO)' which must be defined in | |
63 | common.bkl as either nothing (in monolithic build) or mkLibName('foo') | |
64 | (otherwise).""" | |
65 | return '$(WXLIB_%s)' % wxlibname.upper() | |
66 | ||
67 | ||
68 | wxVersion = None | |
69 | VERSION_FILE = '../../include/wx/version.h' | |
70 | ||
71 | def getVersion(): | |
72 | """Returns wxWindows version as a tuple: (major,minor,release).""" | |
73 | global wxVersion | |
74 | if wxVersion == None: | |
75 | f = open(VERSION_FILE, 'rt') | |
76 | lines = f.readlines() | |
77 | f.close() | |
78 | major = minor = release = None | |
79 | for l in lines: | |
80 | if not l.startswith('#define'): continue | |
81 | splitted = l.strip().split() | |
82 | if splitted[0] != '#define': continue | |
83 | if len(splitted) < 3: continue | |
84 | name = splitted[1] | |
85 | value = splitted[2] | |
86 | if value == None: continue | |
87 | if name == 'wxMAJOR_VERSION': major = int(value) | |
88 | if name == 'wxMINOR_VERSION': minor = int(value) | |
89 | if name == 'wxRELEASE_NUMBER': release = int(value) | |
90 | if major != None and minor != None and release != None: | |
91 | break | |
92 | wxVersion = (major, minor, release) | |
93 | return wxVersion | |
94 | ||
95 | def getVersionMajor(): | |
96 | return getVersion()[0] | |
97 | def getVersionMinor(): | |
98 | return getVersion()[1] | |
99 | def getVersionRelease(): | |
100 | return getVersion()[2] |