-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildLogDigest.mnh
110 lines (99 loc) · 4.51 KB
/
buildLogDigest.mnh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/mnh_light
IGNORED_CODES:=[1002,1008,1021,1022,1023,
3018,3019,3100,3104,
4056,4035,4055,
5036,5044,
9015,9022,6058];
ALWAYS_IGNORED_CODES:=[1023,1022,1021,1008,3104,9022,9015,1002,6058];
IGNORED_PATTERNS:=['3rd_party',
'mnhcustomform.*\(5092\)',
'myGenerics.*\(5092\)',
'C:/Users/mschl/AppData/Local/lazarus/onlinepackagemanager',
'/ide/.*\(5024\)',
'\(5066\).*Symbol "UTF8CharacterLength" is deprecated: "Use UTF8CodepointSize instead."',
'/core/litvar.*\(5024\).*"(adapters|lengthLimit|minusLocation|threadContext|relation|other|literalRecycler)"',
'/core/litvar.*\(5058\).*"stringSingletonsCs"',
'/core/func_defines\.inc.*\(5024\)',
'/core/tokenArray\.pas.*\(5023\).*"strutils"',
'/consoles/substitute_funcs\.pas.*\(5024\)',
'/core/funcs_interpolators\.pas.*\(5024\)',
'/core/out_adapters\.pas.*\(5024\)',
'/core/profiling\.pas.*\(5024\)',
'/core/profiling\.pas.*\(5092\).*"locationToIdMap"',
'/core/operators.*\(5059\)',
'/core/funcs_files.*\(6018\)',
'\(5024\) *Parameter "(context|location|recycler|parameters|lengthLimit)" not used',
'igSrc.*\(5024\).*"(ix|iy|c|style|nameMode|parameters)"',
'/core/listProcessing.*\(5089\).*"nextToEnqueue"',
'editors/mnhCompletion.*\(5092\).*"sourceValue"',
'/core/tokenArray.*\(5023\).*"strutils"'];
splitMessage(message:String)->begin
errorCode:=message.matchComposite('\(....\)').trailing[0];
fileLine :=message.matchComposite('\(\d*,\d*\)').trailing[0];
errorCode.isVoid OR fileLine.isVoid ? return void : void;
parts:=message.split([fileLine,errorCode]);
numericLine:=fileLine.unbrace.split(",").softCast;
[replace(parts[0],'/./','/'),//filename
"(",numericLine[0],",",numericLine[1],")\t",
parts[1],//message type
"\t",errorCode,"\t"]|parts.tail(2);
end;
private currentViolations(doFilter:Boolean)->'build.log'.fileLines
.pEach(line,line.matches('\('&(doFilter ? IGNORED_CODES: ALWAYS_IGNORED_CODES)&'\)').agg(OR) ? void : line)
.replace('\','/')
.pEach(line,line.replace(['/media/',DEV_ROOT.extractFileDirectory],'').replace('\','/'))
.{doFilter ? $L.pEach(line,line.matches(IGNORED_PATTERNS).agg(OR) ? void : line) : $L}
.map(::splitMessage)
.elementFrequency
.map({$x[1]|"\vx\t"|$x[0]})
.sort(6).sort(4).sort(2)
.map(::join);
//*Check for new violations
main->currentViolations(true)
.{$violations.size=0 ? print("No violations found after filtering") : $violations.join("\n").print}
orElse print('For all warnings use ',myPath.extractFileName,' unfiltered');
main('unfiltered')->printf("%s",currentViolations(false));
private existing(f:String)->fileExists(f) ? f : void;
DEV_ROOT:=myPath.extractFileDirectory.extractFileDirectory.replace('/','\');
USE make_config;
//*Check file usage
main('files')->begin
newList:='build.log'.fileLines
.{$L[$L.matches('\(3104\)')]}
.unique
.replace('(3104) Compiling','')
.replace('/media/dev/mnh5','')
.replace('/media/dev/','../')
.replace(DEV_ROOT&'\mnh5\','')
.replace(DEV_ROOT&'\','..\')
.replace('\','/')
.trim
.unique
.each(file,existing(file) orElse
existing('consoles/'&file) orElse
existing('ide/'&file))
.replace('/./','/')
.union(allFiles('ide',['*.inc','*.lpr']),
allFiles('consoles','*.lpr'),
allFiles('common','*.inc'),
allFiles('3rd_party','*.inc'),
allFiles('core','*.inc')).minus(['core/res_version.inc','ide/res_toDeleteOnUninstall.inc'])
.minus(['ide/res_examples.inc'])
.sort;
newList==hashFiles
? return print('List is up to date')
: print('Added : ',newList.minus(hashFiles).toList,
"\nRemoved: ",hashFiles.minus(newList).toList);
make_config_path:=inspect['uses','make_config'];
markerRead:=false;
newFileLines:=
fileLines(make_config_path).each(line,markerRead ? void :
line.hasPrefix('hashFiles:=[')
? begin markerRead:=true; void; end
: line);
newFileLines|=
join(["hashFiles:=[\v",newList.map(::escape).join(",\n\v"),'];']).formatTabs;
writeFileLines(make_config_path,newFileLines);
execPipeless(executor,[systemSpecificFilename(myPath.extractFileDirectory&'/'&'make.mnh'),
'prepare']);
end;