From 7d9f1fad1fe73d2d1885f2e0163bef617fed1494 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 27 Oct 2018 23:53:29 +0100 Subject: [PATCH] Updating python files and riscv for calling from any directory. --- id_regs.py | 3 ++- riscv/riscv.mk.in | 4 ++-- sv_proc_gen.py | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/id_regs.py b/id_regs.py index ccb4f38..d8b587a 100644 --- a/id_regs.py +++ b/id_regs.py @@ -21,7 +21,8 @@ import os import sys -insns_dir = "./riscv/insns" +dir_path = os.path.dirname(os.path.realpath(__file__)) +insns_dir = os.path.join(dir_path, 'riscv', 'insns') def list_insns(): if len(sys.argv) == 2: fullfname = sys.argv[1] diff --git a/riscv/riscv.mk.in b/riscv/riscv.mk.in index 9226eff..6916d07 100644 --- a/riscv/riscv.mk.in +++ b/riscv/riscv.mk.in @@ -310,11 +310,11 @@ insn_list.h: $(src_dir)/riscv/riscv.mk.in printf 'DEFINE_INSN(%s)\n' "$${insn}" ; \ done > $@.tmp mv $@.tmp $@ - python sv_proc_gen.py + python $(src_dir)/sv_proc_gen.py $(riscv_gen_srcs): %.cc: insns/%.h insn_template.cc sed 's/NAME/$(subst .cc,,$@)/' $(src_dir)/riscv/insn_template.cc | sed 's/OPCODE/$(call get_opcode,$(src_dir)/riscv/encoding.h,$(subst .cc,,$@))/' > $@ - python id_regs.py $(src_dir)/riscv/insns/$(subst .cc,,$@).h + python $(src_dir)/id_regs.py $(src_dir)/riscv/insns/$(subst .cc,,$@).h riscv_junk = \ $(riscv_gen_srcs) \ diff --git a/sv_proc_gen.py b/sv_proc_gen.py index 13eddaf..07d3dac 100644 --- a/sv_proc_gen.py +++ b/sv_proc_gen.py @@ -21,7 +21,10 @@ import os import sys -insns_dir = "./riscv/insns" +dir_path = os.path.dirname(os.path.realpath(__file__)) +riscv_dir = os.path.join(dir_path, "riscv") +insns_dir = os.path.join(dir_path, "riscv", "insns") +print(os.getcwd()) def list_insns(): if len(sys.argv) == 2: fullfname = sys.argv[1] @@ -46,7 +49,7 @@ sv_hdr_template = """\ if __name__ == '__main__': files = list_insns() - with open("riscv/sv_insn_decl.h", "w") as f: + with open(os.path.join(riscv_dir, "sv_insn_decl.h"), "w") as f: for (fname, insn) in files: f.write(sv_hdr_template.format(insn)) -- 2.30.2