New build_style: go
This commit is contained in:
parent
632a3e8e91
commit
77e8751a93
5 changed files with 66 additions and 38 deletions
24
Manual.md
24
Manual.md
|
@ -513,6 +513,14 @@ arguments can be passed in via `configure_args`.
|
|||
target can be overriden via `make_build_target` and the install target
|
||||
via `make_install_target`.
|
||||
|
||||
- `go` For programs written in Go that follow the standard package
|
||||
structure. The variable `import_path` must be set to the package's
|
||||
import path, e.g. `github.com/github/hub` for the `hub` program. If
|
||||
the variable `go_get` is set to `yes`, the package will be
|
||||
downloaded with `go get`. Otherwise (the default) it's expected that
|
||||
the distfile contains the package. In both cases, dependencies will
|
||||
be downloaded with `go get`.
|
||||
|
||||
- `meta` For `meta-packages`, i.e packages that only install local files or simply
|
||||
depend on additional packages. This build style does not install
|
||||
dependencies to the root directory, and only checks if a binary package is
|
||||
|
@ -923,6 +931,22 @@ path may be specified, i.e `pycompile_dirs="usr/share/foo"`.
|
|||
> NOTE: it's expected that additional subpkgs must be generated to allow packaging for multiple
|
||||
python versions.
|
||||
|
||||
### Go packages
|
||||
|
||||
Go packages should be built with the `go` build style, if possible.
|
||||
The `go` build style takes care of downloading Go dependencies and
|
||||
setting up cross compilation.
|
||||
|
||||
The following variables influence how Go packages are built:
|
||||
|
||||
- `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_get`: If set to yes, the package specified via `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)
|
||||
packages; using a versioned distfile is prefered.
|
||||
|
||||
### Notes
|
||||
|
||||
- Make sure that all software is configured to use the `/usr` prefix.
|
||||
|
|
31
common/build-style/go.sh
Normal file
31
common/build-style/go.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#
|
||||
# This helper is for templates for Go packages.
|
||||
#
|
||||
|
||||
do_build() {
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
armv6*) export GOARCH=arm; export GOARM=6;;
|
||||
armv7*) export GOARCH=arm; export GOARM=7;;
|
||||
i686*) export GOARCH=386;;
|
||||
x86_64*) export GOARCH=amd64;;
|
||||
esac
|
||||
|
||||
export GOPATH="/tmp/gopath"
|
||||
|
||||
if [[ "${go_get}" != "yes" ]]; then
|
||||
local path="${GOPATH}/src/${import_path}"
|
||||
mkdir -p "$(dirname ${path})"
|
||||
ln -fs $PWD "${path}"
|
||||
fi
|
||||
|
||||
go get -d -v "${import_path}"
|
||||
go build -x "${import_path}"
|
||||
}
|
||||
|
||||
do_install() {
|
||||
vbin ${pkgname}
|
||||
}
|
||||
|
||||
do_clean() {
|
||||
rm -rf /tmp/gopath
|
||||
}
|
5
common/environment/build-style/go.sh
Normal file
5
common/environment/build-style/go.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
hostmakedepends+=" go"
|
||||
if [ "$CROSS_BUILD" ]; then
|
||||
hostmakedepends+=" go-cross-linux"
|
||||
fi
|
||||
nostrip=yes
|
|
@ -2,10 +2,9 @@
|
|||
pkgname=gendesk
|
||||
version=0.6.2
|
||||
revision=2
|
||||
hostmakedepends="go git mercurial"
|
||||
if [ "$CROSS_BUILD" ]; then
|
||||
hostmakedepends+=" go-cross-linux"
|
||||
fi
|
||||
build_style=go
|
||||
hostmakedepends="git mercurial"
|
||||
import_path="github.com/xyproto/gendesk"
|
||||
short_desc="Utility to generate .desktop files and download icons"
|
||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||
license="MIT"
|
||||
|
@ -16,21 +15,6 @@ skip_extraction="default.png"
|
|||
checksum="a01ecee04e2397f263b25b1ec94d642fe7f5b8b67eabc6123a923072dd130602
|
||||
4d96eded48e536d02e35727c36dc20844c2e44654e81baf78e10aee4eb48e837"
|
||||
|
||||
do_build() {
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
armv6*) export GOARCH=arm; export GOARM=6;;
|
||||
armv7*) export GOARCH=arm; export GOARM=7;;
|
||||
i686*) export GOARCH=386;;
|
||||
x86_64*) export GOARCH=amd64;;
|
||||
esac
|
||||
|
||||
export GOPATH="$PWD/gopath"
|
||||
mkdir -p $GOPATH/src/github.com/xyproto
|
||||
ln -s $PWD $GOPATH/src/github.com/xyproto/${pkgname}
|
||||
go get -v github.com/xyproto/${pkgname}
|
||||
go build -v github.com/xyproto/${pkgname}
|
||||
}
|
||||
|
||||
do_install() {
|
||||
vbin ${pkgname}
|
||||
vinstall ${XBPS_SRCDISTDIR}/${pkgname}-${version}/default.png 644 usr/share/pixmaps
|
||||
|
|
|
@ -2,31 +2,15 @@
|
|||
pkgname=hub
|
||||
version=2.2.0
|
||||
revision=2
|
||||
build_style=go
|
||||
import_path="github.com/github/hub"
|
||||
hostmakedepends="git"
|
||||
homepage="http://hub.github.com/"
|
||||
distfiles="https://github.com/github/hub/archive/v${version}.tar.gz"
|
||||
hostmakedepends="go"
|
||||
if [ "$CROSS_BUILD" ]; then
|
||||
hostmakedepends+=" go-cross-linux"
|
||||
fi
|
||||
short_desc="command line tool for Github"
|
||||
maintainer="Enno Boland <eb@s01.de>"
|
||||
license="MIT"
|
||||
checksum=2da1351197eb5696c207f22c69a5422af052d74277b73d0b8661efb9ec1d0eb1
|
||||
nostrip=yes
|
||||
|
||||
do_build() {
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
armv6*) export GOARCH=arm; export GOARM=6;;
|
||||
armv7*) export GOARCH=arm; export GOARM=7;;
|
||||
i686*) export GOARCH=386;;
|
||||
x86_64*) export GOARCH=amd64;;
|
||||
esac
|
||||
|
||||
export GOPATH="$PWD/gopath"
|
||||
mkdir -p $GOPATH/src/github.com/github
|
||||
ln -sf $PWD $GOPATH/src/github.com/github/${pkgname}
|
||||
go build -v github.com/github/${pkgname}
|
||||
}
|
||||
|
||||
do_install() {
|
||||
vbin ${pkgname}
|
||||
|
|
Loading…
Reference in a new issue