blob: 698d25697e99de3a438977f4849e0d85e37fab43 [file] [log] [blame]
Roger Meier5b9693c2012-02-28 19:32:55 +00001@echo off
2if ""=="%1" goto CONFIG
3goto HANDLEDIR
4
5REM -----------------------------------------------------
6:CONFIG
7REM -----------------------------------------------------
8
9rem * CONFIGURATION BEGIN
10rem * configuration settings, adjust as necessary to meet your system setup
11set SVNWORKDIR=
12set MY_THRIFT_FILES=
13set BIN=C:\MSys10\local\bin
14set MINGW_BIN=C:\MinGW\bin
15set DCC=
16set SUBDIR=gen-delphi
17rem * CONFIGURATION END
18
19
20REM -----------------------------------------------------
21:START
22REM -----------------------------------------------------
23
24rem * configured?
25if "%SVNWORKDIR%"=="" goto CONFIG_ERROR
26
27rem * try to find dcc32.exe
28echo Looking for dcc32.exe ...
29if not exist "%DCC%" set DCC=%ProgramFiles%\Embarcadero\RAD Studio\8.0\bin\dcc32.exe
30if not exist "%DCC%" set DCC=%ProgramFiles(x86)%\Embarcadero\RAD Studio\8.0\bin\dcc32.exe
31if not exist "%DCC%" goto CONFIG_ERROR
32echo Found %DCC%
33echo.
34
35rem * some helpers
36set PATH=%BIN%;%MINGW_BIN%;%PATH%
37set TARGET=%SVNWORKDIR%\..\thrift-testing
38set SOURCE=%SVNWORKDIR%
39set TESTAPP=TestProject
40set UNITSEARCH=%SOURCE%\lib\pas\src;%SOURCE%\lib\delphi\src
41set OUTDCU="%TARGET%\dcu"
42set LOGFILE=%TARGET%\%SUBDIR%\codegen.log
43
44rem * create and/or empty target dirs
45if not exist "%TARGET%" md "%TARGET%"
46if not exist "%TARGET%\%SUBDIR%" md "%TARGET%\%SUBDIR%"
47if not exist "%OUTDCU%" md "%OUTDCU%"
48if exist "%TARGET%\*.thrift" del "%TARGET%\*.thrift" /Q
49if exist "%TARGET%\%SUBDIR%\*.*" del "%TARGET%\%SUBDIR%\*.*" /Q
50if exist "%OUTDCU%\*.*" del "%OUTDCU%\*.*" /Q
51
52rem * recurse through thrift WC and "my thrift files" folder
53rem * copies all .thrift files into thrift-testing
54call %0 %SOURCE%
55if not "%MY_THRIFT_FILES%"=="" call %0 %MY_THRIFT_FILES%
56
57rem * compile all thrift files, generate PAS and C++ code
58echo.
59echo Generating code, please wait ...
60cd "%TARGET%"
Jens Geyerd95fc9b2014-02-02 18:08:31 +010061for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen delphi:ansistr_binary,register_types,constprefix,events,xmldoc "%%a" 2>> "%LOGFILE%"
Roger Meier5b9693c2012-02-28 19:32:55 +000062REM * for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen cpp "%%a" >> NUL:
63cmd /c start notepad "%LOGFILE%"
64cd ..
65
66rem * check for special Delphi testcases being processed
67if not exist "%TARGET%\%SUBDIR%\ReservedKeywords.pas" goto TESTCASE_MISSING
68
69
70rem * generate a minimal DPR file that uses all generated pascal units
71cd "%TARGET%\%SUBDIR%\"
72if exist inherited.* ren inherited.* _inherited.*
73echo program %TESTAPP%; > %TESTAPP%.dpr
74echo {$APPTYPE CONSOLE} >> %TESTAPP%.dpr
75echo. >> %TESTAPP%.dpr
76echo uses >> %TESTAPP%.dpr
77for %%a in (*.pas) do echo %%~na, >> %TESTAPP%.dpr
78echo Windows, Classes, SysUtils; >> %TESTAPP%.dpr
79echo. >> %TESTAPP%.dpr
80echo begin >> %TESTAPP%.dpr
81echo Writeln('Successfully compiled!'); >> %TESTAPP%.dpr
82echo Writeln('List of units:'); >> %TESTAPP%.dpr
83for %%a in (*.pas) do echo Write('%%~na':30,'':10); >> %TESTAPP%.dpr
84echo Writeln; >> %TESTAPP%.dpr
85echo end. >> %TESTAPP%.dpr
86echo. >> %TESTAPP%.dpr
87cd ..\..
88
89rem * try to compile the DPR
90rem * this should not throw any errors, warnings or hints
91"%DCC%" -B "%TARGET%\%SUBDIR%\%TESTAPP%" -U"%UNITSEARCH%" -I"%UNITSEARCH%" -N"%OUTDCU%" -E"%TARGET%\%SUBDIR%"
92dir "%TARGET%\%SUBDIR%\%TESTAPP%.exe"
93if not exist "%TARGET%\%SUBDIR%\%TESTAPP%.exe" goto CODEGEN_FAILED
94echo.
95echo -----------------------------------------------------------------
96echo The compiled program is now executed. If it hangs or crashes, we
97echo have a serious problem with the generated code. Expected output
98echo is "Successfully compiled:" followed by a list of generated units.
99echo -----------------------------------------------------------------
100"%TARGET%\%SUBDIR%\%TESTAPP%.exe"
101echo -----------------------------------------------------------------
102echo.
103pause
104GOTO EOF
105
106REM -----------------------------------------------------
107:DXE_NOT_FOUND
108REM -----------------------------------------------------
109echo Delphi Compiler (dcc32.exe) not found.
110echo Please check the "DCC" setting in this batch.
111echo.
Jens Geyerc02618c2014-04-10 01:16:48 +0200112cmd /c start notepad README.MD
Roger Meier5b9693c2012-02-28 19:32:55 +0000113cmd /c start notepad %0
114pause
115GOTO EOF
116
117
118REM -----------------------------------------------------
119:CONFIG_ERROR
120REM -----------------------------------------------------
121echo Missing, incomplete or wrong configuration settings!
Jens Geyerc02618c2014-04-10 01:16:48 +0200122cmd /c start notepad README.MD
Roger Meier5b9693c2012-02-28 19:32:55 +0000123cmd /c start notepad %0
124pause
125GOTO EOF
126
127
128REM -----------------------------------------------------
129:TESTCASE_MISSING
130REM -----------------------------------------------------
131echo Missing an expected Delphi testcase!
132pause
133GOTO EOF
134
135
136REM -----------------------------------------------------
137:CODEGEN_FAILED
138REM -----------------------------------------------------
139echo Code generation FAILED!
140pause
141GOTO EOF
142
143
144REM -----------------------------------------------------
145:HANDLEDIR
146REM -----------------------------------------------------
147REM echo %1
148for /D %%a in (%1\*) do call %0 %%a
149if exist "%1\*.thrift" copy /b "%1\*.thrift" "%TARGET%\*.*"
150GOTO EOF
151
152
153REM -----------------------------------------------------
154:EOF
155REM -----------------------------------------------------