diff --git a/litex/build/lattice/diamond.py b/litex/build/lattice/diamond.py index 9637eb972..e85436ca9 100644 --- a/litex/build/lattice/diamond.py +++ b/litex/build/lattice/diamond.py @@ -115,7 +115,8 @@ def _build_tcl(device, sources, vincpaths, build_name): # Script ------------------------------------------------------------------------------------------- def _build_script(build_name, device): - if sys.platform in ("win32", "cygwin"): + on_windows = sys.platform in ("win32", "cygwin") + if on_windows: script_ext = ".bat" script_contents = "@echo off\nrem Autogenerated by LiteX / git: " + tools.get_litex_git_revision() + "\n\n" copy_stmt = "copy" @@ -126,7 +127,8 @@ def _build_script(build_name, device): copy_stmt = "cp" fail_stmt = "" - script_contents += "diamondc {tcl_script}{fail_stmt}\n".format( + script_contents += "{tool} {tcl_script}{fail_stmt}\n".format( + tool = "pnmainc" if on_windows else "diamondc", tcl_script = build_name + ".tcl", fail_stmt = fail_stmt) for ext in (".bit", ".jed"): @@ -143,12 +145,13 @@ def _build_script(build_name, device): return build_script_file def _run_script(script): - if sys.platform in ("win32", "cygwin"): + on_windows = sys.platform in ("win32", "cygwin") + if on_windows: shell = ["cmd", "/c"] else: shell = ["bash"] - if which("diamondc") is None: + if which("pnmainc" if on_windows else "diamondc") is None: msg = "Unable to find Diamond toolchain, please:\n" msg += "- Add Diamond toolchain to your $PATH.\n" raise OSError(msg)