def generate(<EOL>self, builddir, modbuilddir, component, active_dependencies, immediate_dependencies, all_dependencies, application, toplevel<EOL>):
include_root_dirs = '<STR_LIT>'<EOL>if application is not None and component is not application:<EOL><INDENT>include_root_dirs += '<STR_LIT>' % replaceBackslashes(application.path)<EOL><DEDENT>include_sys_dirs = '<STR_LIT>'<EOL>include_other_dirs = '<STR_LIT>'<EOL>for name, c in itertools.chain(((component.getName(), component),), all_dependencies.items()):<EOL><INDENT>if c is not component and c.isTestDependency():<EOL><INDENT>continue<EOL><DEDENT>include_root_dirs += '<STR_LIT>' % replaceBackslashes(c.path)<EOL>dep_sys_include_dirs = c.getExtraSysIncludes()<EOL>for d in dep_sys_include_dirs:<EOL><INDENT>include_sys_dirs += '<STR_LIT>' % replaceBackslashes(os.path.join(c.path, d))<EOL><DEDENT>dep_extra_include_dirs = c.getExtraIncludes()<EOL>for d in dep_extra_include_dirs:<EOL><INDENT>include_other_dirs += '<STR_LIT>' % replaceBackslashes(os.path.join(c.path, d))<EOL><DEDENT><DEDENT>add_depend_subdirs = '<STR_LIT>'<EOL>for name, c in active_dependencies.items():<EOL><INDENT>depend_subdir = replaceBackslashes(os.path.join(modbuilddir, name))<EOL>relpath = replaceBackslashes(os.path.relpath(depend_subdir, self.buildroot))<EOL>add_depend_subdirs +='<STR_LIT>''<STR_LIT>''<STR_LIT>''<STR_LIT>'% (depend_subdir, relpath)<EOL><DEDENT>delegate_to_existing = None<EOL>delegate_build_dir = None<EOL>module_is_empty = False<EOL>if os.path.isfile(os.path.join(component.path, '<STR_LIT>')) and not component.ignores('<STR_LIT>'):<EOL><INDENT>delegate_to_existing = component.path<EOL>add_own_subdirs = []<EOL>logger.debug("<STR_LIT>", builddir)<EOL>delegate_build_dir = os.path.join(builddir, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>self._validateListedSubdirsExist(component)<EOL>subdirs = self._listSubDirectories(component, toplevel)<EOL>manual_subdirs      = subdirs['<STR_LIT>']<EOL>autogen_subdirs     = subdirs['<STR_LIT>']<EOL>binary_subdirs      = subdirs['<STR_LIT>']<EOL>lib_subdirs         = subdirs['<STR_LIT>']<EOL>test_subdirs        = subdirs['<STR_LIT:test>']<EOL>resource_subdirs    = subdirs['<STR_LIT>']<EOL>header_subdirs      = subdirs['<STR_LIT>']<EOL>logger.debug("<STR_LIT>", component, lib_subdirs, binary_subdirs)<EOL>add_own_subdirs = []<EOL>for f in manual_subdirs:<EOL><INDENT>if os.path.isfile(os.path.join(component.path, f, '<STR_LIT>')):<EOL><INDENT>if f in test_subdirs and component.isTestDependency():<EOL><INDENT>continue<EOL><DEDENT>add_own_subdirs.append(<EOL>(os.path.join(component.path, f), f)<EOL>)<EOL><DEDENT><DEDENT>all_subdirs = manual_subdirs + [x[<NUM_LIT:0>] for x in autogen_subdirs]<EOL>if component.isTestDependency():<EOL><INDENT>if len(autogen_subdirs) + len(add_own_subdirs) == <NUM_LIT:0>:<EOL><INDENT>module_is_empty = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if len(autogen_subdirs) + len(add_own_subdirs) <= len(test_subdirs):<EOL><INDENT>module_is_empty = True<EOL><DEDENT><DEDENT>for f, source_files in autogen_subdirs:<EOL><INDENT>if f in test_subdirs:<EOL><INDENT>if component.isTestDependency():<EOL><INDENT>continue<EOL><DEDENT>self.generateTestDirList(<EOL>builddir, f, source_files, component, immediate_dependencies, toplevel=toplevel, module_is_empty=module_is_empty<EOL>)<EOL><DEDENT>else:<EOL><INDENT>if f in binary_subdirs:<EOL><INDENT>is_executable = True<EOL>object_name = binary_subdirs[f]<EOL><DEDENT>else:<EOL><INDENT>assert(f in lib_subdirs)<EOL>object_name = lib_subdirs[f]<EOL><DEDENT>for header_dir, header_files in header_subdirs:<EOL><INDENT>source_files.extend(header_files)<EOL><DEDENT>self.generateSubDirList(<EOL>builddir = builddir,<EOL>dirname = f,<EOL>source_files = source_files,<EOL>component = component,<EOL>all_subdirs = all_subdirs,<EOL>immediate_dependencies = immediate_dependencies,<EOL>object_name = object_name,<EOL>resource_subdirs = resource_subdirs,<EOL>is_executable = (f in binary_subdirs)<EOL>)<EOL><DEDENT>add_own_subdirs.append(<EOL>(os.path.join(builddir, f), f)<EOL>)<EOL><DEDENT>if component.isTestDependency():<EOL><INDENT>test_subdirs = []<EOL><DEDENT>if module_is_empty:<EOL><INDENT>if len(binary_subdirs):<EOL><INDENT>logger.warning('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>add_own_subdirs.append(self.createDummyLib(<EOL>component, builddir, [x[<NUM_LIT:0>] for x in immediate_dependencies.items() if not x[<NUM_LIT:1>].isTestDependency()]<EOL>))<EOL><DEDENT><DEDENT><DEDENT>toolchain_file_path = os.path.join(builddir, '<STR_LIT>')<EOL>if toplevel:<EOL><INDENT>template = jinja_environment.get_template('<STR_LIT>')<EOL>file_contents = template.render({  <EOL>"<STR_LIT>": self.target.getToolchainFiles()<EOL>})<EOL>self._writeFile(toolchain_file_path, file_contents)<EOL><DEDENT>template = jinja_environment.get_template('<STR_LIT>')<EOL>relpath = os.path.relpath(builddir, self.buildroot)<EOL>file_contents = template.render({ <EOL>"<STR_LIT>": toplevel,<EOL>"<STR_LIT>": self.target.getName(),<EOL>"<STR_LIT>": self.set_toplevel_definitions,<EOL>"<STR_LIT>": toolchain_file_path,<EOL>"<STR_LIT>": component,<EOL>"<STR_LIT>": relpath,<EOL>"<STR_LIT>": include_root_dirs,<EOL>"<STR_LIT>": include_sys_dirs,<EOL>"<STR_LIT>": include_other_dirs,<EOL>"<STR_LIT>": add_depend_subdirs,<EOL>"<STR_LIT>": add_own_subdirs,<EOL>"<STR_LIT>": self.config_include_file,<EOL>"<STR_LIT>": delegate_to_existing,<EOL>"<STR_LIT>": delegate_build_dir,<EOL>"<STR_LIT>": active_dependencies,<EOL>"<STR_LIT>": module_is_empty,<EOL>"<STR_LIT>": self.target.getAdditionalIncludes()<EOL>})<EOL>self._writeFile(os.path.join(builddir, '<STR_LIT>'), file_contents)<EOL>
active_dependencies is the dictionary of components that need to be
            built for this component, but will not already have been built for
            another component.