Exemplo n.º 1
0
    def _needs_recompile(self, dependency_graph, source_file):
        md5 = source_file.md5()
        md5_file_name = self._hash_file_name_of(source_file)

        if not ostools.file_exists(md5_file_name):
            logger.debug("%s has no vunit_hash file at %s and must be recompiled",
                                  source_file.name, md5_file_name)
            return True

        old_md5 = ostools.read_file(md5_file_name)
        if old_md5 != md5:
            logger.debug("%s has different hash than last time and must be recompiled",
                         source_file.name)
            return True

        for other_file in dependency_graph.get_dependencies(source_file):
            other_md5_file_name = self._hash_file_name_of(other_file)

            if not ostools.file_exists(other_md5_file_name):
                continue

            if ostools.get_modification_time(other_md5_file_name) > ostools.get_modification_time(md5_file_name):
                logger.debug("%s has dependency compiled earlier and must be recompiled",
                             source_file.name)
                return True

        logger.debug("%s has same hash file and must not be recompiled",
                     source_file.name)

        return False
Exemplo n.º 2
0
def more_recent(file_name, than_file_name):
    """
    Returns True if the modification time of file_name is more recent
    than_file_name
    """
    mtime = ostools.get_modification_time(file_name)
    than_mtime = ostools.get_modification_time(than_file_name)
    return mtime > than_mtime
Exemplo n.º 3
0
def more_recent(file_name, than_file_name):
    """
    Returns True if the modification time of file_name is more recent
    than_file_name
    """
    mtime = ostools.get_modification_time(file_name)
    than_mtime = ostools.get_modification_time(than_file_name)
    return mtime > than_mtime
Exemplo n.º 4
0
 def _get_compile_timestamps(self, files):
     """
     Return a dictionary of mapping file to the timestamp when it
     was compiled or None if it was not compiled
     """
     # Cache timestamps to avoid duplicate file operations
     timestamps = {}
     for source_file in files:
         hash_file_name = self._hash_file_name_of(source_file)
         if not ostools.file_exists(hash_file_name):
             timestamps[source_file] = None
         else:
             timestamps[source_file] = ostools.get_modification_time(hash_file_name)
     return timestamps