@@ -32,7 +32,8 @@ TBuilder = class(TObject)
3232
3333 function GetHeader (const AHeader: String): String;
3434 function GetVariables : String;
35- function GetFunctionCompile (const AEntry: TEntry): String;
35+ function GetFunctionCompileBash (const AEntry: TEntry): String;
36+ function GetFunctionCompileWindows (const AEntry: TEntry): String;
3637 function GetFunctionTest (const AEntry: TEntry): String;
3738 function GetFunctionRun (const AEntry: TEntry): String;
3839 protected
@@ -41,6 +42,7 @@ TBuilder = class(TObject)
4142 destructor Destroy; override;
4243
4344 procedure BuildCompileScriptBash ;
45+ procedure BuildCompileScriptCmd ;
4446 procedure BuildTestScriptBash ;
4547 procedure BuildRunScriptBash ;
4648 published
@@ -62,6 +64,7 @@ implementation
6264const
6365 lineBreak = #13 ;
6466 cCompileBash = ' compile_all.sh' ;
67+ cCompileCmd = ' compile_all.cmd' ;
6568 cTestBash = ' test_all.sh' ;
6669 cRunBash = ' run_all.sh' ;
6770
@@ -143,36 +146,28 @@ function TBuilder.StringsReplace(
143146
144147function TBuilder.GetHeader (const AHeader: String): String;
145148begin
149+ { $IFDEF UNIX}
146150 Result:= ' #!/bin/bash' + LineEnding + LineEnding;
147151 Result:= Result + ' echo "******** ' + AHeader + ' ********"' + LineEnding;
148152 Result:= Result + ' echo' + LineEnding + LineEnding;
153+ { $ELSE}
154+ Result:= ' @echo off' + LineEnding + LineEnding;
155+ Result:= Result + ' CALL rsvars' + LineEnding + LineEnding;
156+ Result:= Result + ' echo "******** ' + AHeader + ' ********"' + LineEnding;
157+ Result:= Result + ' echo' + LineEnding + LineEnding;
158+ { $ENDIF}
149159end ;
150160
151161function TBuilder.GetVariables : String;
152162begin
153- Result:= ' ' ;
154- { $IFDEF UNIX}
155- Result:= Result + ' BIN="' + FConfig.BinLinux + ' "' + LineEnding;
163+ Result:= ' BIN="' + FConfig.BinLinux + ' "' + LineEnding;
156164 Result:= Result + ' ENTRIES="' + FConfig.EntriesLinux + ' "' + LineEnding;
157165 Result:= Result + ' RESULTS="' + FConfig.ResultsFolder + ' "' + LineEnding;
158166 Result:= Result + ' INPUT="' + FConfig.Input + ' "' + LineEnding;
159- { $ELSE}
160- Result:= Result + ' BIN="' + FConfig.BinWindows + ' "' + LineEnding;
161- Result:= Result + ' ENTRIES="' + FConfig.EntriesWindows + ' "' + LineEnding;
162- Result:= Result + ' DELPHICC="' + FConfig.DelphiCompiler + ' "' + LineEnding;
163- Result:= Result + ' INCLUDE="baseline\Common;c:\program files (x86)\embarcadero\studio\23.0\lib\Linux64\release;C:\Users\gcarr\Documents\Embarcadero\Studio\23.0\Imports;c:\program files (x86)\embarcadero\studio\23.0\Imports;C:\Users\Public\Documents\Embarcadero\Studio\23.0\Dcp\Linux64;c:\program files (x86)\embarcadero\studio\23.0\include;c:\program files (x86)\embarcadero\studio\23.0\redist\Linux64;C:\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\Linux64;C:\Users\gcarr\Documents\Embarcadero\Studio\23.0\CatalogRepository\ChatGPTWizard-2.2.0.9"' + LineEnding;
164- Result:= Result + ' SDK="C:\Users\gcarr\Documents\Embarcadero\Studio\SDKs\ubuntu23.10.sdk"' + LineEnding;
165- Result:= Result + ' LIBPATH="C:\Users\gcarr\Documents\Embarcadero\Studio\SDKs\ubuntu23.10.sdk\usr\lib\gcc\x86_64-linux-gnu\13;C:\Users\gcarr\Documents\Embarcadero\Studio\SDKs\ubuntu23.10.sdk\usr\lib\x86_64-linux-gnu;C:\Users\gcarr\Documents\Embarcadero\Studio\SDKs\ubuntu23.10.sdk\lib\x86_64-linux-gnu;C:\Users\gcarr\Documents\Embarcadero\Studio\SDKs\ubuntu23.10.sdk\lib64"' + LineEnding;
166- Result:= Result + ' BPL="\Users\Public\Documents\Embarcadero\Studio\23.0\Bpl\Linux64"' + LineEnding;
167- Result:= Result + ' DCP="\Users\Public\Documents\Embarcadero\Studio\23.0\Dcp\Linux64"' + LineEnding;
168- Result:= Result + ' GENERICS="Generics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults"' + LineEnding;
169- Result:= Result + ' HEADERS="\Users\Public\Documents\Embarcadero\Studio\23.0\hpp\Linux64"' + LineEnding;
170- Result:= Result + ' DEFINES="RELEASE;LINUX"' + LineEnding;
171- { $ENDIF}
172167 Result:= Result + LineEnding;
173168end ;
174169
175- function TBuilder.GetFunctionCompile (const AEntry: TEntry): String;
170+ function TBuilder.GetFunctionCompileBash (const AEntry: TEntry): String;
176171begin
177172 Result:= ' function ' + AEntry.EntryBinary + ' () {' + LineEnding;
178173 Result:= Result + ' echo "===== ' + UTF8Encode(AEntry.Name ) +' ======"' + LineEnding;
@@ -230,6 +225,26 @@ function TBuilder.GetFunctionCompile(const AEntry: TEntry): String;
230225 Result:= Result + ' echo' + LineEnding + ' }' + LineEnding + LineEnding;
231226end ;
232227
228+ function TBuilder.GetFunctionCompileWindows (const AEntry: TEntry): String;
229+ begin
230+ Result:= ' :' + AEntry.EntryBinary + LineEnding;
231+ Result:= Result +
232+ ' msbuild /t:Build /p:Config=Release /p:platform=Linux64 ' +
233+ ConcatPaths([
234+ // FConfig.EntriesWindows,
235+ AEntry.EntryFolder,
236+ AEntry.DPR
237+ ]) + LineEnding;
238+ 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/' +
241+ Aentry.EntryBinary + LineEnding;
242+ Result:= Result + ' ) else (' + LineEnding;
243+ Result:= Result + ' echo ERROR compiling' + LineEnding;
244+ Result:= Result + ' )' + LineEnding;
245+ Result:= Result + ' EXIT /B' + LineEnding;
246+ end ;
247+
233248function TBuilder.GetFunctionTest (const AEntry: TEntry): String;
234249var
235250 tmpStr: String;
@@ -271,7 +286,7 @@ function TBuilder.GetFunctionTest(const AEntry: TEntry): String;
271286 Result:= Result + Format(' echo "%s Official Output Hash"' ,[
272287 FConfig.OutputHash
273288 ]) + LineEnding;
274- Result:= Result + Format(' rm %s/%s.output' ,[
289+ Result:= Result + Format(' # rm %s/%s.output' ,[
275290 ' ${RESULTS}' ,
276291 AEntry.EntryBinary
277292 ]) + LineEnding;
@@ -352,7 +367,7 @@ procedure TBuilder.BuildCompileScriptBash;
352367 { $ELSE}
353368 if FConfig.Entries[index].Compiler <> cCompilerDelphi then continue;
354369 { $ENDIF}
355- line:= line + GetFunctionCompile (FConfig.Entries[index]);
370+ line:= line + GetFunctionCompileBash (FConfig.Entries[index]);
356371 end ;
357372 line:= line + ' if [ "$1" == "" ];then' + LineEnding;
358373 for index:= 0 to Pred(FConfig.Entries.Count) do
@@ -393,6 +408,41 @@ procedure TBuilder.BuildCompileScriptBash;
393408 { $ENDIF}
394409end ;
395410
411+ procedure TBuilder.BuildCompileScriptCmd ;
412+ var
413+ index: Integer;
414+ line: TJSONStringType;
415+ begin
416+ FScriptFile:= IncludeTrailingPathDelimiter(FConfig.RootWindows) + cCompileCmd;
417+ FScriptStream:= TFileStream.Create(FScriptFile, fmCreate);
418+ try
419+ line:= GetHeader(' Compile' );
420+ for index:=1 to Pred(FConfig.Entries.Count) do
421+ 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]);
425+ end ;
426+ line:= line + ' if [%1] == [] (' + LineEnding;
427+ for index:=1 to Pred(FConfig.Entries.Count) do
428+ begin
429+ line:= line + ' CALL ' + FConfig.Entries[index].EntryBinary + LineEnding;
430+ end ;
431+ line:= line + ' ) else (' + LineEnding;
432+ for index:=1 to Pred(FConfig.Entries.Count) do
433+ 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;
438+ end ;
439+ line:= line + ' echo Unknown "%1"' + LineEnding;
440+ line:= line + ' )' + LineEnding;
441+ finally
442+ FScriptStream.Free;
443+ end ;
444+ end ;
445+
396446procedure TBuilder.BuildTestScriptBash ;
397447var
398448 index: Integer;
0 commit comments