golang-base.eclass 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: golang-build.eclass
  4. # @MAINTAINER:
  5. # William Hubbs <williamh@gentoo.org>
  6. # @BLURB: Eclass that provides base functions for Go packages.
  7. # @DESCRIPTION:
  8. # This eclass provides base functions for software written in the Go
  9. # programming language; it also provides the build-time dependency on
  10. # dev-lang/go.
  11. case "${EAPI:-0}" in
  12. 5|6)
  13. ;;
  14. *)
  15. die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
  16. ;;
  17. esac
  18. if [[ -z ${_GOLANG_BASE} ]]; then
  19. _GOLANG_BASE=1
  20. DEPEND=">=dev-lang/go-1.7:="
  21. # Do not complain about CFLAGS etc since go projects do not use them.
  22. QA_FLAGS_IGNORED='.*'
  23. STRIP_MASK="*.a"
  24. # @ECLASS-VARIABLE: EGO_PN
  25. # @REQUIRED
  26. # @DESCRIPTION:
  27. # This is the import path for the go package to build. Please emerge
  28. # dev-lang/go and read "go help importpath" for syntax.
  29. #
  30. # Example:
  31. # @CODE
  32. # EGO_PN=github.com/user/package
  33. # @CODE
  34. # @FUNCTION: ego_pn_check
  35. # @DESCRIPTION:
  36. # Make sure EGO_PN has a value.
  37. ego_pn_check() {
  38. [[ -z "${EGO_PN}" ]] &&
  39. die "${ECLASS}.eclass: EGO_PN is not set"
  40. return 0
  41. }
  42. # @FUNCTION: get_golibdir
  43. # @DESCRIPTION:
  44. # Return the non-prefixed library directory where Go packages
  45. # should be installed
  46. get_golibdir() {
  47. echo /usr/lib/go-gentoo
  48. }
  49. # @FUNCTION: get_golibdir_gopath
  50. # @DESCRIPTION:
  51. # Return the library directory where Go packages should be installed
  52. # This is the prefixed version which should be included in GOPATH
  53. get_golibdir_gopath() {
  54. echo "${EPREFIX}$(get_golibdir)"
  55. }
  56. # @FUNCTION: golang_install_pkgs
  57. # @DESCRIPTION:
  58. # Install Go packages.
  59. # This function assumes that $cwd is a Go workspace.
  60. golang_install_pkgs() {
  61. debug-print-function ${FUNCNAME} "$@"
  62. ego_pn_check
  63. insinto "$(get_golibdir)"
  64. insopts -m0644 -p # preserve timestamps for bug 551486
  65. doins -r pkg src
  66. }
  67. fi