<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate(self, tool, copied=False, copy=False):
 """ Generates a project """


        tools = self._validate_tools(tool)
        if tools == -1:
            return -1

        generated_files = {}
        result = 0
        for export_tool in tools:
            exporter = ToolsSupported().get_tool(export_tool)

            # None is an error
            if exporter is None:
                result = -1
                logger.debug("Tool: %s was not found" % export_tool)
                continue

            self._fill_export_dict(export_tool, copied)
            if copy:
                logger.debug("Copying sources to the output directory")
                self._copy_sources_to_generated_destination()
            # dump a log file if debug is enabled
            if logger.isEnabledFor(logging.DEBUG):
                dump_data = {}
                dump_data['common'] = self.project['common']
                dump_data['tool_specific'] = self.project['tool_specific']
                dump_data['merged'] = self.project['export']
                handler = logging.FileHandler(os.path.join(os.getcwd(), "%s.log" % self.name),"w", encoding=None, delay="true")
                handler.setLevel(logging.DEBUG)
                logger.addHandler(handler)
                logger.debug("\n" + yaml.dump(dump_data))

            files = exporter(self.project['export'], self.settings).export_project()
            generated_files[export_tool] = files
        self.generated_files = generated_files
        return result