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