@@ -31,11 +31,11 @@ TBuilder = class(TObject)
3131 ): String;
3232
3333 function GetHeader (const AHeader: String): String;
34- function GetVariables : String;
34+ function GetVariablesBash : String;
3535 function GetFunctionCompileBash (const AEntry: TEntry): String;
3636 function GetFunctionCompileWindows (const AEntry: TEntry): String;
37- function GetFunctionTest (const AEntry: TEntry): String;
38- function GetFunctionRun (const AEntry: TEntry): String;
37+ function GetFunctionTestBash (const AEntry: TEntry): String;
38+ function GetFunctionRunBash (const AEntry: TEntry): String;
3939 protected
4040 public
4141 constructor Create(AConfigFile: String);
@@ -153,12 +153,15 @@ function TBuilder.GetHeader(const AHeader: String): String;
153153 { $ELSE}
154154 Result:= ' @echo off' + LineEnding + LineEnding;
155155 Result:= Result + ' CALL rsvars' + LineEnding + LineEnding;
156- Result:= Result + ' echo "******** ' + AHeader + ' ********"' + LineEnding;
157- Result:= Result + ' echo' + LineEnding + LineEnding;
156+ Result:= Result + ' setlocal EnableExtensions EnableDelayedExpansion' + LineEnding + LineEnding;
157+ Result:= Result + ' echo "******** ' + AHeader + ' ********"' + LineEnding + LineEnding;
158+ Result:= Result + ' SET param=%1' + LineEnding + LineEnding;
159+ Result:= Result + ' if NOT DEFINED param CALL :all' + LineEnding;
160+ Result:= Result + ' if NOT DEFINED param EXIT /B' + LineEnding + LineEnding;
158161 { $ENDIF}
159162end ;
160163
161- function TBuilder.GetVariables : String;
164+ function TBuilder.GetVariablesBash : String;
162165begin
163166 Result:= ' BIN="' + FConfig.BinLinux + ' "' + LineEnding;
164167 Result:= Result + ' ENTRIES="' + FConfig.EntriesLinux + ' "' + LineEnding;
@@ -218,7 +221,7 @@ function TBuilder.GetFunctionCompileBash(const AEntry: TEntry): String;
218221 ,
219222 [
220223 AEntry.EntryFolder,
221- AEntry.DPR
224+ AEntry.DPROJ
222225 ]) + LineEnding;
223226 { $ENDIF}
224227 Result:= Result + ' echo "==========="' + LineEnding;
@@ -228,24 +231,33 @@ function TBuilder.GetFunctionCompileBash(const AEntry: TEntry): String;
228231function TBuilder.GetFunctionCompileWindows (const AEntry: TEntry): String;
229232begin
230233 Result:= ' :' + AEntry.EntryBinary + LineEnding;
234+ Result:= Result + ' echo ===== ' + UTF8Encode(AEntry.Name ) +' ======' + LineEnding;
231235 Result:= Result +
232236 ' msbuild /t:Build /p:Config=Release /p:platform=Linux64 ' +
233- ConcatPaths([
234- // FConfig.EntriesWindows,
235- AEntry.EntryFolder,
236- AEntry.DPR
237- ]) + LineEnding;
237+ ExpandFileName(
238+ ConcatPaths([
239+ FConfig.EntriesWindows,
240+ AEntry.EntryFolder,
241+ AEntry.DPROJ
242+ ])
243+ ) + LineEnding;
238244 Result:= Result + ' if ERRORLEVEL 0 (' + LineEnding;
239- Result:= Result + ' scp bin\' + AEntry.EntryBinary +
240- ' gcarreno@10.42.0.1:/home/gcarreno/Programming/1brc-ObjectPascal/bin/' +
245+ Result:= Result + ' echo -- Transfering --' + LineEnding;
246+ Result:= Result + ' scp ' +
247+ ExpandFileName(ConcatPaths([
248+ FConfig.BinWindows,
249+ AEntry.EntryBinary
250+ ])) +
251+ ' gcarreno@10.42.0.1:' + FConfig.BinLinux + ' /' +
241252 Aentry.EntryBinary + LineEnding;
242253 Result:= Result + ' ) else (' + LineEnding;
243254 Result:= Result + ' echo ERROR compiling' + LineEnding;
244255 Result:= Result + ' )' + LineEnding;
245- Result:= Result + ' EXIT /B' + LineEnding;
256+ Result:= Result + ' echo ===========' + LineEnding;
257+ Result:= Result + ' EXIT /B' + LineEnding + LineEnding;
246258end ;
247259
248- function TBuilder.GetFunctionTest (const AEntry: TEntry): String;
260+ function TBuilder.GetFunctionTestBash (const AEntry: TEntry): String;
249261var
250262 tmpStr: String;
251263begin
@@ -294,7 +306,7 @@ function TBuilder.GetFunctionTest(const AEntry: TEntry): String;
294306 Result:= Result + ' echo' + LineEnding + ' }' + LineEnding + LineEnding;
295307end ;
296308
297- function TBuilder.GetFunctionRun (const AEntry: TEntry): String;
309+ function TBuilder.GetFunctionRunBash (const AEntry: TEntry): String;
298310var
299311 tmpStr: String;
300312begin
@@ -349,47 +361,31 @@ procedure TBuilder.BuildCompileScriptBash;
349361 line
350362: TJSONStringType;
351363begin
352- { $IFDEF UNIX}
353364 FScriptFile:= IncludeTrailingPathDelimiter(FConfig.RootLinux) + cCompileBash;
354- { $ELSE}
355- FScriptFile:= IncludeTrailingPathDelimiter(FConfig.RootWIndows) + cCompileBash;
356- { $ENDIF}
357365 FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
358366 try
359367 line:= GetHeader(' Compile' );
360- line:= line + GetVariables ;
368+ line:= line + GetVariablesBash ;
361369 for index:= 0 to Pred(FConfig.Entries.Count) do
362370 begin
363371 Write(GenerateProgressBar(index+1 , FConfig.Entries.Count, 50 ), lineBreak);
364372 if not FConfig.Entries[index].Active then continue;
365- { $IFDEF UNIX}
366373 if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
367- { $ELSE}
368- if FConfig.Entries[index].Compiler <> cCompilerDelphi then continue;
369- { $ENDIF}
370374 line:= line + GetFunctionCompileBash(FConfig.Entries[index]);
371375 end ;
372376 line:= line + ' if [ "$1" == "" ];then' + LineEnding;
373377 for index:= 0 to Pred(FConfig.Entries.Count) do
374378 begin
375379 if not FConfig.Entries[index].Active then continue;
376- { $IFDEF UNIX}
377380 if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
378- { $ELSE}
379- if FConfig.Entries[index].Compiler <> cCompilerDelphi then continue;
380- { $ENDIF}
381381 line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
382382 end ;
383383 line:= line + ' else' + LineEnding;
384384 line:= line + ' case $1 in' + LineEnding;
385385 for index:= 0 to Pred(FConfig.Entries.Count) do
386386 begin
387387 if not FConfig.Entries[index].Active then continue;
388- { $IFDEF UNIX}
389388 if FConfig.Entries[index].Compiler <> cCompilerFPC then continue;
390- { $ELSE}
391- if FConfig.Entries[index].Compiler <> cCompilerDelphi then continue;
392- { $ENDIF}
393389 line:= line + ' ' + FConfig.Entries[index].EntryBinary + ' )' + LineEnding;
394390 line:= line + ' ' + FConfig.Entries[index].EntryBinary + LineEnding;
395391 line:= line + ' ;;' + LineEnding;
@@ -419,25 +415,31 @@ procedure TBuilder.BuildCompileScriptCmd;
419415 line:= GetHeader(' Compile' );
420416 for index:=1 to Pred(FConfig.Entries.Count) do
421417 begin
422- Write(GenerateProgressBar(index+1 , FConfig.Entries.Count, 50 ), lineBreak);
423- if not FConfig.Entries[index].Active then continue;
424- line:= line + GetFunctionCompileWindows(FConfig.Entries[index]);
418+ if FConfig.Entries[index].Compiler = cCompilerFPC then Continue;
419+ line:= line + ' if %1 == ' + FConfig.Entries[index].EntryBinary + ' (' + LineEnding;
420+ line:= line + ' CALL :' + FConfig.Entries[index].EntryBinary + LineEnding;
421+ line:= line + ' EXIT /B 0' + LineEnding;
422+ line:= line + ' )' + LineEnding;
425423 end ;
426- line:= line + ' if [%1] == [] (' + LineEnding;
424+ line:= line + ' echo Unknown "%1"' + LineEnding;
425+ line:= line + ' EXIT /B 0' + LineEnding + LineEnding;
426+ line:= line + ' :all' + LineEnding;
427427 for index:=1 to Pred(FConfig.Entries.Count) do
428428 begin
429- line:= line + ' CALL ' + FConfig.Entries[index].EntryBinary + LineEnding;
429+ if not FConfig.Entries[index].Active then continue;
430+ if FConfig.Entries[index].Compiler = cCompilerFPC then Continue;
431+ line:= line + ' CALL :' + FConfig.Entries[index].EntryBinary + LineEnding;
430432 end ;
431- line:= line + ' ) else (' + LineEnding;
433+ line:= line + ' EXIT /B' + LineEnding;
434+ line:= line + LineEnding;
432435 for index:=1 to Pred(FConfig.Entries.Count) do
433436 begin
434- line:= line + ' if %1 == ' + FConfig.Entries[index].EntryBinary + ' ( ' + LineEnding ;
435- line:= line + ' CALL FConfig.Entries[index].EntryBinary ' + LineEnding ;
436- line:= line + ' EXIT 0 ' + LineEnding ;
437- line:= line + ' ) ' + LineEnding ;
437+ Write(GenerateProgressBar(index+ 1 , FConfig.Entries.Count, 50 ), lineBreak) ;
438+ if not FConfig.Entries[index].Active then continue ;
439+ if FConfig.Entries[index].Compiler = cCompilerFPC then Continue ;
440+ line:= line + GetFunctionCompileWindows(FConfig.Entries[index]) ;
438441 end ;
439- line:= line + ' echo Unknown "%1"' + LineEnding;
440- line:= line + ' )' + LineEnding;
442+ FScriptStream.WriteBuffer(line[1 ], Length(line));
441443 finally
442444 FScriptStream.Free;
443445 end ;
@@ -452,12 +454,12 @@ procedure TBuilder.BuildTestScriptBash;
452454 FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
453455 try
454456 line:= GetHeader(' Test' );
455- line:= line + GetVariables ;
457+ line:= line + GetVariablesBash ;
456458 for index:= 0 to Pred(FConfig.Entries.Count) do
457459 begin
458460 Write(GenerateProgressBar(index+1 , FConfig.Entries.Count, 50 ), lineBreak);
459461 if not FConfig.Entries[index].Active then continue;
460- line:= line + GetFunctionTest (FConfig.Entries[index]);
462+ line:= line + GetFunctionTestBash (FConfig.Entries[index]);
461463 end ;
462464 line:= line + ' if [ "$1" == "" ];then' + LineEnding;
463465 for index:= 0 to Pred(FConfig.Entries.Count) do
@@ -497,13 +499,13 @@ procedure TBuilder.BuildRunScriptBash;
497499 FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
498500 try
499501 line:= GetHeader(' Run' );
500- line:= line + GetVariables ;
502+ line:= line + GetVariablesBash ;
501503 for index:= 0 to Pred(FConfig.Entries.Count) do
502504 begin
503505 Write(GenerateProgressBar(index+1 , FConfig.Entries.Count, 50 ), lineBreak);
504506 if not FConfig.Entries[index].Active then continue;
505507 if FConfig.Entries[index].EntryBinary = cBaselineBinary then continue;
506- line:= line + GetFunctionRun (FConfig.Entries[index]);
508+ line:= line + GetFunctionRunBash (FConfig.Entries[index]);
507509 end ;
508510 line:= line + ' if [ "$1" == "" ];then' + LineEnding;
509511 for index:= 0 to Pred(FConfig.Entries.Count) do
0 commit comments