]> git.saurik.com Git - wxWidgets.git/blame_incremental - build/bakefiles/wxwin.py
Laid groundwork for scrolling.
[wxWidgets.git] / build / bakefiles / wxwin.py
... / ...
CommitLineData
1#
2# Helper functions for wxWindows 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):
14def __noopSubst(func, name):
15 return '$(%s)' % name
16utils.addSubstituteCallback('CFG', __noopSubst)
17utils.addSubstituteCallback('LIBDIRNAME', __noopSubst)
18utils.addSubstituteCallback('OBJS', __noopSubst)
19
20
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
33# All libs that are part of the main library (i.e. non-contrib):
34MAIN_LIBS = ['mono', 'base', 'core', 'adv', 'html', 'xml', 'net',
35 'odbc', 'dbgrid']
36# List of library names/ids for categories with different names:
37LIBS_NOGUI = ['xml', 'net', 'odbc']
38LIBS_GUI = ['core', 'adv', 'html', 'gl', 'dbgrid']
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':
45 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
46 if wxid == 'base':
47 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
48 if wxid in LIBS_NOGUI:
49 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
50 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
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':
57 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
58 if wxid == 'base':
59 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
60 if wxid in LIBS_NOGUI:
61 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
62 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
63
64
65def libToLink(wxlibname):
66 """Returns string to pass to <sys-lib> when linking against 'wxlibname'.
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)
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]
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)