summaryrefslogtreecommitdiff
path: root/numpy/distutils/command/config.py
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2008-09-05 06:11:26 +0000
committerDavid Cournapeau <cournape@gmail.com>2008-09-05 06:11:26 +0000
commit12becb0c6742ab716e9ed812d1a7effca7a8fe2c (patch)
tree001b29b7b45ceb8e2e0dbe3d55b6176b78eb9b7d /numpy/distutils/command/config.py
parente7ed47c36a1161555a2d3a36fbcfc3e89b9acda0 (diff)
downloadnumpy-12becb0c6742ab716e9ed812d1a7effca7a8fe2c.tar.gz
Add a check_funcs_once function to speed up func checks.
Diffstat (limited to 'numpy/distutils/command/config.py')
-rw-r--r--numpy/distutils/command/config.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py
index ce42a36e0..bfc3a20e9 100644
--- a/numpy/distutils/command/config.py
+++ b/numpy/distutils/command/config.py
@@ -140,6 +140,61 @@ int main()
return self.try_link(body, headers, include_dirs,
libraries, library_dirs)
+ def check_funcs_once(self, funcs,
+ headers=None, include_dirs=None,
+ libraries=None, library_dirs=None,
+ decl=False, call=False, call_args=None):
+ """Check a list of functions at once.
+
+ This is useful to speed up things, since all the functions in the funcs
+ list will be put in one compilation unit.
+
+ Arguments
+ ---------
+
+ funcs: seq
+ list of functions to test
+ include_dirs : seq
+ list of header paths
+ libraries : seq
+ list of libraries to link the code snippet to
+ libraru_dirs : seq
+ list of library paths
+ decl : dict
+ for every (key, value), the declaration in the value will be
+ used for function in key. If a function is not in the
+ dictionay, no declaration will be used.
+ call : dict
+ for every item (f, value), if the value is True, a call will be
+ done to the function f"""
+ self._check_compiler()
+ body = []
+ if decl:
+ for f, v in decl.items():
+ if v:
+ body.append("int %s ();" % f)
+
+ body.append("int main (void) {")
+ if call:
+ for f in funcs:
+ if call.has_key(f) and call[f]:
+ if not (call_args and call_args.has_key(f) and call_args[f]):
+ args = ''
+ else:
+ args = call_args[f]
+ body.append(" %s(%s);" % (f, args))
+ else:
+ body.append(" %s;" % f)
+ else:
+ for f in funcs:
+ body.append(" %s;" % f)
+ body.append(" return 0;")
+ body.append("}")
+ body = '\n'.join(body) + "\n"
+
+ return self.try_link(body, headers, include_dirs,
+ libraries, library_dirs)
+
def get_output(self, body, headers=None, include_dirs=None,
libraries=None, library_dirs=None,
lang="c"):