def link_extension(self, ext_file, object_files, debug=False): cc_cmdline = (self._cmdline(object_files, False) + ["-o", ext_file]) from pytools.prefork import call if debug: print(" ".join(cc_cmdline)) result = call(cc_cmdline) if result != 0: import sys print("FAILED compiler invocation:" + " ".join(cc_cmdline), file=sys.stderr) raise CompileError("module compilation failed")
def get_dependencies(self, source_files): from codepy.tools import join_continued_lines result, stdout, stderr = call_capture_output( [self.cc] + ["-M"] + ["-D%s" % define for define in self.defines] + ["-U%s" % undefine for undefine in self.undefines] + ["-I%s" % idir for idir in self.include_dirs] + self.cflags + source_files) if result != 0: raise CompileError("getting dependencies failed: " + stderr) lines = join_continued_lines(stdout.split("\n")) from pytools import flatten return set(flatten(line.split()[2:] for line in lines))
def build_object(self, ext_file, source_files, debug=False): cc_cmdline = ( self._cmdline(source_files, True) + ["-o", ext_file] ) from pytools.prefork import call if debug: print(" ".join(cc_cmdline)) result = call(cc_cmdline) if result != 0: import sys print("FAILED compiler invocation: {}".format(" ".join(cc_cmdline)), file=sys.stderr) raise CompileError("module compilation failed")
def build_object(self, ext_file, source_files, debug=False): cc_cmdline = (self._cmdline(source_files, True) + ["-o", ext_file]) if debug: print(" ".join(cc_cmdline)) result, stdout, stderr = call_capture_output(cc_cmdline) print(stderr) print(stdout) if "error" in stderr: # work around a bug in nvcc, which doesn't provide a non-zero # return code even if it failed. result = 1 if result != 0: import sys print("FAILED compiler invocation:" + " ".join(cc_cmdline), file=sys.stderr) raise CompileError("module compilation failed")
def get_dependencies(self, source_files): from codepy.tools import join_continued_lines result, stdout, stderr = call_capture_output( [self.cc] + ["-M"] + [f"-D{define}" for define in self.defines] + [f"-U{undefine}" for undefine in self.undefines] + [f"-I{idir}" for idir in self.include_dirs] + self.cflags + source_files ) if result != 0: raise CompileError(f"getting dependencies failed: {stderr}") lines = join_continued_lines(stdout.split("\n")) lines = [line for line in lines if not (line.strip() and line.strip()[0] == "#")] from pytools import flatten return set(flatten( line.split()[2:] for line in lines))