diff --git a/analog/tools/ltspice/__init__.py b/analog/tools/ltspice/__init__.py index 9e0a7d3..cc00bc1 100644 --- a/analog/tools/ltspice/__init__.py +++ b/analog/tools/ltspice/__init__.py @@ -59,7 +59,7 @@ def run(asc: str): if sys.platform == "darwin": ltspice = "/Applications/LTspice.app/Contents/MacOS/LTspice" elif sys.platform == "unix" or "linux" in sys.platform: - ltspice = 'wine "%s"' % shutil.which("XVIIx64.exe") + ltspice = 'wine "%s"' % utils.wine.locate("XVIIx64.exe") asc = "z:%s" % asc else: ltspice = "XVIIx64.exe" diff --git a/analog/tools/ltspice_view/__init__.py b/analog/tools/ltspice_view/__init__.py index aa58684..06848cd 100644 --- a/analog/tools/ltspice_view/__init__.py +++ b/analog/tools/ltspice_view/__init__.py @@ -26,7 +26,7 @@ def run(raw: str): if sys.platform == "darwin": ltspice = "/Applications/LTspice.app/Contents/MacOS/LTspice" elif sys.platform == "unix" or "linux" in sys.platform: - ltspice = 'wine "%s"' % shutil.which("XVIIx64.exe") + ltspice = 'wine "%s"' % utils.wine.locate("XVIIx64.exe") raw = "z:%s" % raw else: ltspice = "XVIIx64.exe" diff --git a/common/executor.py b/common/executor.py index 8c55d73..a55d052 100644 --- a/common/executor.py +++ b/common/executor.py @@ -61,7 +61,6 @@ def sh_exec( if return_code: raise subprocess.CalledProcessError(return_code, cmd) except (OSError, subprocess.CalledProcessError) as exception: - relog.error("Exception occured: ", str(exception)) return False except subprocess.TimeoutExpired: relog.error("Unexpected executer timeout") @@ -125,7 +124,6 @@ def ish_exec( if return_code: raise subprocess.CalledProcessError(return_code, cmd) except (OSError, subprocess.CalledProcessError) as exception: - relog.error("Exception occured: ", str(exception)) return False except subprocess.TimeoutExpired: relog.error("Unexpected executer timeout") diff --git a/common/utils/__init__.py b/common/utils/__init__.py index f4b8a95..75b3958 100644 --- a/common/utils/__init__.py +++ b/common/utils/__init__.py @@ -7,5 +7,6 @@ import common.utils.tools as tools import common.utils.graphs as graphs import common.utils.parsers as parsers +import common.utils.wine as wine from common.utils.run import * diff --git a/common/utils/wine.py b/common/utils/wine.py new file mode 100644 index 0000000..af1158a --- /dev/null +++ b/common/utils/wine.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# coding: utf-8 + +import os + +from pathlib import Path + + +def locate(program: str): + """ + locate where an exe file is store in a wine installation + wine load application in WINEPREFIX (by default $HOME/.wine) + """ + wineprefix = os.getenv("WINEPREFIX") or os.path.join(os.getenv("HOME"), ".wine") + ans = [] + for file in Path(wineprefix).rglob("**/*.exe"): + if program in str(file): + ans.append(str(file)) + return ans[-1] diff --git a/digital/tools/iverilog/__init__.py b/digital/tools/iverilog/__init__.py index bbf3a9d..7d29a95 100755 --- a/digital/tools/iverilog/__init__.py +++ b/digital/tools/iverilog/__init__.py @@ -23,14 +23,16 @@ def transform_flags(flags: str) -> str: flags = flags.strip() - if "-DEFINE " in flags: - flags = flags.replace("-DEFINE ", "+define+") - if "-define " in flags: - flags = flags.replace("-define ", "+define+") - if "-PARAM " in flags: - flags = flags.replace("-PARAM ", "+parameter+") - if "-param " in flags: - flags = flags.replace("-param ", "+parameter+") + # replace any values found by the key + matches = { + "+define+": ["-DEFINE ", "-define ", "-D", "-d"], + "+parameter+": ["-PARAM ", "-param ", "-P", "-p"], + } + for output, inputs in matches.items(): + for i in inputs: + if i in flags: + flags = flags.replace(i, output) + # generate a string flags = [flag for flag in flags.split(" ") if not flag.startswith("-g")] return " ".join(flags) @@ -78,12 +80,18 @@ def compile(generation, flags): "iverilog -g%s -grelative-include %s -Wall -o %s -c %s" % (generation, flags, EXE, SRCS) ) - executor.sh_exec( - "iverilog -g%s -grelative-include %s -Wall -o %s -c %s" - % (generation, flags, EXE, SRCS), - PARSER_LOG, - MAX_TIMEOUT=20, - ) + try: + executor.sh_exec( + "iverilog -g%s -grelative-include %s -Wall -o %s -c %s" + % (generation, flags, EXE, SRCS), + PARSER_LOG, + MAX_TIMEOUT=20, + ) + # ignore return code error + # as message is already displayed in stdout + # and in the log file + except subprocess.CalledProcessError: + pass def run(lint: bool = False): diff --git a/tests/.tmp_report/report.html b/tests/.tmp_report/report.html index 8e42305..df3b9c8 100644 --- a/tests/.tmp_report/report.html +++ b/tests/.tmp_report/report.html @@ -87,13 +87,13 @@
- Errors:26
+ Errors:382
- Warnings:8
+ Warnings:16
- Elapsed Time:42.540s
+ Elapsed Time:1m44.951s
id | +warnings | +errors | +total time | + + +
---|---|---|---|
60meg | +0 | +4 | +0.215s | +
50meg | +0 | +2 | +0.212s | +
32meg | +0 | +0 | +0.212s | +
100meg | +0 | +148 | +0.317s | +