@@ -14,6 +14,8 @@ interface
1414;
1515
1616type
17+ { EPatternsLengthDonMatch }
18+ EPatternsLengthDonMatch = Exception;
1719{ TBuilder }
1820 TBuilder = class (TObject)
1921 private
@@ -22,6 +24,11 @@ TBuilder = class(TObject)
2224 FScriptFile: String;
2325
2426 function GenerateProgressBar (APBPosition, APBMax, APBWIdth: Integer): String;
27+ function StringsReplace (
28+ const AString: String;
29+ const AOLdPattern, ANewPattern: TStringArray;
30+ const AFlags: TReplaceFlags
31+ ): String;
2532 protected
2633 public
2734 constructor Create(AConfigFile: String);
@@ -33,8 +40,6 @@ TBuilder = class(TObject)
3340 procedure BuildRunScriptBash ;
3441 { $ELSE}
3542 procedure BuildCompileScriptPowerShell ;
36- procedure BuildTestScriptPowerShell ;
37- procedure BuildRunScriptPowerShell ;
3843 { $ENDIF}
3944 published
4045 end ;
@@ -67,6 +72,9 @@ implementation
6772 cCompilerFPC = ' fpc' ;
6873// cCompilerDelphi = 'delphi';
6974
75+ resourcestring
76+ rsEPatternsLengthDOntMatch = ' Patterns length does not match' ;
77+
7078{ TBuilder }
7179
7280constructor TBuilder.Create(AConfigFile: String);
@@ -105,6 +113,23 @@ function TBuilder.GenerateProgressBar(APBPosition, APBMax, APBWIdth: Integer
105113 Result := Result + Format(' ] %5.2f %%' , [percentDone]);
106114end ;
107115
116+ function TBuilder.StringsReplace (
117+ const AString: String;
118+ const AOLdPattern, ANewPattern: TStringArray;
119+ const AFlags: TReplaceFlags
120+ ): String;
121+ var
122+ index: Integer;
123+ begin
124+ Result:= AString;
125+ if Length(AOLdPattern) <> Length(ANewPattern) then
126+ raise EPatternsLengthDonMatch.Create(rsEPatternsLengthDOntMatch);
127+ for index:= Low(AOLdPattern) to High(AOLdPattern) do
128+ begin
129+ Result:= StringReplace(Result, AOLdPattern[index], ANewPattern[index], AFlags);
130+ end ;
131+ end ;
132+
108133procedure TBuilder.BuildCompileScriptBash ;
109134var
110135 index: Integer;
@@ -154,7 +179,8 @@ procedure TBuilder.BuildCompileScriptBash;
154179{ $IFNDEF UNIX}
155180procedure TBuilder.BuildCompileScriptPowerShell ;
156181begin
157-
182+ { #todo 99 -ogcarreno : Using the command line compiler, compile the binary for Linux 64b }
183+ { #todo 99 -ogcarreno : Using scp copy the resulting binary to Linux }
158184end ;
159185{ $ENDIF}
160186
@@ -176,16 +202,16 @@ procedure TBuilder.BuildTestScriptBash;
176202 FConfig.Entries[index].EntryBinary,
177203 FConfig.Entries[index].RunParams
178204 ]);
179- tmpStr:= StringReplace(
180- tmpStr,
181- cReplaceEntryInput,
182- FConfig.InputSSD,
183- [rfReplaceAll]
184- );
185- tmpStr:= StringReplace(
205+ tmpStr:= StringsReplace(
186206 tmpStr,
187- cReplaceEntryThreads,
188- IntToStr(FConfig.Entries[index].Threads),
207+ [
208+ cReplaceEntryInput,
209+ cReplaceEntryThreads
210+ ],
211+ [
212+ FConfig.InputSSD,
213+ IntToStr(FConfig.Entries[index].Threads)
214+ ],
189215 [rfReplaceAll]
190216 );
191217 tmpStr:= Format(' %s > %s%s.output' , [
@@ -212,13 +238,6 @@ procedure TBuilder.BuildTestScriptBash;
212238 FpChmod(PChar(FScriptFile), &775 );
213239end ;
214240
215- { $IFNDEF UNIX}
216- procedure TBuilder.BuildTestScriptPowerShell ;
217- begin
218-
219- end ;
220- { $ENDIF}
221-
222241procedure TBuilder.BuildRunScriptBash ;
223242var
224243 index: Integer;
@@ -232,42 +251,38 @@ procedure TBuilder.BuildRunScriptBash;
232251 begin
233252 Write(GenerateProgressBar(index+1 , FConfig.Entries.Count, 50 ), lineBreak);
234253 line:= line + ' echo "===== ' + FConfig.Entries[index].Name +' ======"' + LineEnding;
235- tmpStr := StringReplace(
236- FConfig.Hyperfine,
237- cReplaceName,
238- FConfig.Entries[index].EntryBinary,
239- [rfReplaceAll]
240- );
241254 // Run for SSD
242- tmpStr := StringReplace(
243- tmpStr,
244- cReplaceJSONResults,
245- Format(' %s%s' , [
246- IncludeTrailingPathDelimiter(FConfig.ResultsFolder),
247- FConfig.Entries[index].EntryBinary + ' -1_000_000_000-SSD.json'
248- ]),
249- [rfReplaceAll]
250- );
251- tmpStr := StringReplace(
252- tmpStr,
253- cReplaceEntryBinary,
254- Format(' %s%s %s' , [
255- IncludeTrailingPathDelimiter(FConfig.BinFolder),
255+ tmpStr:= StringsReplace(
256+ FConfig.Hyperfine,
257+ [
258+ cReplaceName,
259+ cReplaceJSONResults,
260+ cReplaceEntryBinary
261+ ],
262+ [
256263 FConfig.Entries[index].EntryBinary,
257- FConfig.Entries[index].RunParams
258- ]),
259- [rfReplaceAll]
260- );
261- tmpStr := StringReplace(
262- tmpStr,
263- cReplaceEntryInput,
264- FConfig.InputSSD,
264+ Format(' %s%s' , [
265+ IncludeTrailingPathDelimiter(FConfig.ResultsFolder),
266+ FConfig.Entries[index].EntryBinary + ' -1_000_000_000-SSD.json'
267+ ]),
268+ Format(' %s%s %s' , [
269+ IncludeTrailingPathDelimiter(FConfig.BinFolder),
270+ FConfig.Entries[index].EntryBinary,
271+ FConfig.Entries[index].RunParams
272+ ])
273+ ],
265274 [rfReplaceAll]
266275 );
267- tmpStr := StringReplace (
276+ tmpStr:= StringsReplace (
268277 tmpStr,
269- cReplaceEntryThreads,
270- IntToStr(FConfig.Entries[index].Threads),
278+ [
279+ cReplaceEntryInput,
280+ cReplaceEntryThreads
281+ ],
282+ [
283+ FConfig.InputSSD,
284+ IntToStr(FConfig.Entries[index].Threads)
285+ ],
271286 [rfReplaceAll]
272287 );
273288 line:= line + ' echo "-- SSD --"' + LineEnding + tmpStr + LineEnding;
@@ -295,11 +310,4 @@ procedure TBuilder.BuildRunScriptBash;
295310 FpChmod(PChar(FScriptFile), &775 );
296311end ;
297312
298- { $IFNDEF UNIX}
299- procedure TBuilder.BuildRunScriptPowerShell ;
300- begin
301-
302- end ;
303- { $ENDIF}
304-
305313end .
0 commit comments