build-style/go: support building subdirectories

This commit is contained in:
Dominik Honnef 2015-04-17 18:18:35 +02:00
parent 4df6e4d709
commit 382449cb6e
2 changed files with 12 additions and 5 deletions

View File

@ -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)

View File

@ -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}
}