You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2012/02/28 20:32:55 UTC

svn commit: r1294798 - in /thrift/trunk/lib/delphi/test/codegen: ./ README.txt ReservedKeywords.thrift run-Pascal-Codegen-Tests.bat.tmpl

Author: roger
Date: Tue Feb 28 19:32:55 2012
New Revision: 1294798

URL: http://svn.apache.org/viewvc?rev=1294798&view=rev
Log:
THRIFT-1388 Delphi XE code-generation test case
Patch: Jens Geyer

Added:
    thrift/trunk/lib/delphi/test/codegen/
    thrift/trunk/lib/delphi/test/codegen/README.txt
    thrift/trunk/lib/delphi/test/codegen/ReservedKeywords.thrift
    thrift/trunk/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl

Added: thrift/trunk/lib/delphi/test/codegen/README.txt
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/delphi/test/codegen/README.txt?rev=1294798&view=auto
==============================================================================
--- thrift/trunk/lib/delphi/test/codegen/README.txt (added)
+++ thrift/trunk/lib/delphi/test/codegen/README.txt Tue Feb 28 19:32:55 2012
@@ -0,0 +1,28 @@
+How to use the test case:
+----------------------------------------------
+- copy and the template batch file 
+- open the batch file and adjust configuration as necessary
+- run the batch
+
+
+Configuration:
+----------------------------------------------
+SVNWORKDIR 
+should point to the Thrift working copy root
+
+MY_THRIFT_FILES 
+can be set to point to a folder with more thrift IDL files. 
+If you don't have any such files, just leave the setting blank.
+
+BIN
+Local MSYS binary folder. Your THRIFT.EXE is installed here.
+
+MINGW_BIN
+Local MinGW bin folder. Contains DLL files required by THRIFT.EXE
+
+DCC
+Identifies the Delphi Command Line compiler (dcc32.exe)
+To be configuired only, if the default is not suitable.
+
+----------------------------------------------
+*EOF*
\ No newline at end of file

Added: thrift/trunk/lib/delphi/test/codegen/ReservedKeywords.thrift
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/delphi/test/codegen/ReservedKeywords.thrift?rev=1294798&view=auto
==============================================================================
--- thrift/trunk/lib/delphi/test/codegen/ReservedKeywords.thrift (added)
+++ thrift/trunk/lib/delphi/test/codegen/ReservedKeywords.thrift Tue Feb 28 19:32:55 2012
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// make sure generated code does not produce name collisions with predefined keywords 
+
+
+
+typedef i32 Cardinal
+typedef string message
+typedef list< map< Cardinal, message>> program
+
+struct unit {
+  1: Cardinal downto;
+  2: program procedure;
+}
+
+typedef set< unit> units
+
+exception exception1 {
+  1: program message;
+  2: unit array;
+}
+
+service constructor {
+  unit Create(1: Cardinal asm; 2: message inherited) throws (1: exception1 label);
+  units Destroy();
+}
+
+const Cardinal downto = +1
+const Cardinal published = -1
+
+enum keywords {
+  record = 1,
+  repeat = 2,
+  deprecated = 3
+}
+
+
+

Added: thrift/trunk/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl?rev=1294798&view=auto
==============================================================================
--- thrift/trunk/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl (added)
+++ thrift/trunk/lib/delphi/test/codegen/run-Pascal-Codegen-Tests.bat.tmpl Tue Feb 28 19:32:55 2012
@@ -0,0 +1,155 @@
+@echo off
+if ""=="%1" goto CONFIG
+goto HANDLEDIR
+
+REM -----------------------------------------------------
+:CONFIG
+REM -----------------------------------------------------
+
+rem * CONFIGURATION BEGIN
+rem * configuration settings, adjust as necessary to meet your system setup
+set SVNWORKDIR=
+set MY_THRIFT_FILES=
+set BIN=C:\MSys10\local\bin
+set MINGW_BIN=C:\MinGW\bin
+set DCC=
+set SUBDIR=gen-delphi
+rem * CONFIGURATION END
+
+
+REM -----------------------------------------------------
+:START
+REM -----------------------------------------------------
+
+rem * configured?
+if "%SVNWORKDIR%"=="" goto CONFIG_ERROR
+
+rem * try to find dcc32.exe
+echo Looking for dcc32.exe ...
+if not exist "%DCC%" set DCC=%ProgramFiles%\Embarcadero\RAD Studio\8.0\bin\dcc32.exe
+if not exist "%DCC%" set DCC=%ProgramFiles(x86)%\Embarcadero\RAD Studio\8.0\bin\dcc32.exe
+if not exist "%DCC%" goto CONFIG_ERROR
+echo Found %DCC%
+echo.
+
+rem * some helpers
+set PATH=%BIN%;%MINGW_BIN%;%PATH%
+set TARGET=%SVNWORKDIR%\..\thrift-testing
+set SOURCE=%SVNWORKDIR%
+set TESTAPP=TestProject
+set UNITSEARCH=%SOURCE%\lib\pas\src;%SOURCE%\lib\delphi\src
+set OUTDCU="%TARGET%\dcu"
+set LOGFILE=%TARGET%\%SUBDIR%\codegen.log
+
+rem * create and/or empty target dirs
+if not exist "%TARGET%"           md "%TARGET%"
+if not exist "%TARGET%\%SUBDIR%"  md "%TARGET%\%SUBDIR%"
+if not exist "%OUTDCU%" 	      md "%OUTDCU%"
+if exist "%TARGET%\*.thrift"      del "%TARGET%\*.thrift"       /Q
+if exist "%TARGET%\%SUBDIR%\*.*"  del "%TARGET%\%SUBDIR%\*.*"   /Q
+if exist "%OUTDCU%\*.*"           del "%OUTDCU%\*.*"            /Q
+
+rem * recurse through thrift WC and "my thrift files" folder
+rem * copies all .thrift files into thrift-testing
+call %0 %SOURCE%
+if not "%MY_THRIFT_FILES%"=="" call %0 %MY_THRIFT_FILES%
+
+rem * compile all thrift files, generate PAS and C++ code
+echo.
+echo Generating code, please wait ...
+cd "%TARGET%"
+for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen delphi:ansistr_binary "%%a" >> "%LOGFILE%"
+REM * for %%a in (*.thrift) do "%BIN%\thrift.exe" -v --gen cpp "%%a" >> NUL:
+cmd /c start notepad "%LOGFILE%"
+cd ..
+
+rem * check for special Delphi testcases being processed
+if not exist "%TARGET%\%SUBDIR%\ReservedKeywords.pas" goto TESTCASE_MISSING
+
+
+rem * generate a minimal DPR file that uses all generated pascal units
+cd "%TARGET%\%SUBDIR%\"
+if exist inherited.*  ren inherited.*  _inherited.*
+echo program %TESTAPP%;    					> %TESTAPP%.dpr
+echo {$APPTYPE CONSOLE}   					>> %TESTAPP%.dpr
+echo.    									>> %TESTAPP%.dpr
+echo uses 									>> %TESTAPP%.dpr
+for %%a in (*.pas) do echo   %%~na,			>> %TESTAPP%.dpr
+echo   Windows, Classes, SysUtils;			>> %TESTAPP%.dpr
+echo.    									>> %TESTAPP%.dpr
+echo begin 									>> %TESTAPP%.dpr
+echo   Writeln('Successfully compiled!');	>> %TESTAPP%.dpr
+echo   Writeln('List of units:');	>> %TESTAPP%.dpr
+for %%a in (*.pas) do echo   Write('%%~na':30,'':10);  >> %TESTAPP%.dpr
+echo   Writeln;	>> %TESTAPP%.dpr
+echo end. 									>> %TESTAPP%.dpr
+echo.    									>> %TESTAPP%.dpr
+cd ..\..
+
+rem * try to compile the DPR
+rem * this should not throw any errors, warnings or hints
+"%DCC%"  -B "%TARGET%\%SUBDIR%\%TESTAPP%" -U"%UNITSEARCH%" -I"%UNITSEARCH%" -N"%OUTDCU%" -E"%TARGET%\%SUBDIR%" 
+dir "%TARGET%\%SUBDIR%\%TESTAPP%.exe"
+if not exist "%TARGET%\%SUBDIR%\%TESTAPP%.exe"  goto CODEGEN_FAILED
+echo.
+echo -----------------------------------------------------------------
+echo The compiled program is now executed. If it hangs or crashes, we
+echo have a serious problem with the generated code. Expected output 
+echo is "Successfully compiled:" followed by a list of generated units.
+echo -----------------------------------------------------------------
+"%TARGET%\%SUBDIR%\%TESTAPP%.exe"
+echo -----------------------------------------------------------------
+echo.
+pause
+GOTO EOF
+
+REM -----------------------------------------------------
+:DXE_NOT_FOUND
+REM -----------------------------------------------------
+echo Delphi Compiler (dcc32.exe) not found. 
+echo Please check the "DCC" setting in this batch.
+echo.
+cmd /c start notepad README.TXT
+cmd /c start notepad %0
+pause
+GOTO EOF
+
+
+REM -----------------------------------------------------
+:CONFIG_ERROR
+REM -----------------------------------------------------
+echo Missing, incomplete or wrong configuration settings!
+cmd /c start notepad README.TXT
+cmd /c start notepad %0
+pause
+GOTO EOF
+
+
+REM -----------------------------------------------------
+:TESTCASE_MISSING
+REM -----------------------------------------------------
+echo Missing an expected Delphi testcase!
+pause
+GOTO EOF
+
+
+REM -----------------------------------------------------
+:CODEGEN_FAILED
+REM -----------------------------------------------------
+echo Code generation FAILED!
+pause
+GOTO EOF
+
+
+REM -----------------------------------------------------
+:HANDLEDIR
+REM -----------------------------------------------------
+REM echo %1
+for /D %%a in (%1\*) do call %0 %%a
+if exist "%1\*.thrift"   copy /b "%1\*.thrift" "%TARGET%\*.*"
+GOTO EOF
+
+
+REM -----------------------------------------------------
+:EOF
+REM -----------------------------------------------------