Merge pull request #60 from blastrock/master
Make cmake coloring work with Ninja
This commit is contained in:
commit
df5ca732de
2 changed files with 44 additions and 6 deletions
|
|
@ -367,6 +367,39 @@ def colorin(text, color="red", style="normal"):
|
||||||
color = cmap[i]
|
color = cmap[i]
|
||||||
color_code = str(color)
|
color_code = str(color)
|
||||||
|
|
||||||
|
elif color.lower() == "fraction": # "fraction" or "Fraction"
|
||||||
|
|
||||||
|
# get the different numbers in a list
|
||||||
|
nbs = re.split(r'[^0-9+.,e-]+', text)
|
||||||
|
nbs = [nb for nb in nbs if nb]
|
||||||
|
|
||||||
|
# interpret as decimal
|
||||||
|
try:
|
||||||
|
f = float(nbs[0])/float(nbs[1])
|
||||||
|
except Exception as e:
|
||||||
|
return text
|
||||||
|
|
||||||
|
# if out of scale, do not color
|
||||||
|
if f < 0 or f > 1:
|
||||||
|
return text
|
||||||
|
|
||||||
|
if color[0].islower():
|
||||||
|
mode = 8
|
||||||
|
cmap = colormaps["spectrum"]
|
||||||
|
|
||||||
|
# normalize and scale over the nb of colors in cmap
|
||||||
|
i = int( math.ceil( f * (len(cmap)-1) ) )
|
||||||
|
|
||||||
|
color = cmap[i]
|
||||||
|
color_code = str(30 + colors[color])
|
||||||
|
|
||||||
|
else:
|
||||||
|
mode = 256
|
||||||
|
cmap = colormaps["Spectrum"]
|
||||||
|
i = int( math.ceil( f * (len(cmap)-1) ) )
|
||||||
|
color = cmap[i]
|
||||||
|
color_code = str(color)
|
||||||
|
|
||||||
# "hash" or "Hash"; useful to randomly but consistently color strings
|
# "hash" or "Hash"; useful to randomly but consistently color strings
|
||||||
elif color.lower() == "hash":
|
elif color.lower() == "hash":
|
||||||
hasher = hashlib.md5()
|
hasher = hashlib.md5()
|
||||||
|
|
|
||||||
|
|
@ -24,21 +24,26 @@ def theme():
|
||||||
# Scan
|
# Scan
|
||||||
[ "^(Scanning dependencies of target)(.*)$",
|
[ "^(Scanning dependencies of target)(.*)$",
|
||||||
performing, "normal,bold" ],
|
performing, "normal,bold" ],
|
||||||
# Link
|
# Link (make)
|
||||||
[ "^(Linking .* )(library|executable) (.*/)*(.+(\.[aso]+)*)$",
|
[ "^(Linking .* )(library|executable) (.*/)*(.+(\.[aso]+)*)$",
|
||||||
untimed, "normal,normal,bold" ],
|
untimed, "normal,normal,bold" ],
|
||||||
|
# Link (ninja)
|
||||||
|
[ "^\[[0-9/]+\]\s?(Linking .* )(library|executable) (.*/)*(.+(\.[aso]+)*)$",
|
||||||
|
untimed, "normal,normal,bold" ],
|
||||||
# [percent] Built
|
# [percent] Built
|
||||||
[ "^\[\s*[0-9]+%\]\s(Built target)(\s.*)$",
|
[ "^\[\s*[0-9/]+%?\]\s(Built target)(\s.*)$",
|
||||||
performed, "normal,bold" ],
|
performed, "normal,bold" ],
|
||||||
# [percent] Building
|
# [percent] Building
|
||||||
[ "^\[\s*[0-9]+%\]\s(Building \w* object)(\s+.*/)([-\w]+.c.*)(.o)$",
|
[ "^\[\s*[0-9/]+%?\]\s(Building \w* object)(\s+.*/)([-\w]+.c.*)(.o)$",
|
||||||
performing, "normal,normal,bold,normal"],
|
performing, "normal,normal,bold,normal"],
|
||||||
# [percent] Generating
|
# [percent] Generating
|
||||||
[ "^\[\s*[0-9]+%\]\s(Generating)(\s+.*)$",
|
[ "^\[\s*[0-9/]+%?\]\s(Generating)(\s+.*)$",
|
||||||
performing, "normal,bold"],
|
performing, "normal,bold"],
|
||||||
# make errors
|
# make errors
|
||||||
[ "make\[[0-9]+\].*", "yellow"],
|
[ "make\[[0-9]+\].*", "yellow"],
|
||||||
[ "(make: \*\*\* \[.+\] )(.* [0-9]+)", "red", "normal,bold"],
|
[ "(make: \*\*\* \[.+\] )(.* [0-9]+)", "red", "normal,bold"],
|
||||||
# progress percentage
|
# progress percentage (make)
|
||||||
[ "^(\[\s*[0-9]+%\])","Scale" ]
|
[ "^(\[\s*[0-9]+%\])","Scale" ],
|
||||||
|
# progress percentage (ninja)
|
||||||
|
[ "^(\[[0-9]+/[0-9]+\])","Fraction" ]
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue