forked from M-Labs/artiq
compiler: only use colors in diagnostics on POSIX (fixes #272).
This commit is contained in:
parent
4946a53456
commit
9db2be2b03
|
@ -14,7 +14,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
diag = False
|
diag = False
|
||||||
def process_diagnostic(diag):
|
def process_diagnostic(diag):
|
||||||
print("\n".join(diag.render(colored=True)))
|
print("\n".join(diag.render(colored=False)))
|
||||||
if diag.level in ("fatal", "error"):
|
if diag.level in ("fatal", "error"):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,10 @@ def _render_diagnostic(diagnostic, colored):
|
||||||
lines = [shorten_path(path) for path in diagnostic.render(colored=colored)]
|
lines = [shorten_path(path) for path in diagnostic.render(colored=colored)]
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
colors_supported = (os.name == 'posix')
|
||||||
class _DiagnosticEngine(diagnostic.Engine):
|
class _DiagnosticEngine(diagnostic.Engine):
|
||||||
def render_diagnostic(self, diagnostic):
|
def render_diagnostic(self, diagnostic):
|
||||||
sys.stderr.write(_render_diagnostic(diagnostic, colored=True) + "\n")
|
sys.stderr.write(_render_diagnostic(diagnostic, colored=colors_supported) + "\n")
|
||||||
|
|
||||||
class CompileError(Exception):
|
class CompileError(Exception):
|
||||||
def __init__(self, diagnostic):
|
def __init__(self, diagnostic):
|
||||||
|
@ -33,7 +34,7 @@ class CompileError(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# Prepend a newline so that the message shows up on after
|
# Prepend a newline so that the message shows up on after
|
||||||
# exception class name printed by Python.
|
# exception class name printed by Python.
|
||||||
return "\n" + _render_diagnostic(self.diagnostic, colored=True)
|
return "\n" + _render_diagnostic(self.diagnostic, colored=colors_supported)
|
||||||
|
|
||||||
|
|
||||||
@syscall
|
@syscall
|
||||||
|
|
Loading…
Reference in New Issue