]> granicus.if.org Git - postgresql/blob - src/tools/msvc/pgbison.bat
f433e0774bd7a176f8be6326411434be03810e22
[postgresql] / src / tools / msvc / pgbison.bat
1 @echo off
2 if exist src\tools\msvc\buildenv.bat call src\tools\msvc\buildenv.bat
3
4 SET BV=
5 for /F "tokens=4 usebackq" %%f in (`bison -V`) do if "!BV!"=="" SET BV=%%f
6 if "%BV%"=="" goto novarexp
7 if %BV% LSS 1.875 goto nobison
8 if %BV% EQU 2.1 goto nobison
9
10 if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\include\parser\parse.h
11 if "%1" == "src\backend\bootstrap\bootparse.y" call :generate %1 src\backend\bootstrap\bootparse.c src\backend\bootstrap\bootstrap_tokens.h
12 if "%1" == "src\pl\plpgsql\src\gram.y" call :generate %1 src\pl\plpgsql\src\pl_gram.c src\pl\plpgsql\src\pl.tab.h
13 if "%1" == "src\interfaces\ecpg\preproc\preproc.y" call :generate %1 src\interfaces\ecpg\preproc\preproc.c src\interfaces\ecpg\preproc\preproc.h
14 if "%1" == "contrib\cube\cubeparse.y" call :generate %1 contrib\cube\cubeparse.c contrib\cube\cubeparse.h
15 if "%1" == "contrib\seg\segparse.y" call :generate %1 contrib\seg\segparse.c contrib\seg\segparse.h
16
17 echo Unknown bison input: %1
18 exit 1
19
20 :generate
21 SET fn=%1
22 bison -d %fn%
23 if errorlevel 1 exit 1
24 copy /y %fn:~0,-2%.tab.c %2
25 if errorlevel 1 exit 1
26 copy /y %fn:~0,-2%.tab.h %3
27 if errorlevel 1 exit 1
28 del %fn:~0,-2%.tab.*
29 exit 0
30
31
32 :novarexp
33 echo pgbison must be called with cmd /V:ON /C pgbison to work!
34 exit 1
35
36 :nobison
37 echo WARNING! Bison install not found, or unsupported Bison version.
38 echo Attempting to build without.
39 exit 0