From 382449cb6e44f2ac7daa5b0fcc6c04956c6bfcf5 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Fri, 17 Apr 2015 18:18:35 +0200 Subject: [PATCH] build-style/go: support building subdirectories --- Manual.md | 9 ++++++--- common/build-style/go.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Manual.md b/Manual.md index e94eca48f93..9406b5fd05a 100644 --- a/Manual.md +++ b/Manual.md @@ -1001,9 +1001,12 @@ setting up cross compilation. The following variables influence how Go packages are built: -- `go_import_path`: The import path of the package, as it would be - used with `go get`. For example, GitHub's `hub` program has the - import path `github.com/github/hub`. This variable is required. +- `go_import_path`: The import path of the package included in the + distfile, as it would be used with `go get`. For example, GitHub's + `hub` program has the import path `github.com/github/hub`. This + variable is required. +- `go_package`: The import path of the package that should be built. + Defaults to `go_import_path`. - `go_get`: If set to yes, the package specified via `go_import_path` will be downloaded with `go get`. Otherwise, a distfile has to be provided. This option should only be used with `-git` (or similar) diff --git a/common/build-style/go.sh b/common/build-style/go.sh index dee1ef795e4..e5887f8d077 100644 --- a/common/build-style/go.sh +++ b/common/build-style/go.sh @@ -9,10 +9,14 @@ do_build() { ln -fs $PWD "${path}" fi - go get -d "${go_import_path}" - go build -x "${go_import_path}" + go_package=${go_package:-$go_import_path} + cd "${GOPATH}/src/${go_package}" + go get -d "${go_package}" + go build -x "${go_package}" } do_install() { + go_package=${go_package:-$go_import_path} + cd "${GOPATH}/src/${go_package}" vbin ${pkgname} }