gen_pbs_version.bat 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. @echo off
  2. REM this genereates the pbs_version.h file.
  3. cd %~dp0
  4. REM exit if pbs_version.h exists
  5. if exist "..\..\src\include\pbs_version.h" (
  6. goto :eof
  7. )
  8. if exist "..\..\src\include\pbs_version.h.in" (
  9. copy "..\..\src\include\pbs_version.h.in" "..\..\src\include\pbs_version.h"
  10. )
  11. REM find pbs_version from pbspro.spec
  12. set pbs_specfile="..\..\pbspro.spec"
  13. for /F "tokens=3 USEBACKQ" %%F IN (`findstr /l /c:" pbs_version " %pbs_specfile%`) DO (
  14. set var=%%F
  15. set pbs_ver=%var%
  16. )
  17. REM replace PBS_VERSION placeholder value(@PBS_WIN_VERSION@)
  18. REM defined in pbs_version.h with pbs_ver
  19. set oldfile="..\..\src\include\pbs_version.h"
  20. set searchstr=@PBS_WIN_VERSION@
  21. set repstr=%var%
  22. if exist "..\include\temp_pbs_version.h" (
  23. del /f /q "..\include\temp_pbs_version.h"
  24. )
  25. for /f "tokens=1,* delims=]" %%A in ('"type %oldfile%|find /n /v """') do (
  26. set "line=%%B"
  27. if defined line (
  28. call set "line=echo.%%line:%searchstr%=%repstr%%%"
  29. for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X >> ..\include\temp_pbs_version.h"
  30. ) ELSE echo.
  31. )
  32. copy "..\include\temp_pbs_version.h" "..\..\src\include\pbs_version.h"
  33. del /f /q "..\include\temp_pbs_version.h"