def patched(self, project_dir, spec, sack): f = NamedTemporaryFile(delete=False, prefix="rpg_plugin_c_") file_name = f.name f.close() out = Command(["find " + str(project_dir) + " -name *.c -o -name *.h"]).execute() files_list = [str(s) for s in out.splitlines()] makedepend = "makedepend -w10000 -f" + file_name + " -I" \ + str(project_dir) + " " + \ ' '.join(files_list) + " 2>/dev/null" Command(makedepend).execute() regex = compile(r'.*\.h') regex2 = compile(str(project_dir) + ".*") unlink(file_name + ".bak") with open(file_name, "r") as f: _ret_paths = set([path.dirname(s) for s in f.read().split() if regex.match(s) and not regex2.match(s)]) unlink(file_name) spec.required_files = spec.required_files.union(_ret_paths) spec.build_required_files = spec.build_required_files.union(_ret_paths)
def patched(self, project_dir, spec, sack): """ Finds dependencies via makedepend - This is not garanteed to be all of them. Makedepend uses macro preprocessor and if it throws and error makedepend didn't print deps. """ out = Command([ "find " + path_to_str(project_dir) + " -name " + " -o -name ".join( ["'*." + ex + "'" for ex in self.EXT_CPP] ) ]).execute() cc_makedep = "" cc_included_files = [] for _f in out.splitlines(): try: cc_makedep = Command("makedepend -w 1000 " + str(_f) + " -f- 2>/dev/null").execute() except CalledProcessError as e: logging.warn(str(e.cmd) + "\n" + str(e.output)) continue cc_included_files += [ s for s in cc_makedep.split() if (s.startswith("/usr") or s.startswith("/include")) and str(project_dir) not in s] spec.required_files.update(cc_included_files) spec.build_required_files.update(cc_included_files)
def patched(self, project_dir, spec, sack): out = Command([ "find " + path_to_str(project_dir) + " -name " + " -o -name ".join(["'*." + ex + "'" for ex in self.EXT_CPP]) ]).execute() cc_makedep = "" cc_included_files = [] for _f in out.splitlines(): try: cc_makedep = Command("makedepend -w 1000 " + str(_f) + " -f- 2>/dev/null").execute() except CalledProcessError as e: logging.warn(str(e.cmd) + "\n" + str(e.output)) continue cc_included_files += [ s for s in cc_makedep.split() if (s.startswith("/usr") or s.startswith("/include")) and str(project_dir) not in s ] spec.required_files.update(cc_included_files) spec.build_required_files.update(cc_included_files)
def patched(self, project_dir, spec, sack): out = Command([ "find " + path_to_str(project_dir) + " -name " + " -o -name ".join( ["'*." + ex + "'" for ex in self.EXT_CPP] ) ]).execute() cc_makedep = "" cc_included_files = [] for _f in out.splitlines(): try: cc_makedep = Command("makedepend -w 1000 " + str(_f) + " -f- 2>/dev/null").execute() except CalledProcessError as e: logging.warn(str(e.cmd) + "\n" + str(e.output)) continue cc_included_files += [ s for s in cc_makedep.split() if (s.startswith("/usr") or s.startswith("/include")) and str(project_dir) not in s] spec.required_files.update(cc_included_files) spec.build_required_files.update(cc_included_files)
def patched(self, project_dir, spec, sack): """ Finds dependencies via makedepend - This is not garanteed to be all of them. Makedepend uses macro preprocessor and if it throws and error makedepend didn't print deps. """ out = Command([ "find " + path_to_str(project_dir) + " -name " + " -o -name ".join(["'*." + ex + "'" for ex in self.EXT_CPP]) ]).execute() cc_makedep = "" cc_included_files = [] for _f in out.splitlines(): try: cc_makedep = Command("makedepend -w 1000 " + str(_f) + " -f- 2>/dev/null").execute() except CalledProcessError as e: logging.warn(str(e.cmd) + "\n" + str(e.output)) continue cc_included_files += [ s for s in cc_makedep.split() if (s.startswith("/usr") or s.startswith("/include")) and str(project_dir) not in s ] spec.required_files.update(cc_included_files) spec.build_required_files.update(cc_included_files)