Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 113 lines (94 sloc) 3.258 kb
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
1 import sys
2
3 from numpy.distutils.misc_util \
4 import \
5 get_numpy_include_dirs
6 from numpy.distutils.conv_template \
7 import \
8 process_str as process_c_str
9
10 from bento.commands import hooks
11 from bento.commands.extras.waf \
12 import \
13 ConfigureWafContext, BuildWafContext, register_options
14
15 import waflib
16 from waflib import Options
17
18 # FIXME: add this to numpy so that we can reuse it
19 class CTemplateTask(waflib.Task.Task):
20 color = 'BLUE'
21 before = ['c']
22 def run(self):
23 s = self.inputs[0]
24 cnt = s.read()
25 writestr = process_c_str(cnt)
26 o = self.outputs[0]
27 o.write(writestr)
28
29 @waflib.TaskGen.feature("c_template")
30 @waflib.TaskGen.extension(".src")
31 def c_template(self, node):
32 outs = []
33 outs.append(node.change_ext(""))
34
35 tsk = self.create_task('CTemplateTask', node, outs)
36 if "c" in self.features:
37 self.source.append(outs[0])
38
39 @hooks.startup
40 def startup(context):
41 context.register_context("configure", ConfigureWafContext)
42 context.register_context("build", BuildWafContext)
43
44 @hooks.options
45 def options(context):
46 register_options(context)
47
48 @hooks.pre_configure()
49 def pre_configure(context):
50 opts = context.waf_options_context
51 opts.load("compiler_fc")
52 opts.load("f2py")
53 Options.options.check_fc = "gfortran"
54
55 conf = context.waf_context
56 conf.load("compiler_fc")
57 conf.load("f2py")
58
59 def remove_flag(name, flag):
60 while True:
61 if name in flag:
62 i = flag.index(name)
63 flag.pop(i)
64 else:
65 break
66
67 def remove_flag_postvalue(name, flag):
68 while True:
69 if name in flag:
70 i = flag.index(name)
71 flag.pop(i)
72 flag.pop(i)
73 else:
74 break
75
76 def remove_flag_prevalue(name, flag):
77 while True:
78 if name in flag:
79 i = flag.index(name)
80 flag.pop(i-1)
81 flag.pop(i-1)
82 else:
83 break
84
85 @hooks.post_configure()
86 def post_configure(context):
87 conf = context.waf_context
88
89 conf.env.INCLUDES = get_numpy_include_dirs()
90
91 cflags_pyext = conf.env.CFLAGS_PYEXT
92 cflags_pyext.append("-Wfatal-errors")
93 conf.env.CFLAGS_PYEXT = cflags_pyext
94
95 if sys.platform == "darwin":
96 # FIXME: fix upstream waf tool to work on mac os X
97 conf.env.CC = ["/usr/bin/gcc-4.0"]
98 conf.env.LINK_CC = ["/usr/bin/gcc-4.0"]
99 # FIXME: fix upstream waf tool to avoid linking against libpython2.6.so
100 # (cause crashes when importing the extension)
101 name = "python%s" % ".".join([str(i) for i in sys.version_info[:2]])
102 remove_flag(name, conf.env.LIB_PYEXT)
103 remove_flag("-dynamiclib", conf.env.LINKFLAGS_cshlib)
104 remove_flag_postvalue("-compatibility_version", conf.env.CFLAGS_cshlib)
105 remove_flag_postvalue("-current_version", conf.env.CFLAGS_cshlib)
106 for flag in [conf.env.CFLAGS_PYEXT, conf.env.LINKFLAGS_PYEXT,
107 conf.env.CXXFLAGS_PYEXT, conf.env.FCFLAGS]:
108 remove_flag_prevalue("ppc", flag)
109 conf.env.LINKFLAGS_cshlib.extend(["-undefined", "dynamic_lookup", "-bundle"])
110 conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
111
112 conf.env.MACOSX_DEPLOYMENT_TARGET = "10.4"
Something went wrong with that request. Please try again.