]>
git.saurik.com Git - wxWidgets.git/blob - build/bakefiles/wxwin.py
2 # Helper functions for wxWindows 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):
14 def __noopSubst(func
, name
):
16 utils
.addSubstituteCallback('CFG', __noopSubst
)
17 utils
.addSubstituteCallback('LIBDIRNAME', __noopSubst
)
18 utils
.addSubstituteCallback('SETUPHDIR', __noopSubst
)
19 utils
.addSubstituteCallback('OBJS', __noopSubst
)
23 """Creates wxWindows library identifier from bakefile target ID that
24 follows this convention: DLLs end with 'dll', static libraries
25 end with 'lib'. If withPrefix=1, then _wxid is returned instead
27 if id.endswith('dll') or id.endswith('lib'):
34 # All libs that are part of the main library (i.e. non-contrib):
35 MAIN_LIBS
= ['mono', 'base', 'core', 'adv', 'html', 'xml', 'net',
37 # List of library names/ids for categories with different names:
38 LIBS_NOGUI
= ['xml', 'net', 'odbc']
39 LIBS_GUI
= ['core', 'adv', 'html', 'gl', 'dbgrid']
40 # Additional libraries that must be linked in:
42 'gl' : '$(EXTRALIBS_OPENGL)',
43 'xml' : '$(EXTRALIBS_XML)',
44 'html' : '$(EXTRALIBS_HTML)',
45 'odbc' : '$(EXTRALIBS_ODBC)',
46 'adv' : '$(PLUGIN_ADV_EXTRALIBS)',
50 """Returns string that can be used as library name, including name
51 suffixes, prefixes, version tags etc. This must be kept in sync
52 with variables defined in common.bkl!"""
54 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
56 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)$(WXVERSIONTAG)$(HOST_SUFFIX)'
57 if wxid
in LIBS_NOGUI
:
58 return '$(WXNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
59 return '$(WXNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXVERSIONTAG)$(HOST_SUFFIX)' % wxid
62 """Returns string that can be used as DLL name, including name
63 suffixes, prefixes, version tags etc. This must be kept in sync
64 with variables defined in common.bkl!"""
66 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
68 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)'
69 if wxid
in LIBS_NOGUI
:
70 return '$(WXDLLNAMEPREFIX)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
71 return '$(WXDLLNAMEPREFIXGUI)$(WXNAMESUFFIX)_%s$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)' % wxid
74 def libToLink(wxlibname
):
75 """Returns string to pass to <sys-lib> when linking against 'wxlibname'.
76 For one of main libraries, libToLink('foo') returns '$(WXLIB_FOO)' which
77 must be defined in common.bkl as either nothing (in monolithic build) or
78 mkLibName('foo') (otherwise).
79 For contrib libraries, it returns mkDllName(wxlibname).
81 if wxlibname
in MAIN_LIBS
:
82 return '$(WXLIB_%s)' % wxlibname
.upper()
84 return mkLibName(wxlibname
)
86 def extraLdflags(wxlibname
):
87 if wxlibname
in EXTRALIBS
:
88 return EXTRALIBS
[wxlibname
]
93 VERSION_FILE
= '../../include/wx/version.h'
96 """Returns wxWindows version as a tuple: (major,minor,release)."""
99 f
= open(VERSION_FILE
, 'rt')
100 lines
= f
.readlines()
102 major
= minor
= release
= None
104 if not l
.startswith('#define'): continue
105 splitted
= l
.strip().split()
106 if splitted
[0] != '#define': continue
107 if len(splitted
) < 3: continue
110 if value
== None: continue
111 if name
== 'wxMAJOR_VERSION': major
= int(value
)
112 if name
== 'wxMINOR_VERSION': minor
= int(value
)
113 if name
== 'wxRELEASE_NUMBER': release
= int(value
)
114 if major
!= None and minor
!= None and release
!= None:
116 wxVersion
= (major
, minor
, release
)
119 def getVersionMajor():
120 return getVersion()[0]
121 def getVersionMinor():
122 return getVersion()[1]
123 def getVersionRelease():
124 return getVersion()[2]
127 def headersOnly(files
):
128 """Filters 'files' so that only headers are left. Used with
129 <msvc-project-files> to add headers to VC++ projects but not files such
132 def callback(cond
, sources
):
134 if sources
[0].isspace(): prf
=' '
135 if sources
[-1].isspace(): suf
=' '
137 for s
in sources
.split():
140 return '%s%s%s' % (prf
, ' '.join(retval
), suf
)
141 return utils
.substitute2(files
, callback
)
144 def makeDspDependency(lib
):
145 """Returns suitable entry for <depends-on-dsp> for main libs."""
146 return '%s:$(nativePaths(WXTOPDIR))build\\msw\\wx_%s.dsp' % (lib
,lib
)