fix nax/vexii git checkout process, thanks JoyBed

This commit is contained in:
Dolu1990 2024-05-18 10:01:29 +02:00
parent 0720ffb404
commit 8c0f5447ed
2 changed files with 10 additions and 11 deletions

View File

@ -294,7 +294,11 @@ class NaxRiscv(CPU):
@staticmethod
def git_setup(name, dir, repo, branch, hash):
def git_setup(name, dir, repo, branch, hash, update):
if update == "no":
return
if "recommended" not in update:
hash = ""
if not os.path.exists(dir):
# Clone Repo.
print(f"Cloning {name} Git repository...")
@ -306,7 +310,7 @@ class NaxRiscv(CPU):
print(f"Updating {name} Git repository...")
cwd = os.getcwd()
os.chdir(os.path.join(dir))
wipe_cmd = "&& git clean --force -d -x && git reset --hard" if "wipe" in NaxRiscv.update_repo else ""
wipe_cmd = "&& git clean --force -d -x && git reset --hard" if "wipe" in update else ""
checkout_cmd = f"&& git checkout {hash}" if hash is not None else ""
subprocess.check_call(f"cd {dir} {wipe_cmd} && git checkout {branch} && git submodule init && git pull --recurse-submodules {checkout_cmd}", shell=True)
os.chdir(cwd)
@ -318,8 +322,7 @@ class NaxRiscv(CPU):
ndir = os.path.join(vdir, "ext", "NaxRiscv")
sdir = os.path.join(vdir, "ext", "SpinalHDL")
if NaxRiscv.update_repo != "no":
NaxRiscv.git_setup("NaxRiscv", ndir, "https://github.com/SpinalHDL/NaxRiscv.git", "main", "f3357383" if NaxRiscv.update_repo=="recommended" else None)
NaxRiscv.git_setup("NaxRiscv", ndir, "https://github.com/SpinalHDL/NaxRiscv.git", "main", "f3357383", NaxRiscv.update_repo)
gen_args = []
gen_args.append(f"--netlist-name={NaxRiscv.netlist_name}")

View File

@ -129,10 +129,10 @@ class VexiiRiscv(CPU):
def args_read(args):
print(args)
if args.update_repo != "no":
NaxRiscv.git_setup("VexiiRiscv", ndir, "https://github.com/SpinalHDL/VexiiRiscv.git", "fpu_internal", "8a239d10" if args.update_repo=="recommended" else None)
vdir = get_data_mod("cpu", "vexiiriscv").data_location
ndir = os.path.join(vdir, "ext", "VexiiRiscv")
NaxRiscv.git_setup("VexiiRiscv", ndir, "https://github.com/SpinalHDL/VexiiRiscv.git", "fpu_internal", "8a239d10", args.update_repo)
VexiiRiscv.jtag_tap = args.with_jtag_tap
VexiiRiscv.jtag_instruction = args.with_jtag_instruction
@ -141,15 +141,11 @@ class VexiiRiscv(CPU):
VexiiRiscv.no_netlist_cache = args.no_netlist_cache
VexiiRiscv.vexii_args = args.vexii_args
vdir = get_data_mod("cpu", "vexiiriscv").data_location
md5_hash = hashlib.md5()
md5_hash.update(args.vexii_args.encode('utf-8'))
vexii_args_hash = md5_hash.hexdigest()
ppath = os.path.join(vdir, str(vexii_args_hash) + ".py")
if VexiiRiscv.no_netlist_cache or not os.path.exists(ppath):
ndir = os.path.join(vdir, "ext", "VexiiRiscv")
cmd = f"""cd {ndir} && sbt "runMain vexiiriscv.soc.litex.PythonArgsGen {args.vexii_args} --python-file={str(ppath)}\""""
subprocess.check_call(cmd, shell=True)
with open(ppath) as file: