diff options
author | Greg Ward <gward@python.net> | 2000-06-27 01:21:22 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-06-27 01:21:22 (GMT) |
commit | 855dab99875e733c858bf55e2adc27d3d0234c9a (patch) | |
tree | b658815c819d8bfcadf5d6d00fedf5872c7ce9dd /Lib | |
parent | e8d7dbfe420f0fa72e4d2b6a34d59b81326c1e4a (diff) | |
download | cpython-855dab99875e733c858bf55e2adc27d3d0234c9a.zip cpython-855dab99875e733c858bf55e2adc27d3d0234c9a.tar.gz cpython-855dab99875e733c858bf55e2adc27d3d0234c9a.tar.bz2 |
Added 'include_dirs' parameters all over the place.
Added 'check_lib()', which provides a subset of the functionality of
'check_func()' with a simpler interface and implementation.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/distutils/command/config.py | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py index 570f71a..5c3f26a 100644 --- a/Lib/distutils/command/config.py +++ b/Lib/distutils/command/config.py @@ -112,24 +112,26 @@ class config (Command): file.close() return filename - def _preprocess (self, body, headers, lang): + def _preprocess (self, body, headers, include_dirs, lang): src = self._gen_temp_sourcefile(body, headers, lang) out = "_configtest.i" self.temp_files.extend([src, out]) - self.compiler.preprocess(src, out) + self.compiler.preprocess(src, out, include_dirs=include_dirs) return (src, out) - def _compile (self, body, headers, lang): + def _compile (self, body, headers, include_dirs, lang): src = self._gen_temp_sourcefile(body, headers, lang) if self.dump_source: dump_file(src, "compiling '%s':" % src) (obj,) = self.compiler.object_filenames([src]) self.temp_files.extend([src, obj]) - self.compiler.compile([src]) + self.compiler.compile([src], include_dirs=include_dirs) return (src, obj) - def _link (self, body, headers, libraries, library_dirs, lang): - (src, obj) = self._compile(body, headers, lang) + def _link (self, body, + headers, include_dirs, + libraries, library_dirs, lang): + (src, obj) = self._compile(body, headers, include_dirs, lang) prog = os.path.splitext(os.path.basename(src))[0] self.temp_files.append(prog) # XXX should be prog + exe_ext self.compiler.link_executable([obj], prog, @@ -159,7 +161,7 @@ class config (Command): # XXX need access to the header search path and maybe default macros. - def try_cpp (self, body=None, headers=None, lang="c"): + def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) and run it through the preprocessor. Return true if the @@ -177,7 +179,8 @@ class config (Command): self._clean() return ok - def search_cpp (self, pattern, body=None, headers=None, lang="c"): + def search_cpp (self, pattern, body=None, + headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex object or a @@ -206,7 +209,7 @@ class config (Command): self._clean() return match - def try_compile (self, body, headers=None, lang="c"): + def try_compile (self, body, headers=None, include_dirs=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. """ @@ -222,8 +225,8 @@ class config (Command): self._clean() return ok - def try_link (self, - body, headers=None, + def try_link (self, body, + headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): """Try to compile and link a source file, built from 'body' and @@ -233,7 +236,8 @@ class config (Command): from distutils.ccompiler import CompileError, LinkError self._check_compiler() try: - self._link(body, headers, libraries, library_dirs, lang) + self._link(body, headers, include_dirs, + libraries, library_dirs, lang) ok = 1 except (CompileError, LinkError): ok = 0 @@ -242,8 +246,8 @@ class config (Command): self._clean() return ok - def try_run (self, - body, headers=None, + def try_run (self, body, + headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): """Try to compile, link to an executable, and run a program @@ -253,7 +257,8 @@ class config (Command): from distutils.ccompiler import CompileError, LinkError self._check_compiler() try: - self._link(body, headers, libraries, library_dirs, lang) + self._link(body, headers, include_dirs, + libraries, library_dirs, lang) self.spawn([exe]) ok = 1 except (CompileError, LinkError, DistutilsExecError): @@ -268,7 +273,8 @@ class config (Command): # (these are the ones that are actually likely to be useful # when implementing a real-world config command!) - def check_func (self, func, headers=None, + def check_func (self, func, + headers=None, include_dirs=None, libraries=None, library_dirs=None, decl=0, call=0): @@ -298,16 +304,30 @@ class config (Command): body.append("}") body = string.join(body, "\n") + "\n" - return self.try_link(body, headers, libraries, library_dirs) + return self.try_link(body, headers, include_dirs, + libraries, library_dirs) # check_func () - def check_header (self, header, lang="c"): + def check_lib (self, library, library_dirs=None, + headers=None, include_dirs=None): + """Determine if 'library' is available to be linked against, + without actually checking that any particular symbols are provided + by it. 'headers' will be used in constructing the source file to + be compiled, but the only effect of this is to check if all the + header files listed are available. + """ + self._check_compiler() + return self.try_link("int main (void) { }", + headers, include_dirs, [library], library_dirs) + + def check_header (self, header, include_dirs=None, + library_dirs=None, lang="c"): """Determine if the system header file named by 'header_file' exists and can be found by the preprocessor; return true if so, false otherwise. """ - return self.try_cpp(headers=[header]) + return self.try_cpp(headers=[header], include_dirs=include_dirs) # class config |