1
0

build.cmd 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. @echo off
  2. rem Builds rekopub.exe in the repository root.
  3. rem
  4. rem Run it from Command Prompt or PowerShell:
  5. rem build.cmd (Command Prompt)
  6. rem .\build.cmd (PowerShell)
  7. rem
  8. rem Needs Go 1.26 or newer: https://go.dev/dl/
  9. setlocal
  10. rem Work from the folder this script is in, wherever it was started from.
  11. cd /d "%~dp0"
  12. where go >nul 2>nul
  13. if errorlevel 1 (
  14. echo error: Go was not found. Install Go 1.26 or newer from https://go.dev/dl/
  15. echo and open a new terminal so the installer's PATH change takes effect.
  16. exit /b 1
  17. )
  18. rem A pure-Go Windows build for this machine's processor. -trimpath and
  19. rem -s -w leave out local paths and debug symbols, making the file smaller.
  20. set CGO_ENABLED=0
  21. set GOOS=windows
  22. rem Stamp the version from git (e.g. v1.0.0, or v1.0.0-3-gabc1234 after
  23. rem it) so "rekopub.exe -VERSION" says what was built.
  24. set VERSION=dev
  25. for /f "delims=" %%v in ('git describe --tags --always --dirty 2^>nul') do set VERSION=%%v
  26. echo Building rekopub.exe %VERSION%...
  27. go build -trimpath -ldflags="-s -w -X main.version=%VERSION%" -o rekopub.exe .\cmd\rekopub
  28. if errorlevel 1 (
  29. echo error: the build failed; see the messages above.
  30. exit /b 1
  31. )
  32. echo Built %CD%\rekopub.exe
  33. echo.
  34. echo Example:
  35. echo rekopub.exe -URL https://example.com/article -SAVE %%USERPROFILE%%\Books\
  36. endlocal