AdGuardDNS/scripts/make/go-tools.sh

84 lines
2.1 KiB
Bash
Raw Permalink Normal View History

2022-08-26 14:18:35 +03:00
#!/bin/sh
2022-12-29 15:36:26 +03:00
# This comment is used to simplify checking local copies of the script. Bump
2022-11-29 18:20:10 +03:00
# this number every time a significant change is made to this script.
2022-12-29 15:36:26 +03:00
#
2024-10-14 17:44:24 +03:00
# AdGuard-Project-Version: 6
2022-11-29 18:20:10 +03:00
2022-08-26 14:18:35 +03:00
verbose="${VERBOSE:-0}"
readonly verbose
2024-10-14 17:44:24 +03:00
if [ "$verbose" -gt '1' ]; then
2022-08-26 14:18:35 +03:00
set -x
2022-11-29 18:20:10 +03:00
v_flags='-v=1'
x_flags='-x=1'
2024-10-14 17:44:24 +03:00
elif [ "$verbose" -gt '0' ]; then
2022-08-26 14:18:35 +03:00
set -x
2022-11-29 18:20:10 +03:00
v_flags='-v=1'
x_flags='-x=0'
2022-08-26 14:18:35 +03:00
else
set +x
2022-11-29 18:20:10 +03:00
v_flags='-v=0'
x_flags='-x=0'
2022-08-26 14:18:35 +03:00
fi
readonly v_flags x_flags
set -e -f -u
go="${GO:-go}"
readonly go
2022-11-29 18:20:10 +03:00
# Remove only the actual binaries in the bin/ directory, as developers may add
# their own scripts there. Most commonly, a script named “go” for tools that
# call the go binary and need a particular version.
2024-10-14 17:44:24 +03:00
rm -f \
bin/errcheck \
bin/fieldalignment \
bin/go-junit-report \
bin/gocognit \
bin/gocyclo \
bin/gofumpt \
bin/gosec \
bin/govulncheck \
bin/ineffassign \
bin/misspell \
bin/nilness \
bin/protoc-gen-go \
bin/protoc-gen-go-grpc \
bin/shadow \
bin/shfmt \
bin/staticcheck \
bin/unparam \
2022-11-29 18:20:10 +03:00
;
2022-08-26 14:18:35 +03:00
# Reset GOARCH and GOOS to make sure we install the tools for the native
# architecture even when we're cross-compiling the main binary, and also to
# prevent the "cannot install cross-compiled binaries when GOBIN is set" error.
2024-10-14 17:44:24 +03:00
env \
GOARCH="" \
GOBIN="${PWD}/bin" \
GOOS="" \
GOWORK='off' \
"$go" install \
--modfile=./internal/tools/go.mod \
"$v_flags" \
"$x_flags" \
github.com/fzipp/gocyclo/cmd/gocyclo \
github.com/golangci/misspell/cmd/misspell \
github.com/gordonklaus/ineffassign \
github.com/jstemmer/go-junit-report/v2 \
github.com/kisielk/errcheck \
github.com/securego/gosec/v2/cmd/gosec \
github.com/uudashr/gocognit/cmd/gocognit \
golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment \
golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness \
golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow \
golang.org/x/vuln/cmd/govulncheck \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
honnef.co/go/tools/cmd/staticcheck \
mvdan.cc/gofumpt \
mvdan.cc/sh/v3/cmd/shfmt \
mvdan.cc/unparam \
2022-08-26 14:18:35 +03:00
;