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