Skip to content

Commit fa91af9

Browse files
authored
Remove gox in favor of go build. (#16353)
Remove gox in favor of go build. `gox` hasn't had a release to update it in many years, so is missing support for many modern systems, like `darwin/arm64`. In any case, we only use it for dev builds, where we don't even use the ability of it to build for multiple platforms. Release builds use `go build` now. So, this switches to `go build` everywhere. I pulled this down and tested it in Windows as well. (Side note: I couldn't get `gox` to work in Windows, so couldn't build before this change.)
1 parent 7cd1346 commit fa91af9

File tree

11 files changed

+21
-78
lines changed

11 files changed

+21
-78
lines changed

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ EXTENDED_TEST_TIMEOUT=60m
88
INTEG_TEST_TIMEOUT=120m
99
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
1010
EXTERNAL_TOOLS_CI=\
11-
github.com/mitchellh/gox \
1211
golang.org/x/tools/cmd/goimports
1312
EXTERNAL_TOOLS=\
1413
github.com/client9/misspell/cmd/misspell
@@ -202,10 +201,10 @@ fmtcheck:
202201
fmt:
203202
find . -name '*.go' | grep -v pb.go | grep -v vendor | xargs gofumpt -w
204203

205-
semgrep:
204+
semgrep:
206205
semgrep --include '*.go' --exclude 'vendor' -a -f tools/semgrep .
207206

208-
semgrep-ci:
207+
semgrep-ci:
209208
semgrep --error --include '*.go' --exclude 'vendor' -f tools/semgrep/ci .
210209

211210
assetcheck:

changelog/16353.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
core: remove gox
3+
```

go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ require (
143143
github.com/mitchellh/go-homedir v1.1.0
144144
github.com/mitchellh/go-testing-interface v1.14.1
145145
github.com/mitchellh/go-wordwrap v1.0.0
146-
github.com/mitchellh/gox v1.0.1
147146
github.com/mitchellh/mapstructure v1.5.0
148147
github.com/mitchellh/reflectwalk v1.0.2
149148
github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc
@@ -329,7 +328,6 @@ require (
329328
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
330329
github.com/miekg/dns v1.1.41 // indirect
331330
github.com/mitchellh/hashstructure v1.0.0 // indirect
332-
github.com/mitchellh/iochan v1.0.0 // indirect
333331
github.com/mitchellh/pointerstructure v1.2.0 // indirect
334332
github.com/moby/sys/mount v0.2.0 // indirect
335333
github.com/moby/sys/mountinfo v0.4.1 // indirect

go.sum

-4
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,6 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b
978978
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
979979
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
980980
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
981-
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
982981
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
983982
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
984983
github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
@@ -1324,11 +1323,8 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp
13241323
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
13251324
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
13261325
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
1327-
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=
1328-
github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4=
13291326
github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y=
13301327
github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ=
1331-
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
13321328
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
13331329
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
13341330
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=

make.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ REM If no target is provided, default to test.
77
if [%1]==[] goto test
88

99
set _TARGETS=bin,bootstrap,dev,generate,test,testacc,testrace,vet
10-
set _EXTERNAL_TOOLS=github.com/mitchellh/gox,github.com/kardianos/govendor
10+
set _EXTERNAL_TOOLS=github.com/kardianos/govendor
1111

1212
REM Run target.
1313
for %%a in (%_TARGETS%) do (if x%1==x%%a goto %%a)
@@ -82,7 +82,7 @@ REM any common errors.
8282

8383
go tool vet 2>nul
8484
if %ERRORLEVEL% equ 3 go get golang.org/x/tools/cmd/vet
85-
85+
8686
set _vetExitCode=0
8787
set _VAULT_PKG_DIRS=%TEMP%\vault-pkg-dirs.txt
8888

scripts/build.sh

+6-43
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,6 @@ GIT_DIRTY="$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)"
2323

2424
BUILD_DATE=$("$SOURCE_DIR"/build_date.sh)
2525

26-
# If its dev mode, only build for ourself
27-
if [ "${VAULT_DEV_BUILD}x" != "x" ] && [ "${XC_OSARCH}x" == "x" ]; then
28-
XC_OS=$(${GO_CMD} env GOOS)
29-
XC_ARCH=$(${GO_CMD} env GOARCH)
30-
XC_OSARCH=$(${GO_CMD} env GOOS)/$(${GO_CMD} env GOARCH)
31-
elif [ "${XC_OSARCH}x" != "x" ]; then
32-
IFS='/' read -ra SPLITXC <<< "${XC_OSARCH}"
33-
DEV_PLATFORM="./pkg/${SPLITXC[0]}_${SPLITXC[1]}"
34-
fi
35-
36-
# Determine the arch/os combos we're building for
37-
XC_ARCH=${XC_ARCH:-"386 amd64"}
38-
XC_OS=${XC_OS:-linux darwin windows freebsd openbsd netbsd solaris}
39-
XC_OSARCH=${XC_OSARCH:-"linux/386 linux/amd64 linux/arm linux/arm64 darwin/386 darwin/amd64 darwin/arm64 windows/386 windows/amd64 freebsd/386 freebsd/amd64 freebsd/arm openbsd/386 openbsd/amd64 openbsd/arm netbsd/386 netbsd/amd64 solaris/amd64"}
40-
4126
GOPATH=${GOPATH:-$(${GO_CMD} env GOPATH)}
4227
case $(uname) in
4328
CYGWIN*)
@@ -52,43 +37,21 @@ rm -rf pkg/*
5237
mkdir -p bin/
5338

5439
# Build!
55-
# If GOX_PARALLEL_BUILDS is set, it will be used to add a "-parallel=${GOX_PARALLEL_BUILDS}" gox parameter
5640
echo "==> Building..."
57-
gox \
58-
-osarch="${XC_OSARCH}" \
41+
${GO_CMD} build \
5942
-gcflags "${GCFLAGS}" \
60-
-ldflags "${LD_FLAGS}-X github.com/hashicorp/vault/sdk/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/hashicorp/vault/sdk/version.BuildDate=${BUILD_DATE}" \
61-
-output "pkg/{{.OS}}_{{.Arch}}/vault" \
62-
${GOX_PARALLEL_BUILDS+-parallel="${GOX_PARALLEL_BUILDS}"} \
63-
-tags="${BUILD_TAGS}" \
64-
-gocmd="${GO_CMD}" \
43+
-ldflags "${LD_FLAGS} -X github.com/hashicorp/vault/sdk/version.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X github.com/hashicorp/vault/sdk/version.BuildDate=${BUILD_DATE}" \
44+
-o "bin/vault" \
45+
-tags "${BUILD_TAGS}" \
6546
.
6647

6748
# Move all the compiled things to the $GOPATH/bin
6849
OLDIFS=$IFS
6950
IFS=: MAIN_GOPATH=($GOPATH)
7051
IFS=$OLDIFS
7152

72-
# Copy our OS/Arch to the bin/ directory
73-
DEV_PLATFORM=${DEV_PLATFORM:-"./pkg/$(${GO_CMD} env GOOS)_$(${GO_CMD} env GOARCH)"}
74-
for F in $(find ${DEV_PLATFORM} -mindepth 1 -maxdepth 1 -type f); do
75-
cp ${F} bin/
76-
rm -f ${MAIN_GOPATH}/bin/vault
77-
cp ${F} ${MAIN_GOPATH}/bin/
78-
done
79-
80-
if [ "${VAULT_DEV_BUILD}x" = "x" ]; then
81-
# Zip and copy to the dist dir
82-
echo "==> Packaging..."
83-
for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do
84-
OSARCH=$(basename ${PLATFORM})
85-
echo "--> ${OSARCH}"
86-
87-
pushd $PLATFORM >/dev/null 2>&1
88-
zip ../${OSARCH}.zip ./*
89-
popd >/dev/null 2>&1
90-
done
91-
fi
53+
rm -f ${MAIN_GOPATH}/bin/vault
54+
cp bin/vault ${MAIN_GOPATH}/bin/
9255

9356
# Done!
9457
echo

scripts/cross/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ ENV GOROOT /goroot
3131
ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
3232

3333
RUN go get golang.org/x/tools/cmd/goimports
34-
RUN go get github.com/mitchellh/gox
3534

3635
RUN mkdir -p /gopath/src/github.com/hashicorp/vault
3736
WORKDIR /gopath/src/github.com/hashicorp/vault

scripts/docker/Dockerfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Multi-stage builder to avoid polluting users environment with wrong
2-
# architecture binaries. Since this binary is used in an alpine container,
3-
# we're explicitly compiling for 'linux/amd64'
2+
# architecture binaries.
43
ARG VERSION=1.17.12
54

65
FROM golang:${VERSION} AS builder
@@ -12,7 +11,7 @@ WORKDIR /go/src/github.com/hashicorp/vault
1211
COPY . .
1312

1413
RUN make bootstrap \
15-
&& CGO_ENABLED=$CGO_ENABLED BUILD_TAGS="${BUILD_TAGS}" VAULT_DEV_BUILD=1 XC_OSARCH='linux/amd64' sh -c "'./scripts/build.sh'"
14+
&& CGO_ENABLED=$CGO_ENABLED BUILD_TAGS="${BUILD_TAGS}" VAULT_DEV_BUILD=1 sh -c "'./scripts/build.sh'"
1615

1716
# Docker Image
1817

@@ -27,7 +26,7 @@ RUN addgroup vault && \
2726
RUN set -eux; \
2827
apk add --no-cache ca-certificates libcap su-exec dumb-init tzdata
2928

30-
COPY --from=builder /go/bin/vault /bin/vault
29+
COPY --from=builder /go/src/github.com/hashicorp/vault/bin/vault /bin/vault
3130

3231
# /vault/logs is made available to use as a location to store audit logs, if
3332
# desired; /vault/file is made available to use as a location with the file

scripts/docker/Dockerfile.ui

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Multi-stage builder to avoid polluting users environment with wrong
2-
# architecture binaries. Since this binary is used in an alpine container,
3-
# we're explicitly compiling for 'linux/amd64'
2+
# architecture binaries. This file only currently works for linux/amd64.
43
FROM debian:buster AS builder
54

65
ARG VERSION=1.17.12
@@ -38,7 +37,7 @@ ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
3837
WORKDIR /go/src/github.com/hashicorp/vault
3938
COPY . .
4039
RUN make bootstrap static-dist \
41-
&& CGO_ENABLED=$CGO_ENABLED BUILD_TAGS="${BUILD_TAGS} ui" VAULT_DEV_BUILD=1 XC_OSARCH='linux/amd64' sh -c "'./scripts/build.sh'"
40+
&& CGO_ENABLED=$CGO_ENABLED BUILD_TAGS="${BUILD_TAGS} ui" VAULT_DEV_BUILD=1 GOOS=linux GOARCH=amd64 sh -c "'./scripts/build.sh'"
4241

4342
# Docker Image
4443

@@ -53,7 +52,7 @@ RUN addgroup vault && \
5352
RUN set -eux; \
5453
apk add --no-cache ca-certificates libcap su-exec dumb-init tzdata
5554

56-
COPY --from=builder /go/bin/vault /bin/vault
55+
COPY --from=builder /go/src/github.com/hashicorp/vault/bin/vault /bin/vault
5756

5857
# /vault/logs is made available to use as a location to store audit logs, if
5958
# desired; /vault/file is made available to use as a location with the file

scripts/windows/build.bat

+2-12
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ del /f "%_GO_ENV_TMP_FILE%" 2>nul
6262
:build
6363
REM Build!
6464
echo ==^> Building...
65-
gox^
66-
-os="%_XC_OS%"^
67-
-arch="%_XC_ARCH%"^
65+
go build^
6866
-ldflags "-X github.com/hashicorp/vault/sdk/version.GitCommit=%_GIT_COMMIT%%_GIT_DIRTY% -X github.com/hashicorp/vault/sdk/version.BuildDate=%_BUILD_DATE%"^
69-
-output "pkg/{{.OS}}_{{.Arch}}/vault"^
67+
-o "bin/vault.exe"^
7068
.
7169

7270
if %ERRORLEVEL% equ 1 set %_EXITCODE%=1
@@ -87,14 +85,6 @@ go env GOOS >"%_GO_ENV_TMP_FILE%"
8785
set /p _GOOS=<"%_GO_ENV_TMP_FILE%"
8886
del /f "%_GO_ENV_TMP_FILE%" 2>nul
8987

90-
REM Copy our OS/Arch to the bin/ directory
91-
set _DEV_PLATFORM=pkg\%_GOOS%_%_GOARCH%
92-
93-
for /r %%f in (%_DEV_PLATFORM%) do (
94-
copy /b /y %%f bin\ >nul
95-
copy /b /y %%f %_GOPATH%\bin\ >nul
96-
)
97-
9888
REM TODO(ceh): package dist
9989

10090
REM Done!

tools/tools.go

-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
package tools
1212

1313
//go:generate go install golang.org/x/tools/cmd/goimports
14-
//go:generate go install github.com/mitchellh/gox
1514
//go:generate go install github.com/client9/misspell/cmd/misspell
1615
//go:generate go install mvdan.cc/gofumpt
1716
//go:generate go install google.golang.org/protobuf/cmd/protoc-gen-go
@@ -20,8 +19,6 @@ package tools
2019
import (
2120
_ "golang.org/x/tools/cmd/goimports"
2221

23-
_ "github.com/mitchellh/gox"
24-
2522
_ "github.com/client9/misspell/cmd/misspell"
2623

2724
_ "mvdan.cc/gofumpt"

0 commit comments

Comments
 (0)