blob: 79cf0e3396af8265cf2bbc35add21938e6c476d9 [file] [log] [blame]
Jens Geyer703200c2014-04-15 21:54:55 +02001REM /*
2REM * Licensed to the Apache Software Foundation (ASF) under one
3REM * or more contributor license agreements. See the NOTICE file
4REM * distributed with this work for additional information
5REM * regarding copyright ownership. The ASF licenses this file
6REM * to you under the Apache License, Version 2.0 (the
7REM * "License"); you may not use this file except in compliance
8REM * with the License. You may obtain a copy of the License at
9REM *
10REM * http://www.apache.org/licenses/LICENSE-2.0
11REM *
12REM * Unless required by applicable law or agreed to in writing,
13REM * software distributed under the License is distributed on an
14REM * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15REM * KIND, either express or implied. See the License for the
16REM * specific language governing permissions and limitations
17REM * under the License.
18REM */
Roger Meier5b9693c2012-02-28 19:32:55 +000019@echo off
20if ""=="%1" goto CONFIG
21goto HANDLEDIR
22
23REM -----------------------------------------------------
24:CONFIG
25REM -----------------------------------------------------
26
27rem * CONFIGURATION BEGIN
28rem * configuration settings, adjust as necessary to meet your system setup
29set SVNWORKDIR=
30set MY_THRIFT_FILES=
31set BIN=C:\MSys10\local\bin
32set MINGW_BIN=C:\MinGW\bin
33set DCC=
34set SUBDIR=gen-delphi
35rem * CONFIGURATION END
36
37
38REM -----------------------------------------------------
39:START
40REM -----------------------------------------------------
41
42rem * configured?
43if "%SVNWORKDIR%"=="" goto CONFIG_ERROR
44
45rem * try to find dcc32.exe
46echo Looking for dcc32.exe ...
47if not exist "%DCC%" set DCC=%ProgramFiles%\Embarcadero\RAD Studio\8.0\bin\dcc32.exe
48if not exist "%DCC%" set DCC=%ProgramFiles(x86)%\Embarcadero\RAD Studio\8.0\bin\dcc32.exe
49if not exist "%DCC%" goto CONFIG_ERROR
50echo Found %DCC%
51echo.
52
53rem * some helpers
54set PATH=%BIN%;%MINGW_BIN%;%PATH%
55set TARGET=%SVNWORKDIR%\..\thrift-testing
56set SOURCE=%SVNWORKDIR%
57set TESTAPP=TestProject
58set UNITSEARCH=%SOURCE%\lib\pas\src;%SOURCE%\lib\delphi\src
59set OUTDCU="%TARGET%\dcu"
60set LOGFILE=%TARGET%\%SUBDIR%\codegen.log
61
62rem * create and/or empty target dirs
63if not exist "%TARGET%" md "%TARGET%"
64if not exist "%TARGET%\%SUBDIR%" md "%TARGET%\%SUBDIR%"
Jens Geyerd5436f52014-10-03 19:50:38 +020065if not exist "%OUTDCU%" md "%OUTDCU%"
Roger Meier5b9693c2012-02-28 19:32:55 +000066if exist "%TARGET%\*.thrift" del "%TARGET%\*.thrift" /Q
67if exist "%TARGET%\%SUBDIR%\*.*" del "%TARGET%\%SUBDIR%\*.*" /Q
68if exist "%OUTDCU%\*.*" del "%OUTDCU%\*.*" /Q
69
Jens Geyercd7a2aa2022-10-17 14:21:18 +020070rem init logfile
71echo Errors > "%LOGFILE%"
72echo ---------------- >> "%LOGFILE%"
73
Roger Meier5b9693c2012-02-28 19:32:55 +000074rem * recurse through thrift WC and "my thrift files" folder
75rem * copies all .thrift files into thrift-testing
76call %0 %SOURCE%
77if not "%MY_THRIFT_FILES%"=="" call %0 %MY_THRIFT_FILES%
78
79rem * compile all thrift files, generate PAS and C++ code
80echo.
81echo Generating code, please wait ...
82cd "%TARGET%"
Jens Geyerfd1b3582014-12-13 23:42:58 +010083for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen delphi:register_types,constprefix,events,xmldoc "%%a" 2>> "%LOGFILE%"
Roger Meier5b9693c2012-02-28 19:32:55 +000084REM * for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen cpp "%%a" >> NUL:
85cmd /c start notepad "%LOGFILE%"
86cd ..
87
88rem * check for special Delphi testcases being processed
89if not exist "%TARGET%\%SUBDIR%\ReservedKeywords.pas" goto TESTCASE_MISSING
90
91
92rem * generate a minimal DPR file that uses all generated pascal units
93cd "%TARGET%\%SUBDIR%\"
94if exist inherited.* ren inherited.* _inherited.*
Jens Geyerd5436f52014-10-03 19:50:38 +020095echo program %TESTAPP%; > %TESTAPP%.dpr
96echo {$APPTYPE CONSOLE} >> %TESTAPP%.dpr
97echo. >> %TESTAPP%.dpr
98echo uses >> %TESTAPP%.dpr
99for %%a in (*.pas) do echo %%~na, >> %TESTAPP%.dpr
100echo Windows, Classes, SysUtils; >> %TESTAPP%.dpr
101echo. >> %TESTAPP%.dpr
102echo begin >> %TESTAPP%.dpr
103echo Writeln('Successfully compiled!'); >> %TESTAPP%.dpr
104echo Writeln('List of units:'); >> %TESTAPP%.dpr
105for %%a in (*.pas) do echo Write('%%~na':30,'':10); >> %TESTAPP%.dpr
106echo Writeln; >> %TESTAPP%.dpr
107echo end. >> %TESTAPP%.dpr
108echo. >> %TESTAPP%.dpr
Roger Meier5b9693c2012-02-28 19:32:55 +0000109cd ..\..
110
111rem * try to compile the DPR
112rem * this should not throw any errors, warnings or hints
Jens Geyerd5436f52014-10-03 19:50:38 +0200113"%DCC%" -B "%TARGET%\%SUBDIR%\%TESTAPP%" -U"%UNITSEARCH%" -I"%UNITSEARCH%" -N"%OUTDCU%" -E"%TARGET%\%SUBDIR%"
Roger Meier5b9693c2012-02-28 19:32:55 +0000114dir "%TARGET%\%SUBDIR%\%TESTAPP%.exe"
115if not exist "%TARGET%\%SUBDIR%\%TESTAPP%.exe" goto CODEGEN_FAILED
116echo.
117echo -----------------------------------------------------------------
118echo The compiled program is now executed. If it hangs or crashes, we
Jens Geyerd5436f52014-10-03 19:50:38 +0200119echo have a serious problem with the generated code. Expected output
Roger Meier5b9693c2012-02-28 19:32:55 +0000120echo is "Successfully compiled:" followed by a list of generated units.
121echo -----------------------------------------------------------------
122"%TARGET%\%SUBDIR%\%TESTAPP%.exe"
123echo -----------------------------------------------------------------
124echo.
125pause
126GOTO EOF
127
128REM -----------------------------------------------------
129:DXE_NOT_FOUND
130REM -----------------------------------------------------
Jens Geyerd5436f52014-10-03 19:50:38 +0200131echo Delphi Compiler (dcc32.exe) not found.
Roger Meier5b9693c2012-02-28 19:32:55 +0000132echo Please check the "DCC" setting in this batch.
133echo.
Jens Geyerc02618c2014-04-10 01:16:48 +0200134cmd /c start notepad README.MD
Roger Meier5b9693c2012-02-28 19:32:55 +0000135cmd /c start notepad %0
136pause
137GOTO EOF
138
139
140REM -----------------------------------------------------
141:CONFIG_ERROR
142REM -----------------------------------------------------
143echo Missing, incomplete or wrong configuration settings!
Jens Geyerc02618c2014-04-10 01:16:48 +0200144cmd /c start notepad README.MD
Roger Meier5b9693c2012-02-28 19:32:55 +0000145cmd /c start notepad %0
146pause
147GOTO EOF
148
149
150REM -----------------------------------------------------
151:TESTCASE_MISSING
152REM -----------------------------------------------------
153echo Missing an expected Delphi testcase!
154pause
155GOTO EOF
156
157
158REM -----------------------------------------------------
159:CODEGEN_FAILED
160REM -----------------------------------------------------
161echo Code generation FAILED!
162pause
163GOTO EOF
164
165
166REM -----------------------------------------------------
167:HANDLEDIR
168REM -----------------------------------------------------
169REM echo %1
170for /D %%a in (%1\*) do call %0 %%a
171if exist "%1\*.thrift" copy /b "%1\*.thrift" "%TARGET%\*.*"
172GOTO EOF
173
174
175REM -----------------------------------------------------
176:EOF
177REM -----------------------------------------------------