]> git.saurik.com Git - wxWidgets.git/blame_incremental - build/bakefiles/wxwin.py
fix the problem with parsing HTML comments (closes bug 1116708; based on patch 1168583)
[wxWidgets.git] / build / bakefiles / wxwin.py
... / ...
CommitLineData
1#
2# Helper functions for wxWidgets bakefiles
3#
4# $Id$
5#
6
7
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):
14
15try:
16 # this fails in 0.1.4 and 0.1.5 has different subst.callbacks signature:
17 utils.checkBakefileVersion('0.1.5')
18 def __noopSubst(name, func, caller):
19 return '$(%s)' % name
20except AttributeError:
21 def __noopSubst(func, name):
22 return '$(%s)' % name
23utils.addSubstituteCallback('CFG', __noopSubst)
24utils.addSubstituteCallback('LIBDIRNAME', __noopSubst)
25utils.addSubstituteCallback('SETUPHDIR', __noopSubst)
26utils.addSubstituteCallback('OBJS', __noopSubst)
27
28
29def mk_wxid(id):
30 """Creates wxWidgets library identifier from bakefile target ID that
31 follows this convention: DLLs end with 'dll', static libraries
32 end with 'lib'. If withPrefix=1, then _wxid is returned instead
33 of wxid."""
34 if id.endswith('dll') or id.endswith('lib'):
35 wxid = id[:-3]
36 else:
37 wxid = id
38 return wxid
39
40
41# All libs that are part of the main library (i.e. non-contrib):
42MAIN_LIBS = ['mono', 'base', 'core', 'adv', 'html', 'xml', 'net',
43 'media', 'odbc', 'qa', 'dbgrid', 'xrc', 'aui', 'richtext', 'stc']
44# List of library names/ids for categories with different names:
45LIBS_NOGUI = ['xml', 'net', 'odbc']
46LIBS_GUI = ['core', 'adv', 'html', 'gl', 'qa', 'dbgrid', 'xrc', 'media',
47 'aui', 'richtext', 'stc']
48# Additional libraries that must be linked in:
49EXTRALIBS = {
50 'gl' : '$(EXTRALIBS_OPENGL)',
51 'xml' : '$(EXTRALIBS_XML)',
52 'html' : '$(EXTRALIBS_HTML)',
53 'odbc' : '$(EXTRALIBS_ODBC)',
54 'adv' : '$(PLUGIN_ADV_EXTRALIBS)',
55}
56
57def mkLibName(wxid):
58 """Returns string that can be used as library name, including name
59 suffixes, prefixes, version tags etc. This must be kept in sync
60 with variables defined in common.bkl!"""
61 if wxid == 'mono':
62 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
63 if wxid == 'base':
64 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
65 if wxid in LIBS_NOGUI:
66 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
67 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
68
69def mkDllName(wxid):
70 """Returns string that can be used as DLL name, including name
71 suffixes, prefixes, version tags etc. This must be kept in sync
72 with variables defined in common.bkl!"""
73 if wxid == 'mono':
74 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
75 if wxid == 'base':
76 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
77 if wxid in LIBS_NOGUI:
78 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
79 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
80
81
82def libToLink(wxlibname):
83 """Returns string to pass to <sys-lib> when linking against 'wxlibname'.
84 For one of main libraries, libToLink('foo') returns '$(WXLIB_FOO)' which
85 must be defined in common.bkl as either nothing (in monolithic build) or
86 mkLibName('foo') (otherwise).
87 For contrib libraries, it returns mkDllName(wxlibname).
88 """
89 if wxlibname in MAIN_LIBS:
90 return '$(WXLIB_%s)' % wxlibname.upper()
91 else:
92 return mkLibName(wxlibname)
93
94def extraLdflags(wxlibname):
95 if wxlibname in EXTRALIBS:
96 return EXTRALIBS[wxlibname]
97 else:
98 return ''
99
100wxVersion = None
101VERSION_FILE = '../../include/wx/version.h'
102
103def getVersion():
104 """Returns wxWidgets version as a tuple: (major,minor,release)."""
105 global wxVersion
106 if wxVersion == None:
107 f = open(VERSION_FILE, 'rt')
108 lines = f.readlines()
109 f.close()
110 major = minor = release = None
111 for l in lines:
112 if not l.startswith('#define'): continue
113 splitline = l.strip().split()
114 if splitline[0] != '#define': continue
115 if len(splitline) < 3: continue
116 name = splitline[1]
117 value = splitline[2]
118 if value == None: continue
119 if name == 'wxMAJOR_VERSION': major = int(value)
120 if name == 'wxMINOR_VERSION': minor = int(value)
121 if name == 'wxRELEASE_NUMBER': release = int(value)
122 if major != None and minor != None and release != None:
123 break
124 wxVersion = (major, minor, release)
125 return wxVersion
126
127def getVersionMajor():
128 return getVersion()[0]
129def getVersionMinor():
130 return getVersion()[1]
131def getVersionRelease():
132 return getVersion()[2]
133
134
135def headersOnly(files):
136 """Filters 'files' so that only headers are left. Used with
137 <msvc-project-files> to add headers to VC++ projects but not files such
138 as arrimpl.cpp."""
139
140 def callback(cond, sources):
141 prf = suf = ''
142 if sources[0].isspace(): prf=' '
143 if sources[-1].isspace(): suf=' '
144 retval = []
145 for s in sources.split():
146 if s.endswith('.h'):
147 retval.append(s)
148 return '%s%s%s' % (prf, ' '.join(retval), suf)
149 return utils.substitute2(files, callback)
150
151
152def makeDspDependency(lib):
153 """Returns suitable entry for <depends-on-dsp> for main libs."""
154 return '%s:$(nativePaths(WXTOPDIR))build\\msw\\wx_%s.dsp' % (lib,lib)
155
156def makeContribDspDependency(lib):
157 """Returns suitable entry for <depends-on-dsp> for contrib libs."""
158 return '%s:$(nativePaths(WXTOPDIR))contrib\\build\\%s\\%s.dsp' % (lib,lib,lib)