build.bat 941 B

12345678910111213141516171819202122232425
  1. @echo off
  2. SET ORG_PATH=github.com\coreos
  3. SET REPO_PATH=%ORG_PATH%\etcd
  4. SET GOPATH=%cd%\gopath
  5. :: Cleanup old builds
  6. IF EXIST "%GOPATH%\src\%REPO_PATH%" rmdir /s /q "%GOPATH%\src\%REPO_PATH%"
  7. IF EXIST "%GOPATH%\src\%ORG_PATH%" rmdir /s /q "%GOPATH%\src\%ORG_PATH%"
  8. IF EXIST "%cd%\bin" rmdir /s /q "%cd%\bin"
  9. md "%GOPATH%\src\%ORG_PATH%"
  10. mklink /d "%GOPATH%\src\%REPO_PATH%" "%cd%"
  11. FOR /f "usebackq tokens=*" %%a IN (`go env`) DO %%a
  12. (FOR /f "tokens=*" %%i IN ('git rev-parse --short HEAD') DO SET GIT_SHA=%%i) 2>NUL
  13. IF NOT DEFINED GIT_SHA SET GIT_SHA=GitNotFound
  14. :: Static compilation is useful when etcd is run in a container
  15. SET CGO_ENABLED=0
  16. go build -a -installsuffix cgo -ldflags "-s -X %REPO_PATH%\version.GitSHA %GIT_SHA%" -o bin\etcd.exe "%REPO_PATH%"
  17. :: TODO: Get the %GIT_SHA% argument to work. Useful for `etcd --version` style commands.
  18. go build -a -installsuffix cgo -ldflags "-s" -o bin\etcdctl.exe "%REPO_PATH%\etcdctl"