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