]>
git.saurik.com Git - wxWidgets.git/blob - build/bakefiles/wxwin.py
2 # Helper functions for wxWidgets bakefiles
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):
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
):
20 except AttributeError:
21 def __noopSubst(func
, name
):
23 utils
.addSubstituteCallback('CFG', __noopSubst
)
24 utils
.addSubstituteCallback('LIBDIRNAME', __noopSubst
)
25 utils
.addSubstituteCallback('SETUPHDIR', __noopSubst
)
26 utils
.addSubstituteCallback('OBJS', __noopSubst
)
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
34 if id.endswith('dll') or id.endswith('lib'):
41 # All libs that are part of the main library:
42 MAIN_LIBS
= ['mono', 'base', 'core', 'adv', 'html', 'xml', 'net', 'web',
43 'media', 'qa', 'xrc', 'aui', 'ribbon', 'propgrid', 'richtext', 'stc']
44 # List of library names/ids for categories with different names:
45 LIBS_NOGUI
= ['xml', 'net']
46 LIBS_GUI
= ['core', 'adv', 'html', 'gl', 'qa', 'xrc', 'media',
47 'aui', 'propgrid', 'richtext', 'stc', 'ribbon', 'web']
48 # Additional libraries that must be linked in:
50 'gl' : '$(EXTRALIBS_OPENGL)',
51 'xml' : '$(EXTRALIBS_XML)',
52 'html' : '$(EXTRALIBS_HTML)',
53 'adv' : '$(PLUGIN_ADV_EXTRALIBS)',
54 'media' : '$(EXTRALIBS_MEDIA)',
55 'web' : '$(EXTRALIBS_WEB)',
59 """Returns string that can be used as library name, including name
60 suffixes, prefixes, version tags etc. This must be kept in sync
61 with variables defined in common.bkl!"""
63 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
65 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
66 if wxid
in LIBS_NOGUI
:
67 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
68 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
71 """Returns string that can be used as DLL name, including name
72 suffixes, prefixes, version tags etc. This must be kept in sync
73 with variables defined in common.bkl!"""
75 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
77 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
78 if wxid
in LIBS_NOGUI
:
79 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
80 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
83 def libToLink(wxlibname
):
84 """Returns string to pass to <sys-lib> when linking against 'wxlibname'.
85 For one of main libraries, libToLink('foo') returns '$(WXLIB_FOO)' which
86 must be defined in common.bkl as either nothing (in monolithic build) or
87 mkLibName('foo') (otherwise).
89 if wxlibname
in MAIN_LIBS
:
90 return '$(WXLIB_%s)' % wxlibname
.upper()
92 return mkLibName(wxlibname
)
95 def extraLdflags(wxlibname
):
96 if wxlibname
in EXTRALIBS
:
97 return EXTRALIBS
[wxlibname
]
102 VERSION_FILE
= '../../include/wx/version.h'
105 """Returns wxWidgets version as a tuple: (major,minor,release)."""
107 if wxVersion
== None:
108 f
= open(VERSION_FILE
, 'rt')
109 lines
= f
.readlines()
111 major
= minor
= release
= None
113 if not l
.startswith('#define'): continue
114 splitline
= l
.strip().split()
115 if splitline
[0] != '#define': continue
116 if len(splitline
) < 3: continue
119 if value
== None: continue
120 if name
== 'wxMAJOR_VERSION': major
= int(value
)
121 if name
== 'wxMINOR_VERSION': minor
= int(value
)
122 if name
== 'wxRELEASE_NUMBER': release
= int(value
)
123 if major
!= None and minor
!= None and release
!= None:
125 wxVersion
= (major
, minor
, release
)
128 def getVersionMajor():
129 return getVersion()[0]
130 def getVersionMinor():
131 return getVersion()[1]
132 def getVersionRelease():
133 return getVersion()[2]
136 def headersOnly(files
):
137 """Filters 'files' so that only headers are left. Used with
138 <msvc-project-files> to add headers to VC++ projects but not files such
141 def callback(cond
, sources
):
143 if sources
[0].isspace(): prf
=' '
144 if sources
[-1].isspace(): suf
=' '
146 for s
in sources
.split():
149 return '%s%s%s' % (prf
, ' '.join(retval
), suf
)
150 return utils
.substitute2(files
, callback
)
153 def makeDspDependency(lib
):
154 """Returns suitable entry for <depends-on-dsp> for main libs."""
155 return '%s:$(nativePaths(WXTOPDIR))build\\msw\\wx_%s.dsp' % (lib
,lib
)