mirror of https://github.com/hashicorp/consul
Browse Source
Converted the Makefile functionality into several bat files to better support building on Windows. All targets have been introduced in the make.bat file, except for "cov" and "format". Running make.bat with no arguments runs the all target per default, just like Makefile. If an argument is supplied, it must be one of all, cover, deps, integ, test, vet, or updatedeps. For example > make.bat test runs the test target.pull/638/head
Emil Hessman
10 years ago
5 changed files with 164 additions and 20 deletions
@ -1,18 +0,0 @@
|
||||
@echo off |
||||
|
||||
REM Download Mingw 64 on Windows from http://win-builds.org/download.html |
||||
|
||||
set GOARCH=%2 |
||||
IF "%2" == "" (set GOARCH=amd64) |
||||
set MODULENAME=%1 |
||||
set ORG_PATH=github.com\hashicorp |
||||
set REPO_PATH=%ORG_PATH%\%MODULENAME% |
||||
|
||||
set GOPATH=%cd%\gopath |
||||
|
||||
rmdir /s /q %GOPATH%\src\%REPO_PATH% 2>nul |
||||
mkdir %GOPATH%\src\%ORG_PATH% 2>nul |
||||
go get .\... |
||||
mklink /J "%GOPATH%\src\%REPO_PATH%" "%cd%" 2>nul |
||||
|
||||
%GOROOT%\bin\go build -o bin\%GOARCH%\%MODULENAME%.exe %REPO_PATH% |
@ -0,0 +1,86 @@
|
||||
@echo off |
||||
|
||||
setlocal |
||||
|
||||
set _EXITCODE=0 |
||||
|
||||
set _DEPSFILE=%TEMP%\consul-deps.txt |
||||
go list -f "{{range .TestImports}}{{.}} {{end}}" .\... >%_DEPSFILE% |
||||
|
||||
set _PKGSFILE=%TEMP%\consul-pkgs.txt |
||||
go list .\... >%_PKGSFILE% |
||||
|
||||
set _VETARGS=-asmdecl -atomic -bool -buildtags -copylocks -methods^ |
||||
-nilfunc -printf -rangeloops -shift -structtags -unsafeptr |
||||
if defined VETARGS set _VETARGS=%VETARGS% |
||||
|
||||
:deps |
||||
echo --^> Installing build dependencies |
||||
for /f "delims=" %%d in (%_DEPSFILE%) do go get -d -v .\... %%d |
||||
|
||||
if [%1]==[] goto all |
||||
if x%1==xdeps goto end |
||||
goto args |
||||
|
||||
:args |
||||
for %%a in (all,cover,integ,test,vet,updatedeps) do (if x%1==x%%a goto %%a) |
||||
echo. |
||||
echo Unknown make target: %1 |
||||
echo Expected one of "all", "cover", "deps", "integ", "test", "vet", or "updatedeps". |
||||
set _EXITCODE=1 |
||||
goto end |
||||
|
||||
:all |
||||
md bin 2>NUL |
||||
call .\scripts\windows\build.bat %CD% |
||||
if not errorlevel 1 goto end |
||||
echo. |
||||
echo BUILD FAILED |
||||
set _EXITCODE=%ERRORLEVEL% |
||||
goto end |
||||
|
||||
:cover |
||||
set _COVER=--cover |
||||
go tool cover 2>NUL |
||||
if %ERRORLEVEL% EQU 3 go get golang.org/x/tools/cmd/cover |
||||
goto test |
||||
|
||||
:integ |
||||
set INTEG_TESTS=yes |
||||
goto test |
||||
|
||||
:test |
||||
call .\scripts\windows\verify_no_uuid.bat %CD% |
||||
if %ERRORLEVEL% EQU 0 goto _test |
||||
echo. |
||||
echo UUID verification failed. |
||||
set _EXITCODE=%ERRORLEVEL% |
||||
goto end |
||||
:_test |
||||
for /f "delims=" %%p in (%_PKGSFILE%) do ( |
||||
go test %_COVER% %%p |
||||
if errorlevel 1 set _TESTFAIL=1 |
||||
) |
||||
if x%_TESTFAIL%==x1 set _EXITCODE=1 && goto end |
||||
goto vet |
||||
|
||||
:vet |
||||
go tool vet 2>NUL |
||||
if %ERRORLEVEL% EQU 3 go get golang.org/x/tools/cmd/vet |
||||
echo --^> Running go tool vet %_VETARGS% |
||||
go tool vet %_VETARGS% . |
||||
echo. |
||||
if %ERRORLEVEL% EQU 0 echo ALL TESTS PASSED && goto end |
||||
echo Vet found suspicious constructs. Please check the reported constructs |
||||
echo and fix them if necessary before submitting the code for reviewal. |
||||
set _EXITCODE=%ERRORLEVEL% |
||||
goto end |
||||
|
||||
:updatedeps |
||||
echo --^> Updating build dependencies |
||||
for /f "delims=" %%d in (%_DEPSFILE%) do go get -d -f -u .\... %%d |
||||
goto end |
||||
|
||||
:end |
||||
del /F %_DEPSFILE% %_PKGSFILE% 2>NUL |
||||
exit /B %_EXITCODE% |
@ -0,0 +1,42 @@
|
||||
@echo off |
||||
|
||||
setlocal |
||||
|
||||
if not exist %1 exit /B 1 |
||||
cd %1 |
||||
|
||||
:: Get the git commit |
||||
set _GIT_COMMIT_FILE=%TEMP%\consul-git_commit.txt |
||||
set _GIT_DIRTY_FILE=%TEMP%\consul-git_dirty.txt |
||||
set _GIT_DESCRIBE_FILE=%TEMP%\consul-git_describe.txt |
||||
|
||||
set _NUL_CMP_FILE=%TEMP%\consul-nul_cmp.txt |
||||
type NUL >%_NUL_CMP_FILE% |
||||
|
||||
git rev-parse HEAD >%_GIT_COMMIT_FILE% |
||||
set /p _GIT_COMMIT=<%_GIT_COMMIT_FILE% |
||||
del /F "%_GIT_COMMIT_FILE%" 2>NUL |
||||
|
||||
set _GIT_DIRTY= |
||||
git status --porcelain >%_GIT_DIRTY_FILE% |
||||
fc %_GIT_DIRTY_FILE% %_NUL_CMP_FILE% >NUL |
||||
if errorlevel 1 set _GIT_DIRTY=+CHANGES |
||||
del /F "%_GIT_DIRTY_FILE%" 2>NUL |
||||
del /F "%_NUL_CMP_FILE%" 2>NUL |
||||
|
||||
git describe --tags >%_GIT_DESCRIBE_FILE% |
||||
set /p _GIT_DESCRIBE=<%_GIT_DESCRIBE_FILE% |
||||
del /F "%_GIT_DESCRIBE_FILE%" 2>NUL |
||||
|
||||
:: Install dependencies |
||||
echo --^> Installing dependencies to speed up builds... |
||||
go get .\... |
||||
|
||||
:: Build! |
||||
echo --^> Building... |
||||
go build^ |
||||
-ldflags "-X main.GitCommit %_GIT_COMMIT%%_GIT_DIRTY% -X main.GitDescribe %_GIT_DESCRIBE%"^ |
||||
-v^ |
||||
-o bin\consul.exe . |
||||
if errorlevel 1 exit /B 1 |
||||
copy /B /Y bin\consul.exe %GOPATH%\bin\consul.exe >NUL |
@ -0,0 +1,14 @@
|
||||
@echo off |
||||
|
||||
setlocal |
||||
|
||||
if not exist %1\consul\state_store.go exit /B 1 |
||||
if not exist %1\consul\fsm.go exit /B 1 |
||||
|
||||
findstr /R generateUUID %1\consul\state_store.go 1>nul |
||||
if not %ERRORLEVEL% EQU 1 exit /B 1 |
||||
|
||||
findstr generateUUID %1\consul\fsm.go 1>nul |
||||
if not %ERRORLEVEL% EQU 1 exit /B 1 |
||||
|
||||
exit /B 0 |
Loading…
Reference in new issue