Skip to content

Commit bab8916

Browse files
committed
Added Crinkler support to entropy.
1 parent c51c2ec commit bab8916

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

shader_minifier/entropy.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
QVariant,
2424
)
2525
from time import sleep
26+
from traceback import print_exc
2627

2728

2829
class LinkerType(IntEnum):
@@ -81,9 +82,38 @@ def _run(self: Self) -> int:
8182

8283
if result.returncode == 0:
8384
output: str = result.stdout.decode('utf-8').strip()
84-
[data_size, _, _] = parse("{} + {} = {}", output)
85+
data_size: Optional[float] = None
86+
parsed: bool = False
87+
88+
# Attempt to parse Cold output format.
89+
try:
90+
[data_size, _, _] = parse(
91+
"{} + {} = {}",
92+
output,
93+
)
94+
parsed = True
95+
except:
96+
pass
97+
98+
# Attempt to parse Crinkler output format.
99+
lines: List[str] = list(filter(
100+
lambda line: line.lstrip().startswith("Ideal compressed size of data:"),
101+
output.splitlines(),
102+
))
103+
if len(lines) != 0:
104+
[data_size] = parse(
105+
"Ideal compressed size of data: {}",
106+
lines[0].lstrip().rstrip(),
107+
)
108+
parsed = True
109+
110+
if not parsed:
111+
print("Could not parse build output:")
112+
print(output)
113+
85114
self._versions[hash] = data_size
86115
except:
116+
print_exc()
87117
self._versions[hash] = 'Errored'
88118
self.built.emit(self)
89119

0 commit comments

Comments
 (0)