Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/clean_webconsole.py
4128 views
1
# Copyright 2012 The Emscripten Authors. All rights reserved.
2
# Emscripten is available under two separate licenses, the MIT license and the
3
# University of Illinois/NCSA Open Source License. Both these licenses can be
4
# found in the LICENSE file.
5
6
"""Removes timestamp and line info from a webgl log
7
"""
8
9
import os
10
import re
11
import sys
12
from pathlib import Path
13
14
__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15
16
17
def path_from_root(*pathelems):
18
return os.path.join(__rootpath__, *pathelems)
19
20
21
def nice(x):
22
return '0x' + ('0' * (len(x) - 6)) + x[2:].upper()
23
24
25
repdata = (
26
Path(path_from_root('system/include/GL/gl.h')).read_text().splitlines(keepends=True) +
27
['\n'] +
28
Path(path_from_root('system/include/GL/glext.h')).read_text().splitlines(keepends=True)
29
)
30
reps = {}
31
for rep in repdata:
32
rep = rep.replace('\t', ' ').replace('\n', '')
33
parts = [part for part in rep.split(' ') if part != '']
34
if len(parts) == 3 and parts[0] == '#define':
35
reps[nice(parts[2])] = '%s (%s)' % (parts[1], parts[2])
36
37
lines = sys.stdin.read().split('\n')
38
39
for line in lines:
40
if line.startswith('['):
41
line = line[15:]
42
line = line.split(' @ ')[0]
43
line = re.sub(r'(0x[\dabcdef]+)', lambda hexx: reps[nice(hexx.group(0))] if nice(hexx.group(0)) in reps else nice(hexx.group(0)), line)
44
print(line)
45
46