-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathuprojectoptions.pas
138 lines (121 loc) · 4.11 KB
/
uprojectoptions.pas
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
unit uprojectoptions;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
const
ETContinuousName='Continuous';
ETDottedName='Dotted';
ETUCDottedName='DOTTED';
type
{$Z1}
TPasPaths=packed record
_File:String;
_Paths:String;
end;
TParser=packed record
_CompilerOptions:String;
TargetOS,TargetCPU:String;
end;
TCircularGraphOptions=packed record
CalcEdgesWeight:Boolean;
end;
TClustersOptions=packed record
PathClusters:Boolean;
CollapseClusters:string;
ExpandClusters:string;
LabelClustersEdges:Boolean;
end;
TFullGraphOptions=packed record
ClustersOptions:TClustersOptions;
IncludeNotFoundedUnits:Boolean;
IncludeInterfaceUses:Boolean;
IncludeImplementationUses:Boolean;
IncludeOnlyCircularLoops:Boolean;
IncludeToGraph:string;
ExcludeFromGraph:string;
OnlyDirectlyUses:Boolean;
DstUnit:string;
SrcUnit:string;
end;
TEdgeType=(ETContinuous,ETDotted);
TGraphBulding=packed record
CircularGraphOptions:TCircularGraphOptions;
FullGraphOptions:TFullGraphOptions;
InterfaceUsesEdgeType:TEdgeType;
ImplementationUsesEdgeType:TEdgeType;
end;
PTProjectOptions=^TProjectOptions;
TProjectOptions=packed record
Paths:TPasPaths;
ParserOptions:TParser;
GraphBulding:TGraphBulding;
end;
TLogDir=(LD_Clear,LD_Report,LD_FullGraph,LD_CircGraph,LD_Explorer);
TLogOpt=set of TLogDir;
TLogWriter=procedure(msg:string; const LogOpt:TLogOpt) of object;
function DefaultProjectOptions:TProjectOptions;
function GetCompilerDefs:String;
function EdgeType2String(ET:TEdgeType):String;
function String2EdgeType(ETn:String):TEdgeType;
implementation
function EdgeType2String(ET:TEdgeType):String;
begin
case ET of
ETContinuous:result:=ETContinuousName;
ETDotted:result:=ETDottedName;
end;
end;
function String2EdgeType(ETn:String):TEdgeType;
begin
if UpperCase(ETn)=ETUCDottedName then
result:=ETDotted
else
result:=ETContinuous;
end;
function GetCompilerDefs:String;
procedure adddef(def:string);
begin
if result='' then
result:=format('-d%s',[def])
else
result:=result+format(' -d%s',[def]);
end;
begin
result:='';
{$ifdef LINUX}adddef('LINUX');{$endif}
{$ifdef WINDOWS}adddef('WINDOWS');{$endif}
{$ifdef MSWINDOWS}adddef('MSWINDOWS');{$endif}
{$ifdef WIN32}adddef('WIN32');{$endif}
{$ifdef LCLWIN32}adddef('LCLWIN32');{$endif}
{$ifdef FPC}adddef('FPC');{$endif}
{$ifdef CPU64}adddef('CPU64');{$endif}
{$ifdef CPU32}adddef('CPU32');{$endif}
{$ifdef LCLWIN32}adddef('LCLWIN32');{$endif}
{$ifdef LCLQT}adddef('LCLQT');{$endif}
{$ifdef LCLQT5}adddef('LCLQT5');{$endif}
{$ifdef LCLGTK2}adddef('LCLGTK2');{$endif}
end;
function DefaultProjectOptions:TProjectOptions;
begin
result.Paths._File:=ExtractFileDir(ParamStr(0))+pathdelim+'passrcerrors.pas';
result.Paths._Paths:=ExtractFileDir(ParamStr(0));
result.ParserOptions._CompilerOptions:='-Sc '+GetCompilerDefs;
result.ParserOptions.TargetOS:={$I %FPCTARGETOS%};
result.ParserOptions.TargetCPU:={$I %FPCTARGETCPU%};
result.GraphBulding.FullGraphOptions.IncludeToGraph:='';
result.GraphBulding.FullGraphOptions.ExcludeFromGraph:='';
result.GraphBulding.FullGraphOptions.IncludeNotFoundedUnits:=false;
result.GraphBulding.FullGraphOptions.IncludeInterfaceUses:=true;
result.GraphBulding.InterfaceUsesEdgeType:=ETContinuous;
result.GraphBulding.FullGraphOptions.IncludeImplementationUses:=true;
result.GraphBulding.ImplementationUsesEdgeType:=ETDotted;
result.GraphBulding.FullGraphOptions.ClustersOptions.PathClusters:=true;
result.GraphBulding.FullGraphOptions.ClustersOptions.CollapseClusters:='';
result.GraphBulding.FullGraphOptions.ClustersOptions.ExpandClusters:='';
result.GraphBulding.FullGraphOptions.ClustersOptions.LabelClustersEdges:=false;
result.GraphBulding.FullGraphOptions.IncludeOnlyCircularLoops:=false;
result.GraphBulding.FullGraphOptions.OnlyDirectlyUses:=false;
result.GraphBulding.CircularGraphOptions.CalcEdgesWeight:=false;
end;
end.