colorer: Avoid duplication and move it to litex/gen.
This commit is contained in:
parent
3986a5b27e
commit
507ffb72b5
|
@ -2,6 +2,8 @@ import sys
|
||||||
|
|
||||||
from litex.tools.litex_client import RemoteClient
|
from litex.tools.litex_client import RemoteClient
|
||||||
|
|
||||||
|
# Python-Data Import Helper ------------------------------------------------------------------------
|
||||||
|
|
||||||
def get_data_mod(data_type, data_name):
|
def get_data_mod(data_type, data_name):
|
||||||
"""Get the pythondata-{}-{} module or raise a useful error message."""
|
"""Get the pythondata-{}-{} module or raise a useful error message."""
|
||||||
imp = "import pythondata_{}_{} as dm".format(data_type, data_name)
|
imp = "import pythondata_{}_{} as dm".format(data_type, data_name)
|
||||||
|
|
|
@ -1,22 +1,10 @@
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# Helpers ------------------------------------------------------------------------------------------
|
# Compatibility Layer ------------------------------------------------------------------------------
|
||||||
|
|
||||||
def colorer(s, color="bright"): # FIXME: Move colorer to litex.common?
|
|
||||||
header = {
|
|
||||||
"bright": "\x1b[1m",
|
|
||||||
"green": "\x1b[32m",
|
|
||||||
"cyan": "\x1b[36m",
|
|
||||||
"red": "\x1b[31m",
|
|
||||||
"yellow": "\x1b[33m",
|
|
||||||
"underline": "\x1b[4m"}[color]
|
|
||||||
trailer = "\x1b[0m"
|
|
||||||
return header + str(s) + trailer
|
|
||||||
|
|
||||||
# Compat -------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
def compat_notice(name, date, info=""):
|
def compat_notice(name, date, info=""):
|
||||||
|
from litex.gen import colorer
|
||||||
print("Compat: {name} is {deprecated} since {date} and will soon no longer work, please {update}. {info}".format(
|
print("Compat: {name} is {deprecated} since {date} and will soon no longer work, please {update}. {info}".format(
|
||||||
name = colorer(name),
|
name = colorer(name),
|
||||||
deprecated = colorer("deprecated", color="red"),
|
deprecated = colorer("deprecated", color="red"),
|
||||||
|
|
|
@ -6,6 +6,19 @@
|
||||||
|
|
||||||
from migen import *
|
from migen import *
|
||||||
|
|
||||||
|
# Generic Helpers ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def colorer(s, color="bright"):
|
||||||
|
header = {
|
||||||
|
"bright": "\x1b[1m",
|
||||||
|
"green": "\x1b[32m",
|
||||||
|
"cyan": "\x1b[36m",
|
||||||
|
"red": "\x1b[31m",
|
||||||
|
"yellow": "\x1b[33m",
|
||||||
|
"underline": "\x1b[4m"}[color]
|
||||||
|
trailer = "\x1b[0m"
|
||||||
|
return header + str(s) + trailer
|
||||||
|
|
||||||
# Bit/Bytes Reversing ------------------------------------------------------------------------------
|
# Bit/Bytes Reversing ------------------------------------------------------------------------------
|
||||||
|
|
||||||
def reverse_bits(s):
|
def reverse_bits(s):
|
||||||
|
|
|
@ -9,7 +9,7 @@ import math
|
||||||
|
|
||||||
from migen import Record
|
from migen import Record
|
||||||
|
|
||||||
from litex.soc.integration.soc import colorer
|
from litex.gen import colorer
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,12 @@ import struct
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from litex import get_data_mod
|
from litex import get_data_mod
|
||||||
|
from litex.gen import colorer
|
||||||
|
|
||||||
from litex.build.tools import write_to_file
|
from litex.build.tools import write_to_file
|
||||||
from litex.soc.integration import export, soc_core
|
|
||||||
from litex.soc.integration.soc import colorer
|
|
||||||
from litex.soc.cores import cpu
|
from litex.soc.cores import cpu
|
||||||
|
from litex.soc.integration import export, soc_core
|
||||||
|
|
||||||
# Helpers ------------------------------------------------------------------------------------------
|
# Helpers ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ import datetime
|
||||||
from math import log2, ceil
|
from math import log2, ceil
|
||||||
|
|
||||||
from migen import *
|
from migen import *
|
||||||
|
|
||||||
|
from litex.gen import colorer
|
||||||
|
|
||||||
from litex.gen import LiteXModule
|
from litex.gen import LiteXModule
|
||||||
|
|
||||||
from litex.soc.cores import cpu
|
from litex.soc.cores import cpu
|
||||||
|
@ -33,17 +36,6 @@ logging.basicConfig(level=logging.INFO)
|
||||||
def auto_int(x):
|
def auto_int(x):
|
||||||
return int(x, 0)
|
return int(x, 0)
|
||||||
|
|
||||||
def colorer(s, color="bright"):
|
|
||||||
header = {
|
|
||||||
"bright": "\x1b[1m",
|
|
||||||
"green": "\x1b[32m",
|
|
||||||
"cyan": "\x1b[36m",
|
|
||||||
"red": "\x1b[31m",
|
|
||||||
"yellow": "\x1b[33m",
|
|
||||||
"underline": "\x1b[4m"}[color]
|
|
||||||
trailer = "\x1b[0m"
|
|
||||||
return header + str(s) + trailer
|
|
||||||
|
|
||||||
def build_time(with_time=True):
|
def build_time(with_time=True):
|
||||||
fmt = "%Y-%m-%d %H:%M:%S" if with_time else "%Y-%m-%d"
|
fmt = "%Y-%m-%d %H:%M:%S" if with_time else "%Y-%m-%d"
|
||||||
return datetime.datetime.fromtimestamp(time.time()).strftime(fmt)
|
return datetime.datetime.fromtimestamp(time.time()).strftime(fmt)
|
||||||
|
|
|
@ -16,7 +16,7 @@ python3 = sys.executable
|
||||||
|
|
||||||
# Helpers ------------------------------------------------------------------------------------------
|
# Helpers ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def colorer(s, color="bright"): # FIXME: Move colorer to litex.common?
|
def colorer(s, color="bright"):
|
||||||
header = {
|
header = {
|
||||||
"bright" : "\x1b[1m",
|
"bright" : "\x1b[1m",
|
||||||
"green" : "\x1b[1m\x1b[32m",
|
"green" : "\x1b[1m\x1b[32m",
|
||||||
|
|
Loading…
Reference in New Issue