def generate_source_files(self):
from pybfd.gen_supported_disasm import get_supported_architectures,get_supported_machines,generate_supported_architectures_source,generate_supported_disassembler_header,gen_supported_archs<EOL>libs_dirs = [os.path.dirname(lib) for lib in self.libs]<EOL>libopcodes = [lib for lib in self.libs if os.path.basename(<EOL>lib).startswith("<STR_LIT>")][<NUM_LIT:0>]<EOL>print("<STR_LIT>")<EOL>if self.with_static_binutils:  <EOL><INDENT>nms = [<EOL>os.path.join(libs_dir, "<STR_LIT:..>", "<STR_LIT>", "<STR_LIT>"),<EOL>os.path.join(libs_dir, "<STR_LIT:..>", "<STR_LIT>", "<STR_LIT>")<EOL>]<EOL>path_to_nm = None<EOL>for nm_fullpath in nms:<EOL><INDENT>if os.path.isfile(nm_fullpath):<EOL><INDENT>path_to_nm = nm_fullpath<EOL>break<EOL><DEDENT><DEDENT>if path_to_nm == None:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>path_to_nm = "<STR_LIT>"<EOL><DEDENT>path_to_bfd_header = os.path.join(self.includes, "<STR_LIT>")<EOL>supported_machines = get_supported_machines(path_to_bfd_header)<EOL>supported_archs = get_supported_architectures(<EOL>path_to_nm,<EOL>libopcodes,<EOL>supported_machines,<EOL>self.with_static_binutils == None)<EOL>source_bfd_archs_c = generate_supported_architectures_source(<EOL>supported_archs, supported_machines)<EOL>print("<STR_LIT>")<EOL>gen_file = os.path.join(PACKAGE_DIR, "<STR_LIT>")<EOL>with open(gen_file, "<STR_LIT>") as fd:<EOL><INDENT>fd.write(source_bfd_archs_c)<EOL><DEDENT>print("<STR_LIT>" % gen_file)<EOL>if self.with_static_binutils:<EOL><INDENT>link_to_libs = []  <EOL><DEDENT>else:<EOL><INDENT>link_to_libs = [self.prepare_libs_for_cc(<EOL>os.path.basename(lib)) for lib in self.libs]<EOL><DEDENT>c_compiler = new_compiler()<EOL>objects = c_compiler.compile(<EOL>[os.path.join(PACKAGE_DIR, "<STR_LIT>"), ],<EOL>include_dirs=[self.includes, ]<EOL>)<EOL>program = c_compiler.link_executable(<EOL>objects,<EOL>libraries=link_to_libs,<EOL>library_dirs=libs_dirs,<EOL>output_progname="<STR_LIT>",<EOL>output_dir=PACKAGE_DIR<EOL>)<EOL>gen_tool = os.path.join(PACKAGE_DIR, "<STR_LIT>")<EOL>gen_file = os.path.join(self.build_lib, PACKAGE_DIR, "<STR_LIT>")<EOL>cmd = "<STR_LIT>" % (<EOL>gen_tool,<EOL>gen_file)<EOL>print("<STR_LIT>")<EOL>os.system(cmd)<EOL>with open(gen_file, "<STR_LIT:a>") as f:<EOL><INDENT>f.write(gen_supported_archs(supported_archs))<EOL><DEDENT>for obj in objects:<EOL><INDENT>os.unlink(obj)<EOL><DEDENT>os.unlink(gen_tool)<EOL>print("<STR_LIT>" % gen_file)<EOL>gen_source = generate_supported_disassembler_header(supported_archs)<EOL>if len(supported_archs) == <NUM_LIT:0>:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>"<STR_LIT>" % libopcodes)<EOL><DEDENT>print("<STR_LIT>")<EOL>gen_file = os.path.join(PACKAGE_DIR, "<STR_LIT>")<EOL>with open(gen_file, "<STR_LIT>") as fd:<EOL><INDENT>fd.write(gen_source)<EOL><DEDENT>print("<STR_LIT>" % gen_file)<EOL>return supported_archs<EOL>
Genertate source files to be used during the compile process of the
extension module.
This is better than just hardcoding the values on python files because
header definitions might change along differente Binutils versions and
we'll be able to catch the changes and keep the correct values.