Skip to content

Commit 571a71d

Browse files
committed
Create Makefile.bat
1 parent 09c32b9 commit 571a71d

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

src/Makefile.bat

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
@echo off
2+
rem
3+
rem Windows Makefile for PAS2JS and verification of regresssion tests during refactorings.
4+
rem
5+
rem Set %WUDSN_TOOLS_FOLDER% to the folder with the latest https://github.com/wudsn/wudsn-ide-tools
6+
rem The script will use the FPC, MP and MADS version from there as reference.
7+
rem
8+
rem The script compiles "Test-0.pas" with FPC vs. the new MP.
9+
rem The script compiles a set of reference examples with the released and the new MP an validates that there are no differences in the binary output.
10+
11+
setlocal
12+
set PATH=%WUDSN_TOOLS_FOLDER%\PAS\FPC.jac;%WUDSN_TOOLS_FOLDER%\ASM\MADS\bin\windows_x86_64;%PATH%
13+
set MP_FOLDER=%~dp0..
14+
set MP_SRC_FOLDER=%MP_FOLDER%\src
15+
16+
rem set TEST_EXE=%MP_SRC_FOLDER%\Test-0.exe
17+
set MP_EXE=%MP_SRC_FOLDER%\mp.exe
18+
19+
set WUDSN_MP_EXE=%WUDSN_TOOLS_FOLDER%\PAS%\MP\bin\windows\mp.exe
20+
21+
cd /d %MP_SRC_FOLDER%
22+
23+
if not "%TEST_EXE%"=="" (
24+
if exist "%TEST_EXE%" del "%TEST_EXE%"
25+
call fpc.bat %MP_SRC_FOLDER%\Test-0.pas
26+
if errorlevel 1 goto :eof
27+
if exist "%TEST_EXE%" (
28+
echo Starting test program "%TEST_EXE%".
29+
%TEST_EXE%
30+
)
31+
)
32+
33+
if not "%MP_EXE%"=="" (
34+
35+
rem Regression test with standard MP.
36+
if 1==1 (
37+
echo.
38+
echo INFO: Compiling with WUDSN version.
39+
echo ===================================
40+
echo.
41+
call :run_tests %WUDSN_MP_EXE%
42+
)
43+
44+
45+
echo.
46+
echo.
47+
echo INFO: Comiling with new version.
48+
echo ================================
49+
echo.
50+
if exist "%MP_EXE%" del "%MP_EXE%"
51+
call fpc.bat %MP_SRC_FOLDER%\mp.pas
52+
if errorlevel 1 goto :eof
53+
if exist "%MP_EXE%" (
54+
call :run_tests %MP_EXE%
55+
)
56+
)
57+
58+
goto :eof
59+
60+
rem IN: %1=Path to mp.exe´, %2=Folder of test source %3=File name without file extension of the ".pas" file
61+
:run_mp
62+
set MP=%1
63+
set TEST_FOLDER=%2
64+
set TEST_MP=%3
65+
66+
set MP_INPUT_PAS=%TEST_MP%.pas
67+
set MP_OUTPUT_ASM=%TEST_MP%.a65
68+
set MADS_OUTPUT_XEX_REF=%TEST_MP%-Reference.xex
69+
echo %MADS_OUTPUT_XEX_REF%
70+
if %MP%==%WUDSN_MP_EXE% (
71+
set MADS_OUTPUT_XEX=%MADS_OUTPUT_XEX_REF%
72+
) else (
73+
set MADS_OUTPUT_XEX=%TEST_MP%.xex
74+
)
75+
pushd %TEST_FOLDER%
76+
echo INFO: Compiling "%MP_INPUT_PAS%" in "%TEST_FOLDER%" with "%MP%".
77+
if exist %MP_OUTPUT_ASM% del %MP_OUTPUT_ASM%
78+
%MP% -ipath:%MP_FOLDER%\lib %MP_INPUT_PAS%
79+
if errorlevel 1 goto :mp_error
80+
if exist %MP_OUTPUT_ASM% (
81+
if exist %MADS_OUTPUT_XEX% del %MADS_OUTPUT_XEX%
82+
mads %MP_OUTPUT_ASM% -x -i:%MP_FOLDER%\base -o:%MADS_OUTPUT_XEX%
83+
if exist %MADS_OUTPUT_XEX% (
84+
echo Starting test program "%MADS_OUTPUT_XEX%".
85+
rem %MADS_OUTPUT_XEX%
86+
) else (
87+
echo ERROR: MADS output file %MADS_OUTPUT_XEX% not created.
88+
pause
89+
)
90+
) else (
91+
echo ERROR: MP output file %MP_OUTPUT_ASM% not created.
92+
pause
93+
)
94+
95+
REM TODO Compare file if both files reference exists
96+
if not "%MADS_OUTPUT_XEX%" == "%MADS_OUTPUT_XEX_REF%" (
97+
if exist %MADS_OUTPUT_XEX% (
98+
99+
if exist %MADS_OUTPUT_XEX_REF% (
100+
fc /b %MADS_OUTPUT_XEX% %MADS_OUTPUT_XEX_REF%
101+
if errorlevel 1 goto :fc_error
102+
) else (
103+
echo WARNING: Reference file "%MADS_OUTPUT_XEX_REF%" does not exist, no comparsion possible.
104+
)
105+
)
106+
)
107+
popd
108+
goto :eof
109+
110+
:mp_error
111+
popd
112+
echo ERROR: Mad-Pascal error.
113+
pause
114+
goto :eof
115+
116+
117+
:fc_error
118+
popd
119+
echo ERROR: %MADS_OUTPUT_XEX% and %MADS_OUTPUT_XEX_REF% are binary different.
120+
pause
121+
goto :eof
122+
123+
rem Run all tests with a given mp.exe.
124+
rem IN: Path to mp.exe
125+
rem
126+
:run_tests
127+
rem call :run_mp % %MP_SRC_FOLDER% Test-MPP
128+
rem call :run_mp %1=%MP_FOLDER%\samples\a8\games\PacMad pacmadd
129+
call :run_mp %1 %MP_FOLDER%\samples\a8\graph_crossplatform fedorahat
130+
call :run_mp %1 %MP_FOLDER%\samples\a8\graph_crossplatform cannabis
131+
call :run_mp %1 %MP_FOLDER%\samples\a8\graph_crossplatform snowflake
132+
call :run_mp %1 %MP_FOLDER%\samples\a8\graph_crossplatform spline
133+
call :run_mp %1 %MP_FOLDER%\samples\a8\graph_crossplatform fern
134+
goto :eof
135+

0 commit comments

Comments
 (0)