rem Retrieve major/minor version
rem ============================

setlocal enabledelayedexpansion

for /f "delims=" %%a in ('findstr /b /c:"#define THA_MAJOR_VERSION " ..\..\src\thalia\app_info.h') do (
  set pwd=%%a
  set "pwd=!pwd:Password: =!"
)

set major_ver="%pwd%"
set maj=%major_ver:~27,1%

for /f "delims=" %%a in ('findstr /b /c:"#define THA_MINOR_VERSION " ..\..\src\thalia\app_info.h') do (
  set pwd=%%a
  set "pwd=!pwd:Password: =!"
)

set minor_ver="%pwd%"
set min=%minor_ver:~27,2%

for /f "delims=" %%a in ('findstr /b /c:"#define THA_RELEASE " ..\..\src\thalia\app_info.h') do (
  set pwd=%%a
  set "pwd=!pwd:Password: =!"
)

set release="%pwd%"
set rel=%release:~22%

rmdir /s /q build
rmdir /s /q src
del /s /q thalia-mp3*.zip

mkdir build
mkdir build\vc
rem mkdir build\linux
mkdir src
mkdir src\WDL-GV
mkdir src\thalia
mkdir src\thalia_mp3

xcopy /y /s ..\..\src\WDL-GV src\WDL-GV
xcopy /y ..\..\src\thalia\thalia_plugin_public.h src\thalia
xcopy /y ..\..\src\thalia\sample_format.h src\thalia
xcopy /y ..\..\src\thalia\fp_cmp.* src\thalia
xcopy /y ..\..\build\vc\thalia-mp3.* build\vc
rem xcopy /y ..\..\build\linux\makefile_tha_mp3.mk build\linux
rem xcopy /y ..\..\build\linux\Makefile build\linux
xcopy /y /s ..\..\src\thalia_mp3 src\thalia_mp3

7z a -tzip -mx=1 thalia-mp3-%maj%.%min%%rel%-src.zip build
7z a -tzip -mx=1 thalia-mp3-%maj%.%min%%rel%-src.zip src
7z d -r thalia-mp3-%maj%.%min%%rel%-src.zip build\vc\Win32
7z d -r thalia-mp3-%maj%.%min%%rel%-src.zip build\vc\x64
7z d -r thalia-mp3-%maj%.%min%%rel%-src.zip *.o
7z t thalia-mp3-%maj%.%min%%rel%-src.zip * -r

rmdir /s /q build
rmdir /s /q src

pause
