diff --git a/Manual.md b/Manual.md index 816941e03ab..1c68481a8b5 100644 --- a/Manual.md +++ b/Manual.md @@ -1196,6 +1196,12 @@ The following variables influence how Go packages are built: - `go_build_tags`: An optional, space-separated list of build tags to pass to Go. +Occasionally it is necessary to perform operations from within the Go +source tree. This is usually needed by programs using go-bindata or +otherwise preping some assets. If possible do this in pre_build(). +The path to the package's source inside `$GOPATH` is available as +`$GOSRCPATH`. + ### Haskell packages diff --git a/common/build-style/go.sh b/common/build-style/go.sh index 71c6e55da09..01a50b167e0 100644 --- a/common/build-style/go.sh +++ b/common/build-style/go.sh @@ -2,18 +2,17 @@ # This helper is for templates for Go packages. # -do_build() { - local path="${GOPATH}/src/${go_import_path}" +do_configure() { + # This isn't really configuration, but its needed by packages + # that do unusual things with the build where the expect to be + # able to cd into the $GOSRCPATH if [[ "${go_get}" != "yes" ]]; then - mkdir -p "$(dirname ${path})" - ln -fs $PWD "${path}" - fi - - if [ -x /usr/bin/dep ] && [ -f Gopkg.toml ] && [ -f Gopkg.lock ]; then - cd "${path}" - dep ensure + mkdir -p "$(dirname ${GOSRCPATH})" + ln -fs $PWD "${GOSRCPATH}" fi +} +do_build() { go_package=${go_package:-$go_import_path} go get -x -tags "${go_build_tags}" -ldflags "${go_ldflags}" ${go_package} } diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh index be8e68b6603..b6be9f1e609 100644 --- a/common/environment/build-style/go.sh +++ b/common/environment/build-style/go.sh @@ -14,6 +14,7 @@ case "$XBPS_TARGET_MACHINE" in esac export GOPATH="${wrksrc}/_build-${pkgname}-xbps" +GOSRCPATH="${GOPATH}/src/${go_import_path}" export CGO_CFLAGS="$CFLAGS" export CGO_CPPFLAGS="$CPPFLAGS" export CGO_CXXFLAGS="$CXXFLAGS"