]> git.saurik.com Git - wxWidgets.git/blame - build/bakefiles/wxwin.py
use univ/setup.h when building wxUniv
[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):
404d4609
VS
14def __noopSubst(func, name):
15 return '$(%s)' % name
cff5df9f 16utils.addSubstituteCallback('CFG', __noopSubst)
404d4609 17utils.addSubstituteCallback('LIBDIRNAME', __noopSubst)
8004cb2b 18utils.addSubstituteCallback('OBJS', __noopSubst)
cff5df9f
VS
19
20
ddf98968
VS
21def mk_wxid(id):
22 """Creates wxWindows library identifier from bakefile target ID that
23 follows this convention: DLLs end with 'dll', static libraries
24 end with 'lib'. If withPrefix=1, then _wxid is returned instead
25 of wxid."""
26 if id.endswith('dll') or id.endswith('lib'):
27 wxid = id[:-3]
28 else:
29 wxid = id
30 return wxid
31
32
3560dc76 33# All libs that are part of the main library (i.e. non-contrib):
83b9886f
VS
34MAIN_LIBS = ['mono', 'base', 'core', 'adv', 'html', 'xml', 'net',
35 'odbc', 'dbgrid']
ddf98968 36# List of library names/ids for categories with different names:
83b9886f
VS
37LIBS_NOGUI = ['xml', 'net', 'odbc']
38LIBS_GUI = ['core', 'adv', 'html', 'gl', 'dbgrid']
ddf98968
VS
39
40def mkLibName(wxid):
41 """Returns string that can be used as library name, including name
42 suffixes, prefixes, version tags etc. This must be kept in sync
43 with variables defined in common.bkl!"""
44 if wxid == 'mono':
ea66c762 45 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
e6978d5b 46 if wxid == 'base':
ea66c762 47 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
e6978d5b 48 if wxid in LIBS_NOGUI:
ea66c762
VS
49 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
50 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
ddf98968
VS
51
52def mkDllName(wxid):
53 """Returns string that can be used as DLL name, including name
54 suffixes, prefixes, version tags etc. This must be kept in sync
55 with variables defined in common.bkl!"""
56 if wxid == 'mono':
4fc5f509 57 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
e6978d5b
VS
58 if wxid == 'base':
59 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
60 if wxid in LIBS_NOGUI:
4fc5f509
VS
61 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
62 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
ddf98968
VS
63
64
65def libToLink(wxlibname):
66 """Returns string to pass to <sys-lib> when linking against 'wxlibname'.
3560dc76
VS
67 For one of main libraries, libToLink('foo') returns '$(WXLIB_FOO)' which
68 must be defined in common.bkl as either nothing (in monolithic build) or
69 mkLibName('foo') (otherwise).
70 For contrib libraries, it returns mkDllName(wxlibname).
71 """
72 if wxlibname in MAIN_LIBS:
73 return '$(WXLIB_%s)' % wxlibname.upper()
74 else:
75 return mkLibName(wxlibname)
ddf98968
VS
76
77
78wxVersion = None
79VERSION_FILE = '../../include/wx/version.h'
80
81def getVersion():
82 """Returns wxWindows version as a tuple: (major,minor,release)."""
83 global wxVersion
84 if wxVersion == None:
85 f = open(VERSION_FILE, 'rt')
86 lines = f.readlines()
87 f.close()
88 major = minor = release = None
89 for l in lines:
90 if not l.startswith('#define'): continue
91 splitted = l.strip().split()
92 if splitted[0] != '#define': continue
93 if len(splitted) < 3: continue
94 name = splitted[1]
95 value = splitted[2]
96 if value == None: continue
97 if name == 'wxMAJOR_VERSION': major = int(value)
98 if name == 'wxMINOR_VERSION': minor = int(value)
99 if name == 'wxRELEASE_NUMBER': release = int(value)
100 if major != None and minor != None and release != None:
101 break
102 wxVersion = (major, minor, release)
103 return wxVersion
104
105def getVersionMajor():
106 return getVersion()[0]
107def getVersionMinor():
108 return getVersion()[1]
109def getVersionRelease():
110 return getVersion()[2]
390c0cfb
VS
111
112
113def headersOnly(files):
114 """Filters 'files' so that only headers are left. Used with
115 <msvc-project-files> to add headers to VC++ projects but not files such
116 as arrimpl.cpp."""
117
118 def callback(cond, sources):
119 prf = suf = ''
120 if sources[0].isspace(): prefix=' '
121 if sources[-1].isspace(): suffix=' '
122 retval = []
123 for s in sources.split():
124 if s.endswith('.h'):
125 retval.append(s)
126 return '%s%s%s' % (prf, ' '.join(retval), suf)
127 return utils.substitute2(files, callback)