forked from Memnarch/Delphinus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDN.JSonFile.Installation.pas
More file actions
180 lines (165 loc) · 4.98 KB
/
DN.JSonFile.Installation.pas
File metadata and controls
180 lines (165 loc) · 4.98 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
{
#########################################################
# Copyright by Alexander Benikowski #
# This unit is part of the Delphinus project hosted on #
# https://github.com/Memnarch/Delphinus #
#########################################################
}
unit DN.JSonFile.Installation;
interface
uses
Types,
DN.JSon,
DN.JSOnFile,
DN.Compiler.Intf;
type
TSearchPath = record
Path: string;
CompilerMin: Integer;
CompilerMax: Integer;
Platforms: TDNCompilerPlatforms;
end;
TFolder = record
Folder: string;
Recursive: Boolean;
Filter: string;
Base: string;
CompilerMin: Integer;
CompilerMax: Integer;
end;
TProject = record
Project: string;
CompilerMin: Integer;
CompilerMax: Integer;
end;
TInstallationFile = class(TJSonFile)
private
FSourceFolders: TArray<TFolder>;
FSearchPath: TArray<TSearchPath>;
FProjects: TArray<TProject>;
FBrowsingPathes: TArray<TSearchPath>;
protected
procedure LoadPathes(const ARoot: TJSONObject; const AName: string; out APathes: TArray<TSearchPath>);
procedure Load(const ARoot: TJSONObject); override;
function GetPlatforms(const APlatforms: string): TDNCompilerPlatforms;
public
property SearchPathes: TArray<TSearchPath> read FSearchPath;
property BrowsingPathes: TArray<TSearchPath> read FBrowsingPathes;
property SourceFolders: TArray<TFolder> read FSourceFolders;
property Projects: TArray<TProject> read FProjects;
end;
implementation
uses
SysUtils,
StrUtils;
{ TInstallationFile }
function TInstallationFile.GetPlatforms(
const APlatforms: string): TDNCompilerPlatforms;
var
LPlatforms: TStringDynArray;
LPlatform: string;
begin
LPlatforms := SplitString(APlatforms, ';');
if Length(LPlatforms) > 0 then
begin
Result := [];
for LPlatform in LPlatforms do
begin
if SameText(LPlatform, 'Win32') then
Result := Result + [cpWin32]
else if SameText(LPlatform, 'Win64') then
Result := Result + [cpWin64]
else if SameText(LPlatform, 'OSX32') then
Result := Result + [cpOSX32]
end;
end
else
begin
Result := [cpWin32];
end;
end;
procedure TInstallationFile.Load(const ARoot: TJSONObject);
var
LArray: TJSonArray;
LItem: TJSONObject;
i: Integer;
LCompiler: Integer;
begin
inherited;
LoadPathes(ARoot, 'search_pathes', FSearchPath);
LoadPathes(ARoot, 'browsing_pathes', FBrowsingPathes);
if ReadArray(ARoot, 'source_folders', LArray) then
begin
SetLength(FSourceFolders, LArray.Count);
for i := 0 to Pred(LArray.Count) do
begin
LItem := LArray.Items[i] as TJSONObject;
FSourceFolders[i].Folder := ReadString(LItem, 'folder');
FSourceFolders[i].Base := ReadString(LItem, 'base');
FSourceFolders[i].Recursive := ReadBoolean(LItem, 'recursive');
FSourceFolders[i].Filter := ReadString(LItem, 'filter');
LCompiler := ReadInteger(LItem, 'compiler');
if LCompiler > 0 then
begin
FSourceFolders[i].CompilerMin := LCompiler;
FSourceFolders[i].CompilerMax := LCompiler;
end
else
begin
FSourceFolders[i].CompilerMin := ReadInteger(LItem, 'compiler_min');
FSourceFolders[i].CompilerMax := ReadInteger(LItem, 'compiler_max');
end;
end;
end;
if ReadArray(ARoot, 'projects', LArray) then
begin
SetLength(FProjects, LArray.Count);
for i := 0 to Pred(LArray.Count) do
begin
LItem := LArray.Items[i] as TJSONObject;
FProjects[i].Project := ReadString(LItem, 'project');
LCompiler := ReadInteger(LItem, 'compiler');
if LCompiler > 0 then
begin
FProjects[i].CompilerMin := LCompiler;
FProjects[i].CompilerMax := LCompiler;
end
else
begin
FProjects[i].CompilerMin := ReadInteger(LItem, 'compiler_min');
FProjects[i].CompilerMax := ReadInteger(LItem, 'compiler_max');
end;
end;
end;
end;
procedure TInstallationFile.LoadPathes(const ARoot: TJSONObject;
const AName: string; out APathes: TArray<TSearchPath>);
var
LArray: TJSonArray;
LItem: TJSONObject;
i: Integer;
LCompiler: Integer;
begin
if ReadArray(ARoot, AName, LArray) then
begin
SetLength(APathes, LArray.Count);
for i := 0 to Pred(LArray.Count) do
begin
LItem := LArray.Items[i] as TJSONObject;
APathes[i].Path := ReadString(LItem, 'pathes');
LCompiler := ReadInteger(LItem, 'compiler');
if LCompiler > 0 then
begin
APathes[i].CompilerMin := LCompiler;
APathes[i].CompilerMax := LCompiler;
end
else
begin
APathes[i].CompilerMin := ReadInteger(LItem, 'compiler_min');
APathes[i].CompilerMax := ReadInteger(LItem, 'compiler_max');
end;
APathes[i].Platforms := GetPlatforms(ReadString(LItem, 'platforms'));
end;
end;
end;
end.