common/build-style/go.sh: update go build style for go1.21.0
This commit is contained in:
parent
9499a43f0a
commit
4c22fd9b48
2 changed files with 13 additions and 1 deletions
|
@ -32,8 +32,13 @@ do_build() {
|
||||||
go_package=${go_package:-$go_import_path}
|
go_package=${go_package:-$go_import_path}
|
||||||
# Build using Go modules if there's a go.mod file
|
# Build using Go modules if there's a go.mod file
|
||||||
if [ "${go_mod_mode}" != "off" ] && [ -f go.mod ]; then
|
if [ "${go_mod_mode}" != "off" ] && [ -f go.mod ]; then
|
||||||
|
|
||||||
|
if [[ -n "${_go_mod_path}" ]]; then
|
||||||
|
pushd $(dirname ${_go_mod_path})
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if go_import_path matches module
|
# Check if go_import_path matches module
|
||||||
if [ "module $go_import_path" != "$(head -n1 go.mod)" ]; then
|
if [ "module $go_import_path" != "$(grep '^module' go.mod | head -n1)" ]; then
|
||||||
msg_error "\"\$go_import_path\" doesn't match the one defined in go.mod!\n"
|
msg_error "\"\$go_import_path\" doesn't match the one defined in go.mod!\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -46,6 +51,9 @@ do_build() {
|
||||||
go_mod_mode=
|
go_mod_mode=
|
||||||
fi
|
fi
|
||||||
go install -p "$XBPS_MAKEJOBS" -mod="${go_mod_mode}" -modcacherw -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
|
go install -p "$XBPS_MAKEJOBS" -mod="${go_mod_mode}" -modcacherw -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
|
||||||
|
if [[ -n "${_go_mod_path}" ]]; then
|
||||||
|
popd
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# Otherwise, build using GOPATH
|
# Otherwise, build using GOPATH
|
||||||
go get -p "$XBPS_MAKEJOBS" -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
|
go get -p "$XBPS_MAKEJOBS" -v -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package}
|
||||||
|
|
|
@ -39,6 +39,10 @@ export CGO_CXXFLAGS="$CXXFLAGS"
|
||||||
export CGO_LDFLAGS="$LDFLAGS"
|
export CGO_LDFLAGS="$LDFLAGS"
|
||||||
export CGO_ENABLED="${CGO_ENABLED:-1}"
|
export CGO_ENABLED="${CGO_ENABLED:-1}"
|
||||||
export GO111MODULE=auto
|
export GO111MODULE=auto
|
||||||
|
export GOTOOLCHAIN=local
|
||||||
|
export GOPROXY="https://proxy.golang.org,direct"
|
||||||
|
export GOSUMDB="sum.golang.org"
|
||||||
|
|
||||||
case "$XBPS_TARGET_MACHINE" in
|
case "$XBPS_TARGET_MACHINE" in
|
||||||
*-musl) export GOCACHE="${XBPS_HOSTDIR}/gocache-muslc" ;;
|
*-musl) export GOCACHE="${XBPS_HOSTDIR}/gocache-muslc" ;;
|
||||||
*) export GOCACHE="${XBPS_HOSTDIR}/gocache-glibc" ;;
|
*) export GOCACHE="${XBPS_HOSTDIR}/gocache-glibc" ;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue