def should_rebuild_dependency(self, dep: Dependency) -> bool: stamp_path = self.fs_layout.get_build_stamp_path_for_dependency( dep, self.build_type) old_build_stamp = None if os.path.exists(stamp_path): with open(stamp_path, 'rt') as inp: old_build_stamp = inp.read() new_build_stamp = self.get_build_stamp_for_dependency(dep) if dep.dir_name is not None: src_dir = self.fs_layout.get_source_path(dep) if not os.path.exists(src_dir): log("Have to rebuild %s (%s): source dir %s does not exist", dep.name, self.build_type, src_dir) return True if old_build_stamp == new_build_stamp: log("Not rebuilding %s (%s) -- nothing changed.", dep.name, self.build_type) return False else: log("Have to rebuild %s (%s):", dep.name, self.build_type) log("Old build stamp for %s (from %s):\n%s", dep.name, stamp_path, indent_lines(old_build_stamp)) log("New build stamp for %s:\n%s", dep.name, indent_lines(new_build_stamp)) return True
def save_build_stamp_for_dependency(self, dep: Dependency) -> None: stamp = self.get_build_stamp_for_dependency(dep) stamp_path = self.fs_layout.get_build_stamp_path_for_dependency(dep, self.build_type) log("Saving new build stamp to '%s':\n%s", stamp_path, indent_lines(stamp)) with open(stamp_path, "wt") as out: out.write(stamp)