Beispiel #1
0
 def c_compile(self,
               c_file,
               verbose_flag=0,
               cplus=0,
               obj_suffix=".o",
               use_timestamps=0,
               options=None):
     #  Compile the given C source file to produce
     #  an object file. Returns the pathname of the
     #  resulting file.
     c_file = os.path.join(os.getcwd(), c_file)
     o_file = replace_suffix(c_file, obj_suffix)
     if use_timestamps and not file_newer_than_file(c_file, o_file):
         return
     include_dirs = []
     if options:
         include_dirs.extend(options.include_path)
     include_dirs.extend(py_include_dirs)
     include_options = ["-I%s" % dir for dir in include_dirs]
     compiler = self.compilers[bool(cplus)]
     args = [compiler] + self.compiler_options + include_options \
      + [c_file, "-o", o_file]
     if verbose_flag or self.verbose:
         print " ".join(args)
     status = os.spawnvp(os.P_WAIT, compiler, args)
     if status <> 0:
         raise CCompilerError("C compiler returned status %s" % status)
     return o_file
Beispiel #2
0
 def c_link_list(self, obj_files, verbose_flag=0, cplus=0, use_timestamps=0, options=None):
     #  Link the given object files into a dynamically
     #  loadable extension file. Returns the pathname
     #  of the resulting file.
     in_file = obj_files[0]
     out_file = replace_suffix(in_file, ".so")
     if use_timestamps and not file_newer_than_file(in_file, out_file):
         return
     linker = self.linkers[bool(cplus)]
     args = [linker] + self.get_linker_options(options) + obj_files + self.get_libraries(options) + ["-o", out_file]
     if verbose_flag or self.verbose:
         print " ".join(args)
     status = os.spawnvp(os.P_WAIT, linker, args)
     if status <> 0:
         raise CCompilerError("Linker returned status %s" % status)
     return out_file
Beispiel #3
0
 def c_compile(self, c_file, verbose_flag=0, cplus=0, obj_suffix=".o", use_timestamps=0, options=None):
     #  Compile the given C source file to produce
     #  an object file. Returns the pathname of the
     #  resulting file.
     c_file = os.path.join(os.getcwd(), c_file)
     o_file = replace_suffix(c_file, obj_suffix)
     if use_timestamps and not file_newer_than_file(c_file, o_file):
         return
     include_dirs = []
     if options:
         include_dirs.extend(options.include_path)
     include_dirs.extend(py_include_dirs)
     include_options = ["-I%s" % dir for dir in include_dirs]
     compiler = self.compilers[bool(cplus)]
     args = [compiler] + self.compiler_options + include_options + [c_file, "-o", o_file]
     if verbose_flag or self.verbose:
         print " ".join(args)
     status = os.spawnvp(os.P_WAIT, compiler, args)
     if status <> 0:
         raise CCompilerError("C compiler returned status %s" % status)
     return o_file
Beispiel #4
0
 def c_link_list(self,
                 obj_files,
                 verbose_flag=0,
                 cplus=0,
                 use_timestamps=0,
                 options=None):
     #  Link the given object files into a dynamically
     #  loadable extension file. Returns the pathname
     #  of the resulting file.
     in_file = obj_files[0]
     out_file = replace_suffix(in_file, ".so")
     if use_timestamps and not file_newer_than_file(in_file, out_file):
         return
     linker = self.linkers[bool(cplus)]
     args = [linker] + self.get_linker_options(options) + obj_files \
      + self.get_libraries(options) + ["-o", out_file]
     if verbose_flag or self.verbose:
         print " ".join(args)
     status = os.spawnvp(os.P_WAIT, linker, args)
     if status <> 0:
         raise CCompilerError("Linker returned status %s" % status)
     return out_file