]> git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/make_static_setup.py
Missed labels to replace number of 'topicNNN' in anchors. Consistent use of -dtor...
[wxWidgets.git] / wxPython / distrib / make_static_setup.py
1 #!/bin/env python
2 #---------------------------------------------------------------------------
3 # This script generates a template that can be used in the Python
4 # build process (on posix systems) in order to staticly link the
5 # wxPython modules into the Python executable. The output of this
6 # script should be put into a file named Setup.local (or perhaps just
7 # concatenated to Setup) in the Modules dir of the Python source
8 # distribution, then just build Python like normal.
9 #
10 # You can use any of the command-line args that setup.py understands
11 # with this script too in order to control what modules are built and
12 # which compile options and such are used.
13 #
14 # This script must be run from the wxPython directory.
15 #---------------------------------------------------------------------------
16
17
18 import sys, os, re
19
20 # if you need to change some setup.py flags do it here before it is
21 # imported. Just append to sys.argv.
22 sys.argv.append("BUILD_GLCANVAS=0")
23 sys.argv.append("BUILD_OGL=0")
24 sys.argv.append("BUILD_DLLWIDGET=0")
25 #sys.argv.append("CORE_ONLY=1")
26
27 import setup
28
29
30 def printitem(st):
31 if st:
32 print '\\\n\t', st,
33
34
35 def buildflags(items, flag, path=None):
36 st = ''
37 for item in items:
38 if path is not None and item[0] != '/':
39 item = os.path.join(path, item)
40 st += "%s%s " % (flag, item)
41 return st
42
43
44 def buildmacros(items):
45 st = ''
46 for item in items:
47 if len(item) == 1:
48 st += "-U%s " % item[0]
49 elif item[1] is None:
50 st += "-D%s " % item[0]
51 else:
52 st += "-D%s=%s " % item
53 return st
54
55
56 # Python's makesetup can't handle -D flags with = in them, so we need to workaround
57 def fixmacros(st):
58 defs = []
59 pat = re.compile(r'-D([A-Za-z0-9_]*)=([A-Za-z0-9_]*)')
60 match = pat.search(st)
61 while match is not None:
62 name = match.group(1)
63 value = match.group(2)
64 defs.append("m_%s = -D%s=%s" % (name, name, value))
65 st = st[:match.start()] + ("$(m_%s)" % name) + st[match.end():]
66 match = pat.search(st)
67
68 return st, defs
69
70
71
72 def main():
73 cwd = os.getcwd()
74
75 print """\
76 # This file is autogenerated by %s and should be
77 # placed in the <PythonDist>/Modules/Setup.local file before
78 # Python is built.
79
80 *static*
81
82 """ % sys.argv[0]
83
84 for ext in setup.wxpExtensions:
85 eca = " ".join(ext.extra_compile_args)
86 macros = buildmacros(ext.define_macros)
87
88 eca, defs = fixmacros(eca)
89 print "\n".join(defs)
90 macros, defs = fixmacros(macros)
91 print "\n".join(defs)
92
93 print ext.name,
94 for s in ext.sources:
95 printitem(os.path.join(cwd, s))
96 printitem(buildflags(ext.include_dirs, '-I', cwd))
97 printitem(buildflags(ext.library_dirs, '-L'))
98 printitem(buildflags(ext.libraries, '-l'))
99 printitem(macros)
100 printitem(eca)
101 # filter out some options that makesetup can't handle, but it shouldn't hurt to remove these...
102 ela = filter(lambda x: x not in ['-pthread', '-rdynamic'], ext.extra_link_args)
103 printitem(" ".join(ela))
104
105 print; print; print
106
107
108
109 if __name__ == "__main__":
110 main()
111