utils: Improving mux_gen. Signed-off-by: Tim 'mithro' Ansell <mithro@mithis.com>
diff --git a/v2x/mux_gen.py b/v2x/mux_gen.py index 94f3163..f2323d5 100755 --- a/v2x/mux_gen.py +++ b/v2x/mux_gen.py
@@ -192,31 +192,43 @@ """ % " ".join(a.replace("--", "~~") for a in repo_args) # Create a makefile to regenerate files. +makefile_file = os.path.join(outdir, "Makefile") output_files = ['model.xml', 'pb_type.xml', '.gitignore', 'Makefile'] -with open(os.path.join(outdir, "Makefile"), "w") as f: +commit_files = ['.gitignore', 'Makefile'] +remove_files = [f for f in output_files if f not in commit_files] +with open(makefile_file, "w") as f: f.write("""\ %s all: %s -.PHONY: all -""" % ("\n# ".join(generated_with.split("\n")), " ".join(output_files))) - f.write(""" +clean: +\trm -f .mux_gen.stamp %s + .mux_gen.stamp: %s \t%s \ttouch --reference $< $@ -""" % (repo_args[0], " ".join(repo_args))) +.PHONY: all clean + +""" % ("\n# ".join(generated_with.split("\n")), + " ".join(output_files), + " ".join(remove_files), + repo_args[0], + " ".join(repo_args), + )) for name in output_files: f.write("%s: .mux_gen.stamp\n\n" % name) + print("Makefile", "-"*75) -print(open("Makefile").read()) +print(open(makefile_file).read()) print("-"*75) # .gitignore file for the generated file. -with open(os.path.join(outdir, ".gitignore"), "w") as f: +gitignore_file = os.path.join(outdir, ".gitignore") +with open(gitignore_file, "w") as f: f.write(".mux_gen.stamp\n") for name in output_files: if name in ('.gitignore', 'Makefile'): @@ -224,7 +236,7 @@ f.write(name+'\n') print(".gitignore", "-"*75) -print(open(".gitignore").read()) +print(open(gitignore_file).read()) print("-"*75) # Work out the port names @@ -287,11 +299,12 @@ ) if args.type == 'logic': - pb_type = ET.SubElement( - pb_type_xml, - 'pb_type', - {}, - ) + #pb_type = ET.SubElement( + # pb_type_xml, + # 'pb_type', + # {}, + #) + pass interconnect = ET.SubElement(pb_type_xml, 'interconnect') if args.type == 'routing': @@ -325,7 +338,7 @@ ) pb_type_str = ET.tostring(pb_type_xml, pretty_print=True).decode('utf-8') -print("p_type.xml", "-"*75) +print("pb_type.xml", "-"*75) print(pb_type_str) print("-"*75) with open(os.path.join(outdir, "pb_type.xml"), "w") as f: