Skip to content

Commit

Permalink
fix xbuild.bat PRODUCT_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Aug 29, 2024
1 parent f20969b commit c48c70a
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions xbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,23 @@ if not defined VERSION_PATCH set VERSION_PATCH=1
if not defined WEASEL_VERSION set WEASEL_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%
if not defined WEASEL_BUILD set WEASEL_BUILD=0

if not defined PRODUCT_VERSION (
rem use numeric build version for release build
set PRODUCT_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD%
rem for non-release build, try to use git commit hash as product build version
if not defined RELEASE_BUILD (
rem check if git is installed and available, then get the short commit id of head
git --version >nul 2>&1
if not errorlevel 1 (
rem get short commmit id of head
for /F %%i in ('git rev-parse --short HEAD') do (set PRODUCT_VERSION=%WEASEL_VERSION%-%%i)
rem use numeric build version for release build
set PRODUCT_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD%
rem for non-release build, try to use git commit hash as product build version
if not defined RELEASE_BUILD (
rem check if git is installed and available, then get the short commit id of head
git --version >nul 2>&1
if not errorlevel 1 (
for /f "delims=" %%i in ('git tag --sort=-creatordate ^| findstr /r "^0."') do (
set LAST_TAG=%%i
goto found_tag
)
:found_tag
for /f "delims=" %%i in ('git rev-list %LAST_TAG%..HEAD --count') do (
set WEASEL_BUILD=%%i
)
rem get short commmit id of head
for /F %%i in ('git rev-parse --short HEAD') do (set PRODUCT_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD%.%%i)
)
)

Expand Down Expand Up @@ -181,10 +187,8 @@ if %build_installer% == 1 (
"%ProgramFiles(x86)%"\NSIS\Bin\makensis.exe ^
/DWEASEL_VERSION=%WEASEL_VERSION% ^
/DWEASEL_BUILD=%WEASEL_BUILD% ^
/DPRODUCT_VERSION=%PRODUCT_VERSION% ^
output\install.nsi
if not defined RELEASE_BUILD (
move output\archives\weasel-%WEASEL_VERSION%.%WEASEL_BUILD%-installer.exe output\archives\weasel-%PRODUCT_VERSION%-installer.exe
)
if errorlevel 1 goto error
)
goto end
Expand Down

0 comments on commit c48c70a

Please sign in to comment.