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