go-1.10.3.ebuild (5857B)
1 # Copyright 1999-2018 Gentoo Foundation 2 # Distributed under the terms of the GNU General Public License v2 3 4 EAPI=6 5 6 export CBUILD=${CBUILD:-${CHOST}} 7 export CTARGET=${CTARGET:-${CHOST}} 8 9 MY_PV=${PV/_/} 10 11 inherit toolchain-funcs 12 13 BOOTSTRAP_DIST="https://dev.gentoo.org/~williamh/dist" 14 BOOTSTRAP_VERSION="bootstrap-1.8" 15 BOOTSTRAP_URI=" 16 amd64? ( ${BOOTSTRAP_DIST}/go-linux-amd64-${BOOTSTRAP_VERSION}.tbz ) 17 arm? ( ${BOOTSTRAP_DIST}/go-linux-arm-${BOOTSTRAP_VERSION}.tbz ) 18 arm64? ( ${BOOTSTRAP_DIST}/go-linux-arm64-${BOOTSTRAP_VERSION}.tbz ) 19 ppc64? ( 20 ${BOOTSTRAP_DIST}/go-linux-ppc64-${BOOTSTRAP_VERSION}.tbz 21 ${BOOTSTRAP_DIST}/go-linux-ppc64le-${BOOTSTRAP_VERSION}.tbz 22 ) 23 s390? ( ${BOOTSTRAP_DIST}/go-linux-s390x-${BOOTSTRAP_VERSION}.tbz ) 24 x86? ( ${BOOTSTRAP_DIST}/go-linux-386-${BOOTSTRAP_VERSION}.tbz ) 25 amd64-fbsd? ( ${BOOTSTRAP_DIST}/go-freebsd-amd64-${BOOTSTRAP_VERSION}.tbz ) 26 x86-fbsd? ( ${BOOTSTRAP_DIST}/go-freebsd-386-${BOOTSTRAP_VERSION}.tbz ) 27 x64-macos? ( ${BOOTSTRAP_DIST}/go-darwin-amd64-${BOOTSTRAP_VERSION}.tbz ) 28 x64-solaris? ( ${BOOTSTRAP_DIST}/go-solaris-amd64-${BOOTSTRAP_VERSION}.tbz ) 29 " 30 31 case ${PV} in 32 *9999*) 33 EGIT_REPO_URI="https://github.com/golang/go.git" 34 inherit git-r3 35 ;; 36 *) 37 SRC_URI="https://storage.googleapis.com/golang/go${MY_PV}.src.tar.gz " 38 S="${WORKDIR}"/go 39 case ${PV} in 40 *_beta*|*_rc*) ;; 41 *) 42 KEYWORDS="~amd64 ~arm ~x86" 43 # The upstream tests fail under portage but pass if the build is 44 # run according to their documentation [1]. 45 # I am restricting the tests on released versions until this is 46 # solved. 47 # [1] https://golang.org/issues/18442 48 RESTRICT="test" 49 ;; 50 esac 51 esac 52 SRC_URI+="!gccgo? ( !bootstrap? ( ${BOOTSTRAP_URI} ) )" 53 54 DESCRIPTION="A concurrent garbage collected and typesafe programming language" 55 HOMEPAGE="https://golang.org" 56 57 LICENSE="BSD" 58 SLOT="0/${PV}" 59 IUSE="gccgo bootstrap" 60 61 DEPEND=" 62 gccgo? ( >=sys-devel/gcc-5[go] ) 63 bootstrap? ( dev-lang/go-bootstrap ) 64 " 65 RDEPEND="!<dev-go/go-tools-0_pre20150902" 66 67 # These test data objects have writable/executable stacks. 68 QA_EXECSTACK=" 69 usr/lib/go/src/debug/elf/testdata/*.obj 70 usr/lib/go/src/go/internal/gccgoimporter/testdata/escapeinfo.gox 71 usr/lib/go/src/go/internal/gccgoimporter/testdata/unicode.gox 72 usr/lib/go/src/go/internal/gccgoimporter/testdata/time.gox 73 " 74 75 # Do not complain about CFLAGS, etc, since Go doesn't use them. 76 QA_FLAGS_IGNORED='.*' 77 78 REQUIRES_EXCLUDE="/usr/lib/go/src/debug/elf/testdata/*" 79 80 # The tools in /usr/lib/go should not cause the multilib-strict check to fail. 81 QA_MULTILIB_PATHS="usr/lib/go/pkg/tool/.*/.*" 82 83 # Do not strip this package. Stripping is unsupported upstream and may 84 # fail. 85 RESTRICT+=" strip" 86 87 DOCS=( 88 AUTHORS 89 CONTRIBUTING.md 90 CONTRIBUTORS 91 PATENTS 92 README.md 93 ) 94 95 go_arch() 96 { 97 # By chance most portage arch names match Go 98 local portage_arch=$(tc-arch $@) 99 case "${portage_arch}" in 100 x86) echo 386;; 101 x64-*) echo amd64;; 102 ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;; 103 s390) echo s390x ;; 104 *) echo "${portage_arch}";; 105 esac 106 } 107 108 go_arm() 109 { 110 case "${1:-${CHOST}}" in 111 armv5*) echo 5;; 112 armv6*) echo 6;; 113 armv7*) echo 7;; 114 *) 115 die "unknown GOARM for ${1:-${CHOST}}" 116 ;; 117 esac 118 } 119 120 go_os() 121 { 122 case "${1:-${CHOST}}" in 123 *-linux*) echo linux;; 124 *-darwin*) echo darwin;; 125 *-freebsd*) echo freebsd;; 126 *-netbsd*) echo netbsd;; 127 *-openbsd*) echo openbsd;; 128 *-solaris*) echo solaris;; 129 *-cygwin*|*-interix*|*-winnt*) 130 echo windows 131 ;; 132 *) 133 die "unknown GOOS for ${1:-${CHOST}}" 134 ;; 135 esac 136 } 137 138 go_tuple() 139 { 140 echo "$(go_os $@)_$(go_arch $@)" 141 } 142 143 go_cross_compile() 144 { 145 [[ $(go_tuple ${CBUILD}) != $(go_tuple) ]] 146 } 147 148 pkg_pretend() 149 { 150 # make.bash does not understand cross-compiling a cross-compiler 151 if [[ $(go_tuple) != $(go_tuple ${CTARGET}) ]]; then 152 die "CHOST CTARGET pair unsupported: CHOST=${CHOST} CTARGET=${CTARGET}" 153 fi 154 } 155 156 src_unpack() 157 { 158 if [[ ${PV} = 9999 ]]; then 159 git-r3_src_unpack 160 fi 161 default 162 } 163 164 src_compile() 165 { 166 export GOROOT_BOOTSTRAP="${WORKDIR}"/go-$(go_os)-$(go_arch)-bootstrap 167 if use gccgo; then 168 mkdir -p "${GOROOT_BOOTSTRAP}/bin" || die 169 local go_binary=$(gcc-config --get-bin-path)/go-$(gcc-major-version) 170 [[ -x ${go_binary} ]] || go_binary=$( 171 find "${EPREFIX}"/usr/${CHOST}/gcc-bin/*/go-$(gcc-major-version) | 172 sort -V | tail -n1) 173 [[ -x ${go_binary} ]] || 174 die "go-$(gcc-major-version): command not found" 175 ln -s "${go_binary}" "${GOROOT_BOOTSTRAP}/bin/go" || die 176 fi 177 if use bootstrap; then 178 mkdir -p "${GOROOT_BOOTSTRAP}/bin" || die 179 ln -s "${EPREFIX}/usr/lib/go1.4/bin/go" "${GOROOT_BOOTSTRAP}/bin/go" || die 180 export GOROOT_BOOTSTRAP="${EPREFIX}/usr/lib/go1.4" 181 fi 182 export GOROOT_FINAL="${EPREFIX}"/usr/lib/go 183 export GOROOT="$(pwd)" 184 export GOBIN="${GOROOT}/bin" 185 186 # Go's build script does not use BUILD/HOST/TARGET consistently. :( 187 export GOHOSTARCH=$(go_arch ${CBUILD}) 188 export GOHOSTOS=$(go_os ${CBUILD}) 189 export CC=$(tc-getBUILD_CC) 190 191 export GOARCH=$(go_arch) 192 export GOOS=$(go_os) 193 export CC_FOR_TARGET=$(tc-getCC) 194 export CXX_FOR_TARGET=$(tc-getCXX) 195 if [[ ${ARCH} == arm ]]; then 196 export GOARM=$(go_arm) 197 fi 198 einfo "GOROOT_BOOTSTRAP is ${GOROOT_BOOTSTRAP}" 199 200 cd src 201 ./make.bash || die "build failed" 202 } 203 204 src_test() 205 { 206 go_cross_compile && return 0 207 208 cd src 209 PATH="${GOBIN}:${PATH}" \ 210 ./run.bash -no-rebuild || die "tests failed" 211 } 212 213 src_install() 214 { 215 local bin_path f x 216 217 dodir /usr/lib/go 218 219 # There is a known issue which requires the source tree to be installed [1]. 220 # Once this is fixed, we can consider using the doc use flag to control 221 # installing the doc and src directories. 222 # [1] https://golang.org/issue/2775 223 # 224 # deliberately use cp to retain permissions 225 cp -R api bin doc lib pkg misc src test "${ED}"/usr/lib/go 226 if go_cross_compile; then 227 bin_path="bin/$(go_tuple)" 228 else 229 bin_path=bin 230 fi 231 for x in ${bin_path}/*; do 232 f=${x##*/} 233 dosym ../lib/go/${bin_path}/${f} /usr/bin/${f} 234 done 235 einstalldocs 236 }