2006-10-22 19:17:09 +02:00
|
|
|
@echo off
|
2010-09-20 22:08:53 +02:00
|
|
|
REM src/tools/msvc/pgbison.bat
|
2007-03-17 15:01:01 +01:00
|
|
|
|
2007-12-19 13:29:36 +01:00
|
|
|
IF NOT EXIST src\tools\msvc\buildenv.pl goto nobuildenv
|
2011-07-03 16:36:56 +02:00
|
|
|
perl -e "require 'src/tools/msvc/buildenv.pl'; while(($k,$v) = each %%ENV) { print qq[\@SET $k=$v\n]; }" > bldenv.bat
|
2007-12-19 13:29:36 +01:00
|
|
|
CALL bldenv.bat
|
|
|
|
del bldenv.bat
|
|
|
|
:nobuildenv
|
2007-01-16 22:43:19 +01:00
|
|
|
|
2006-10-22 19:17:09 +02:00
|
|
|
SET BV=
|
|
|
|
for /F "tokens=4 usebackq" %%f in (`bison -V`) do if "!BV!"=="" SET BV=%%f
|
|
|
|
if "%BV%"=="" goto novarexp
|
2007-03-17 18:11:41 +01:00
|
|
|
if %BV% EQU 1.875 goto bisonok
|
|
|
|
if %BV% GEQ 2.2 goto bisonok
|
|
|
|
goto nobison
|
|
|
|
:bisonok
|
2006-10-22 19:17:09 +02:00
|
|
|
|
2008-08-29 15:02:33 +02:00
|
|
|
if "%1" == "src\backend\parser\gram.y" call :generate %1 src\backend\parser\gram.c src\backend\parser\gram.h
|
|
|
|
if "%1" == "src\backend\bootstrap\bootparse.y" call :generate %1 src\backend\bootstrap\bootparse.c
|
2011-01-14 16:30:33 +01:00
|
|
|
if "%1" == "src\backend\replication\repl_gram.y" call :generate %1 src\backend\replication\repl_gram.c
|
2008-08-30 04:32:24 +02:00
|
|
|
if "%1" == "src\pl\plpgsql\src\gram.y" call :generate %1 src\pl\plpgsql\src\pl_gram.c src\pl\plpgsql\src\pl_gram.h
|
2011-05-15 23:55:05 +02:00
|
|
|
if "%1" == "src\test\isolation\specparse.y" call :generate %1 src\test\isolation\specparse.c
|
2006-10-22 19:17:09 +02:00
|
|
|
if "%1" == "src\interfaces\ecpg\preproc\preproc.y" call :generate %1 src\interfaces\ecpg\preproc\preproc.c src\interfaces\ecpg\preproc\preproc.h
|
2008-08-30 04:32:24 +02:00
|
|
|
if "%1" == "contrib\cube\cubeparse.y" call :generate %1 contrib\cube\cubeparse.c
|
|
|
|
if "%1" == "contrib\seg\segparse.y" call :generate %1 contrib\seg\segparse.c
|
2006-10-22 19:17:09 +02:00
|
|
|
|
|
|
|
echo Unknown bison input: %1
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
:generate
|
|
|
|
SET fn=%1
|
2007-01-28 17:29:37 +01:00
|
|
|
SET cf=%2
|
|
|
|
bison.exe -d %fn% -o %cf%
|
2006-10-22 19:17:09 +02:00
|
|
|
if errorlevel 1 exit 1
|
2007-01-28 17:29:37 +01:00
|
|
|
SET hf=%cf:~0,-2%.h
|
|
|
|
if not "%hf%"=="%3" (
|
|
|
|
copy /y %hf% %3
|
|
|
|
if errorlevel 1 exit 1
|
|
|
|
del %hf%
|
|
|
|
)
|
2006-10-22 19:17:09 +02:00
|
|
|
exit 0
|
|
|
|
|
|
|
|
|
|
|
|
:novarexp
|
|
|
|
echo pgbison must be called with cmd /V:ON /C pgbison to work!
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
:nobison
|
|
|
|
echo WARNING! Bison install not found, or unsupported Bison version.
|
|
|
|
echo Attempting to build without.
|
|
|
|
exit 0
|