def build_object(self, target_name, out_filename, in_filename, include_dirs, compiler_flags): ui.debug("building object " + out_filename) with ui.ident: prerequisites = self.__fetch_includes(target_name, in_filename, include_dirs, compiler_flags) prerequisites.append(in_filename) ui.debug("appending prerequisites from pake modules: {!s}".format( fsutils.pake_files)) prerequisites.extend(fsutils.pake_files) ui.debug("prerequisites: {!r}".format(prerequisites)) if fsutils.is_any_newer_than(prerequisites, out_filename): fsutils.mkdir_recursive(os.path.dirname(out_filename)) cmd = configurations.compiler( ) + " " + self.__prepare_compiler_flags( include_dirs, compiler_flags ) + " -c -o " + out_filename + " " + in_filename if command_line.args.verbose: ui.step(configurations.compiler(), cmd) else: ui.step(configurations.compiler(), in_filename) shell.execute(cmd)
def build_object(self, target_name, out_filename, in_filename, include_dirs, compiler_flags): abs_source = os.path.join(os.getcwd(), in_filename) ui.debug("building object " + out_filename) with ui.ident: prerequisites = self.__fetch_includes(target_name, abs_source, include_dirs, compiler_flags) prerequisites.append(in_filename) ui.debug("appending prerequisites from pake modules: {!s}" .format(fsutils.pake_files)) prerequisites.extend(fsutils.pake_files) ui.debug("prerequisites: {!r}".format(prerequisites)) if fsutils.is_any_newer_than(prerequisites, out_filename): fsutils.mkdir_recursive(os.path.dirname(out_filename)); cmd = configurations.compiler() + " " + self.__prepare_compiler_flags(include_dirs, compiler_flags) + " -c -o " + out_filename + " " + abs_source if command_line.args.verbose: ui.step(configurations.compiler(), cmd) else: ui.step(configurations.compiler(), in_filename) shell.execute(cmd)
def link_application(self, out_filename, in_filenames, link_with, library_dirs): if fsutils.is_any_newer_than( in_filenames, out_filename) or self.__are_libs_newer_than_target( link_with, out_filename): ui.debug("linking application") ui.debug(" files: " + str(in_filenames)) ui.debug(" with libs: " + str(link_with)) ui.debug(" lib dirs: " + str(library_dirs)) parameters = " ".join("-L " + lib_dir for lib_dir in library_dirs) ui.bigstep("linking", out_filename) try: shell.execute(" ".join([ configurations.compiler(), configurations.linker_flags(), "-o", out_filename, " ".join(in_filenames), self.__prepare_linker_flags(link_with), parameters ])) except Exception as e: ui.fatal("cannot link {}, reason: {!s}".format( out_filename, e)) else: ui.bigstep("up to date", out_filename)
def __scan_includes(self, in_filename, include_dirs, compiler_flags): ui.debug("scanning includes for " + in_filename) try: flags = self.__prepare_compiler_flags(include_dirs, compiler_flags) out = shell.execute(" ".join( [configurations.compiler(), flags, "-M", in_filename]), capture_output=True).split() except Exception as e: raise Exception("error while building dependency graph for" "{!s}, {!s}".format(in_filename, e)) return [token for token in out[2:] if not token == "\\"]
def __scan_includes(self, in_filename, include_dirs, compiler_flags): ui.debug("scanning includes for " + in_filename) try: flags = self.__prepare_compiler_flags(include_dirs, compiler_flags) out = shell.execute(" ".join([configurations.compiler(), flags, "-M", in_filename]), capture_output=True).split() except Exception as e: raise Exception("error while building dependency graph for" "{!s}, {!s}".format(in_filename, e)) def is_system_include(filename): return filename.startswith("/usr/include") or filename.startswith("/usr/lib") return [token for token in out[2:] if not token == "\\" and not is_system_include(token)]
def link_application(self, out_filename, in_filenames, link_with, library_dirs): if fsutils.is_any_newer_than(in_filenames, out_filename) or self.__are_libs_newer_than_target(link_with, out_filename): ui.debug("linking application") ui.debug(" files: " + str(in_filenames)) ui.debug(" with libs: " + str(link_with)) ui.debug(" lib dirs: " + str(library_dirs)) parameters = " ".join("-L " + lib_dir for lib_dir in library_dirs) ui.bigstep("linking", out_filename) try: shell.execute(" ".join([configurations.compiler(), configurations.linker_flags(), "-o", out_filename, " ".join(in_filenames), self.__prepare_linker_flags(link_with), parameters])) except Exception as e: ui.fatal("cannot link {}, reason: {!s}".format(out_filename, e)) else: ui.bigstep("up to date", out_filename)