Skip to content

Commit

Permalink
all: add race build mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Apr 2, 2021
1 parent 70d4c70 commit 20af1ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GPG_KEY = [email protected]
GPG_KEY_PASSPHRASE = not-a-real-password
NPM = npm
NPM_FLAGS = --prefix $(CLIENT_DIR)
RACE = 0
SIGN = 1
VERBOSE = 0
VERSION = v0.0.0
Expand All @@ -30,6 +31,7 @@ ENV = env\
GO='$(GO)'\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
RACE='$(RACE)'\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
VERSION='$(VERSION)'\
Expand Down
18 changes: 15 additions & 3 deletions scripts/make/go-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,22 @@ else
readonly out_flags=''
fi

# Don't use cgo. Use modules.
export CGO_ENABLED='0' GO111MODULE='on'
# Allow users to enable the race detector. Unfortunately, that means
# that CGo must be enabled.
readonly race="${RACE:-0}"
if [ "$race" = '0' ]
then
readonly cgo_enabled='0'
readonly race_flags=''
else
readonly cgo_enabled='1'
readonly race_flags='--race'
fi

export CGO_ENABLED="$cgo_enabled"
export GO111MODULE='on'

readonly build_flags="${BUILD_FLAGS:-$out_flags $par_flags\
readonly build_flags="${BUILD_FLAGS:-$race_flags $out_flags $par_flags\
$v_flags $x_flags}"

# Don't use quotes with flag variables to get word splitting.
Expand Down

0 comments on commit 20af1ab

Please sign in to comment.