def build(self, source_entities, targets):

        file2deps = {}
        files_content = {}
        modules = set()
        tails = []

        std_modules = set()

        for entity in source_entities:
            file_name = entity.name
            mod_std_imports, mod_deps, mod_content = entity.data

            if not mod_content:
                continue

            if not mod_deps:
                tails.append(file_name)

            files_content[file_name] = mod_content
            file2deps[file_name] = mod_deps

            std_modules.update(mod_std_imports)
            modules.update(mod_deps)

        mod2files = self._mod_to_files(file2deps, modules)

        dep2files, file2deps = self._get_dep_to_files(file2deps, mod2files)

        content = self._get_content(files_content, dep2files, file2deps, tails)

        imports_content = '\n'.join(
            "import %s" % module for module in sorted(std_modules))

        content = '\n'.join([HEADER, imports_content, content, AQL_DATE])

        aql.write_text_file(self.target, data=content)
        targets.add_target_files(self.target)