@REM zip a complete distribution of Vim for Win32 or Win64

@setlocal
@if "%_echo%"=="" (echo off) else (echo %_echo%)

@REM pass in the patchlevel and/or platform; e.g., -192-amd64
set Patch=%1
set Is64=%2
set VimVer=vim72a
set TargetDir=%~dp0%VimVer%
set RelativeTargetDir=%VimVer%
set ZipFile=%VimVer%%Patch%.zip

REM set ObjSuffix if you've added some non-standard extras; e.g., Y for Python
REM see Make_mvc.mak for details
set ObjSuffix=Y

if exist %TargetDir% (rmdir /s/q %TargetDir%)
mkdir %TargetDir%

pushd runtime

for /d %%g in (autoload colors compiler ftplugin indent keymap lang macros plugin print syntax tools tutor) do (
    echo %%g
    xcopy /yqsi %%g %TargetDir%\%%g > nul
)
for %%g in (rgb.txt *.vim) do (
    xcopy /yq %%g %TargetDir% > nul
)

mkdir %TargetDir%\doc
cd doc
echo doc
for %%g in (tags *.txt) do (
    xcopy /yq %%g %TargetDir%\doc > nul
)

mkdir %TargetDir%\spell
cd ..\spell
echo spell
for %%g in (*.txt *.vim *.spl *.sug) do (
    xcopy /yq %%g %TargetDir%\spell > nul
)

popd

for %%g in (README.txt uninstal.txt vimtutor.bat) do (
    xcopy /yq %%g %TargetDir% > nul
)

call :CopyExe    install
call :CopyExe    uninstal
call :CopyExe    vimrun
call :CopyExe    xxd\xxd
call :CopyExe    ..\tools\diff
if [%Is64%]==[] (call :CopyDll    ..\tools\libintl)
call :CopyDll    GvimExt\gvimext
call :CopyDll    VisVim\VisVim
call :CopyFile   VisVim\README_VisVim.txt

call :CopyExePdb vim   ObjC%ObjSuffix%
call :CopyExePdb vimd  ObjC%ObjSuffix%d
call :CopyExePdb gvim  ObjGO%ObjSuffix%
call :CopyExePdb gvimd ObjGO%ObjSuffix%d

if exist %ZipFile%  attrib -R %ZipFile% && del /q %ZipFile%
echo Zipping to %ZipFile%
@REM requires Info-Zip zip.exe
zip -q -r %ZipFile% %RelativeTargetDir%
dir %ZipFile%
goto :EOF

:CopyFile
xcopy /yf src\%1 %TargetDir%
goto :EOF

:CopyDll
call :CopyFile %1.dll
goto :EOF

:CopyExe
call :CopyFile %1.exe
goto :EOF

:CopyExePdb
call :CopyExe %1
call :CopyFile %1.pdb
goto :EOF
