Skip to content

Conversation

@anguslees
Copy link

Merge the good bits from alternate golang recipe
https://gitlab.com/anguslees/meta-containos/tree/devel/recipes-devtools/go

Highlights:

  • go compiler patch to fix CC env handling
  • No need to build go-cross packages with go >=1.5
  • "More normal" handling of SRC_URI and other variables.

In particular, the unpacked source is now in $S as expected (not
$S/src/$GOIMPORT) so LICENSE files, patches, etc work as usual without
additional paths.

In addition:
- GOPATH is now exposed as a regular bitbake variable.
- GO binary is overridable (eg: to prefix it with godep)
- GO_{GCFLAGS,LDFLAGS} are no longer set from TARGET_CFLAGS/LDFLAGS.
  go no longer uses gcc, so these flags are unlikely to be correct.
- New variables: GO_ASMFLAGS, GO_FLAGS
Specific criteria is probably incomplete.  Patches welcome.
caddy doesn't actually build because all these recipes use AUTOREV and
upstream sources have drifted to include new dependencies.  I'm not
interested in maintaining these, but they should continue to serve as
examples of how to use go.bbclass.

(And this also serves as a good example of why we shouldn't use AUTOREV)
We only need go 1.4 to bootstrap newer versions of go compiler.
Upstream seems to be confused whether CC should have multiple
args (separated by spaces) or be one arg (that may contain spaces).
We would prefer the former / usual as this matches uses of $CC in
other environments - so this patch does that.
In particular:
- Use bitbake environment variables rather than set in shell fragments
- Remove setup_cgo_gcc_wrapper (obsoleted by cc-args.patch)
- Cleanup path handling to take advantage of ${S}
DEPEND on go-native rather than go-cross (go >= 1.5 can cross-compile
to all supported architectures from the single native binary).

Mark ${PN}-dev as package arch "all" because it contains only golang
src code.  ${PN}-staticdev contains the cross-compiled static
libraries and remains arch-specific.

Various minor path fixes and cleanups.
Standard go >=1.5 compiler can cross compile to all architectures with
the one binary.
@anguslees
Copy link
Author

anguslees commented Mar 4, 2017

(Apologies for the size of the PR - I can attempt to break this up further if you wish)

@anguslees
Copy link
Author

ping?


FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://COPYING;md5=389a9e29629d1f05e115f8f05c283df5"
S = "${WORKDIR}/git"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be simplified even futher similar to how the pypi.bbclass is implemented.

For example in a gopkg.bbclass it could:

  • the SRC_URI could be derived from the import path
  • S could be set by default
  • fill the HOMEPAGE variable

There would only be a minimal set of information required for a standard conform packages, like it is for python for example: https://github.com/openembedded/meta-openembedded/blob/master/meta-python/recipes-devtools/python/python-chardet.inc

Example:

GO_IMPORT = "github.com/BurntSushi/toml"
LICENSE = "DWTFYW"
LIC_FILES_CHKSUM = "file://COPYING;md5=389a9e29629d1f05e115f8f05c283df5"

SRCREV = "${AUTOREV}"

inherit gopkg

@mem
Copy link
Owner

mem commented Mar 31, 2017

Hi, sorry about the delay. It looks good, but I'm still going over a couple of things. Hopefully I can get this merged today or tomorrow.

Thanks for the cleanup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants