]> git.saurik.com Git - wxWidgets.git/blob - build/bakefiles/wxwin.py
re-added OpenGL canvas
[wxWidgets.git] / build / bakefiles / wxwin.py
1 #
2 # Helper functions for wxWindows bakefiles
3 #
4 # $Id$
5 #
6
7
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
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 # All libs that are part of the main library (i.e. non-contrib):
32 MAIN_LIBS = ['mono', 'base', 'core', 'html']
33 # List of library names/ids for categories with different names:
34 LIBS_NOGUI = ['']
35 LIBS_GUI = ['core', 'html']
36
37 def mkLibName(wxid):
38 """Returns string that can be used as library name, including name
39 suffixes, prefixes, version tags etc. This must be kept in sync
40 with variables defined in common.bkl!"""
41 if wxid == 'mono':
42 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXVERSIONTAG)'
43 if wxid == 'base':
44 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)$(WXVERSIONTAG)'
45 if wxid in LIBS_NOGUI:
46 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)' % wxid
47 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)' % wxid
48
49 def mkDllName(wxid):
50 """Returns string that can be used as DLL name, including name
51 suffixes, prefixes, version tags etc. This must be kept in sync
52 with variables defined in common.bkl!"""
53 if wxid == 'mono':
54 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
55 if wxid == 'base':
56 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
57 if wxid in LIBS_NOGUI:
58 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
59 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
60
61
62 def libToLink(wxlibname):
63 """Returns string to pass to <sys-lib> when linking against 'wxlibname'.
64 For one of main libraries, libToLink('foo') returns '$(WXLIB_FOO)' which
65 must be defined in common.bkl as either nothing (in monolithic build) or
66 mkLibName('foo') (otherwise).
67 For contrib libraries, it returns mkDllName(wxlibname).
68 """
69 if wxlibname in MAIN_LIBS:
70 return '$(WXLIB_%s)' % wxlibname.upper()
71 else:
72 return mkLibName(wxlibname)
73
74
75 wxVersion = None
76 VERSION_FILE = '../../include/wx/version.h'
77
78 def getVersion():
79 """Returns wxWindows version as a tuple: (major,minor,release)."""
80 global wxVersion
81 if wxVersion == None:
82 f = open(VERSION_FILE, 'rt')
83 lines = f.readlines()
84 f.close()
85 major = minor = release = None
86 for l in lines:
87 if not l.startswith('#define'): continue
88 splitted = l.strip().split()
89 if splitted[0] != '#define': continue
90 if len(splitted) < 3: continue
91 name = splitted[1]
92 value = splitted[2]
93 if value == None: continue
94 if name == 'wxMAJOR_VERSION': major = int(value)
95 if name == 'wxMINOR_VERSION': minor = int(value)
96 if name == 'wxRELEASE_NUMBER': release = int(value)
97 if major != None and minor != None and release != None:
98 break
99 wxVersion = (major, minor, release)
100 return wxVersion
101
102 def getVersionMajor():
103 return getVersion()[0]
104 def getVersionMinor():
105 return getVersion()[1]
106 def getVersionRelease():
107 return getVersion()[2]