mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
powershell and WSL support
This commit is contained in:
parent
cfab857c7b
commit
700077e4a1
1 changed files with 13 additions and 3 deletions
|
@ -6,6 +6,7 @@
|
||||||
# SPDX-License-Identifier: BSD-2-Clause
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import math
|
import math
|
||||||
import subprocess
|
import subprocess
|
||||||
from shutil import which
|
from shutil import which
|
||||||
|
@ -67,7 +68,9 @@ def _build_tcl(name, partnumber, files, options):
|
||||||
|
|
||||||
# Add Sources.
|
# Add Sources.
|
||||||
for f, typ, lib in files:
|
for f, typ, lib in files:
|
||||||
f = f.replace("\\", "\\\\")
|
# Support windows/powershell
|
||||||
|
if sys.platform == "win32":
|
||||||
|
f = f.replace("\\", "\\\\")
|
||||||
tcl.append(f"add_file {f}")
|
tcl.append(f"add_file {f}")
|
||||||
|
|
||||||
# Set Options.
|
# Set Options.
|
||||||
|
@ -162,12 +165,19 @@ class GowinToolchain:
|
||||||
|
|
||||||
# Run
|
# Run
|
||||||
if run:
|
if run:
|
||||||
if which("gw_sh") is None:
|
# Support Powershell/WSL platform
|
||||||
|
# Some python distros for windows (e.g, oss-cad-suite)
|
||||||
|
# which does not have 'os.uname' support, we should check 'sys.platform' firstly.
|
||||||
|
gw_sh = "gw_sh"
|
||||||
|
if sys.platform.find("linux") >= 0:
|
||||||
|
if os.uname().release.find("WSL") > 0:
|
||||||
|
gw_sh += ".exe"
|
||||||
|
if which(gw_sh) is None:
|
||||||
msg = "Unable to find Gowin toolchain, please:\n"
|
msg = "Unable to find Gowin toolchain, please:\n"
|
||||||
msg += "- Add Gowin toolchain to your $PATH."
|
msg += "- Add Gowin toolchain to your $PATH."
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
|
|
||||||
if subprocess.call(["gw_sh", "run.tcl"]) != 0:
|
if subprocess.call([gw_sh, "run.tcl"]) != 0:
|
||||||
raise OSError("Error occured during Gowin's script execution.")
|
raise OSError("Error occured during Gowin's script execution.")
|
||||||
|
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
Loading…
Reference in a new issue