Gentoo Archives: gentoo-commits

From: Haelwenn Monnier <contact@×××××××××.me>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:master commit in: eclass/
Date: Mon, 24 May 2021 22:25:57
Message-Id: 1621867795.55604b91a81e9e391253623c7b3ce40f57eec0b0.lanodan@gentoo
1 commit: 55604b91a81e9e391253623c7b3ce40f57eec0b0
2 Author: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com>
3 AuthorDate: Mon May 24 14:48:21 2021 +0000
4 Commit: Haelwenn Monnier <contact <AT> hacktivis <DOT> me>
5 CommitDate: Mon May 24 14:49:55 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=55604b91
7
8 eclass: remove unused eclasses
9
10 Signed-off-by: Alessandro Barbieri <lssndrbarbieri <AT> gmail.com>
11
12 eclass/golang-common.eclass | 1027 -------------------------------------------
13 eclass/golang-single.eclass | 180 --------
14 2 files changed, 1207 deletions(-)
15
16 diff --git a/eclass/golang-common.eclass b/eclass/golang-common.eclass
17 deleted file mode 100644
18 index 85dac9d25..000000000
19 --- a/eclass/golang-common.eclass
20 +++ /dev/null
21 @@ -1,1027 +0,0 @@
22 -# Copyright 1999-2021 Gentoo Authors
23 -# Distributed under the terms of the GNU General Public License v2
24 -
25 -# @ECLASS: golang-utils.eclass
26 -# @MAINTAINER:
27 -#
28 -# @AUTHOR:
29 -# Mauro Toffanin <toffanin.mauro@×××××.com>
30 -# @BLURB: Base eclass for GoLang packages
31 -# @SUPPORTED_EAPIS: 7
32 -# @DESCRIPTION:
33 -# This eclass provides functionalities which are used by golang-single.eclass,
34 -# golang-live.eclass, and as well as from ebuilds.
35 -#
36 -# This eclass should not be inherited directly from an ebuild.
37 -# Instead, you should inherit golang-single or golang-live for GoLang packages.
38 -
39 -inherit eutils multiprocessing
40 -
41 -if [[ -z ${_GOLANG_BASE_ECLASS} ]]; then
42 -_GOLANG_BASE_ECLASS=1
43 -
44 -# Silences repoman warnings.
45 -case "${EAPI:-0}" in
46 - 7)
47 - case "${GOLANG_PKG_DEPEND_ON_GO_SUBSLOT:-yes}" in
48 - yes)
49 - GO_DEPEND="dev-lang/go:0="
50 - ;;
51 - *)
52 - GO_DEPEND="dev-lang/go:*"
53 - ;;
54 - esac
55 - ;;
56 - *)
57 - die "${ECLASS}: EAPI=${EAPI:-0} is not supported" ;;
58 -esac
59 -
60 -DEPEND+=" ${GO_DEPEND}"
61 -
62 -RESTRICT+=" strip"
63 -
64 -QA_FLAGS_IGNORED="
65 - usr/bin/.*
66 - usr/sbin/.*
67 -"
68 -QA_PRESTRIPPED="
69 - usr/bin/.*
70 - usr/sbin/.*
71 -"
72 -
73 -# @ECLASS-VARIABLE: GOLANG_PKG_NAME
74 -# @DESCRIPTION:
75 -# Sets the GoLang name for the generated package.
76 -# GOLANG_PKG_NAME="${PN}"
77 -GOLANG_PKG_NAME="${GOLANG_PKG_NAME:-${PN}}"
78 -
79 -# @ECLASS-VARIABLE: GOLANG_PKG_VERSION
80 -# @DESCRIPTION:
81 -# Sets the GoLang version for the generated package.
82 -# GOLANG_PKG_VERSION="${PV}"
83 -GOLANG_PKG_VERSION="${GOLANG_PKG_VERSION:-${PV/_pre/.pre}}"
84 -
85 -# @ECLASS-VARIABLE: GOLANG_PKG_IMPORTPATH
86 -# @DESCRIPTION:
87 -# Sets the remote import path for the generated package.
88 -# GOLANG_PKG_IMPORTPATH="github.com/captObvious/"
89 -GOLANG_PKG_IMPORTPATH="${GOLANG_PKG_IMPORTPATH:-}"
90 -
91 -# @ECLASS-VARIABLE: GOLANG_PKG_IMPORTPATH_ALIAS
92 -# @DESCRIPTION:
93 -# Sets an alias of the remote import path for the generated package.
94 -# GOLANG_PKG_IMPORTPATH_ALIAS="privaterepo.com/captObvious/"
95 -GOLANG_PKG_IMPORTPATH_ALIAS="${GOLANG_PKG_IMPORTPATH_ALIAS:=${GOLANG_PKG_IMPORTPATH}}"
96 -
97 -# @ECLASS-VARIABLE: GOLANG_PKG_ARCHIVEPREFIX
98 -# @DESCRIPTION:
99 -# Sets the archive prefix for the file URI of the package.
100 -# Most projects hosted on GitHub's mirrors provide archives with prefix as
101 -# 'v' or 'source-', other hosted services offer different archive formats.
102 -# This eclass defaults to an empty prefix.
103 -GOLANG_PKG_ARCHIVEPREFIX="${GOLANG_PKG_ARCHIVEPREFIX:-}"
104 -
105 -# @ECLASS-VARIABLE: GOLANG_PKG_ARCHIVESUFFIX
106 -# @DESCRIPTION:
107 -# Sets the archive suffix for the file URI of the package.
108 -# Most projects hosted on GitHub's mirrors provide archives with suffix as
109 -# '.tar.gz' or '.zip', other hosted services offer different archive formats.
110 -# This eclass defaults to '.tar.gz'.
111 -GOLANG_PKG_ARCHIVESUFFIX="${GOLANG_PKG_ARCHIVESUFFIX:=".tar.gz"}"
112 -
113 -# @ECLASS-VARIABLE: GOLANG_PKG_OUTPUT_NAME
114 -# @DESCRIPTION:
115 -# Specifies the output file name of the package.
116 -# If not set, it derives from the name of the package, such as $GOLANG_PKG_NAME.
117 -# This eclass defaults to $PN.
118 -GOLANG_PKG_OUTPUT_NAME="${GOLANG_PKG_OUTPUT_NAME:=${PN}}"
119 -
120 -# @ECLASS-VARIABLE: GOLANG_PKG_BUILDPATH
121 -# @DESCRIPTION:
122 -# Specifies a go source file to be compiled as a single main package.
123 -# This eclass defaults to an empty value.
124 -# This eclass defaults to "/..." when the user declares GOLANG_PKG_IS_MULTIPLE=1
125 -GOLANG_PKG_BUILDPATH="${GOLANG_PKG_BUILDPATH:-}"
126 -
127 -# @ECLASS-VARIABLE: GOLANG_PKG_INSTALLPATH
128 -# @DESCRIPTION:
129 -# Sets the root path into which a binary, or a list of binaries, will be
130 -# installed (e.x.: ${GOLANG_PKG_INSTALLPATH}/bin).
131 -# This eclass defaults to "/usr"
132 -GOLANG_PKG_INSTALLPATH="${GOLANG_PKG_INSTALLPATH:="/usr"}"
133 -
134 -# @ECLASS-VARIABLE: GOLANG_PKG_INSTALLSUFFIX
135 -# @DESCRIPTION:
136 -# Sets a suffix to use in the name of the package installation directory.
137 -# This eclass defaults to an empty install suffix.
138 -GOLANG_PKG_INSTALLSUFFIX="${GOLANG_PKG_INSTALLSUFFIX:-}"
139 -
140 -# @ECLASS-VARIABLE: GOLANG_PKG_IS_MULTIPLE
141 -# @DESCRIPTION:
142 -# Set to enable the building of multiple packages from a single import path.
143 -
144 -# @ECLASS-VARIABLE: GOLANG_PKG_HAVE_TEST
145 -# @DEFAULT_UNSET
146 -# @DESCRIPTION:
147 -# Set to enable the execution of automated testing.
148 -
149 -# @ECLASS-VARIABLE: GOLANG_PKG_HAVE_TEST_RACE
150 -# @DEFAULT_UNSET
151 -# @DESCRIPTION:
152 -# Set to enable the execution of automated testing with support for
153 -# data race detection.
154 -
155 -# @ECLASS-VARIABLE: GOLANG_PKG_USE_CGO
156 -# @DEFAULT_UNSET
157 -# @DESCRIPTION:
158 -# Set to enable the compilation of the package with CGO.
159 -
160 -# @ECLASS-VARIABLE: GOLANG_PKG_USE_GENERATE
161 -# @DEFAULT_UNSET
162 -# @DESCRIPTION:
163 -# Set to run commands described by directives within existing golang files.
164 -
165 -# @ECLASS-VARIABLE: GOLANG_PKG_DEPEND_ON_GO_SUBSLOT
166 -# @DESCRIPTION:
167 -# Set to ensure the package does depend on the dev-lang/go subslot value.
168 -# Possible values: {yes,no}
169 -# This eclass defaults to "no"
170 -GOLANG_PKG_DEPEND_ON_GO_SUBSLOT=${GOLANG_PKG_DEPEND_ON_GO_SUBSLOT:="no"}
171 -
172 -# @ECLASS-VARIABLE: GOLANG_PKG_LDFLAGS
173 -# @DESCRIPTION:
174 -# Sets the linker arguments to pass to 5l, 6l, or 8l.
175 -# This eclass defaults to an empty list.
176 -GOLANG_PKG_LDFLAGS="${GOLANG_PKG_LDFLAGS:-}"
177 -
178 -# @ECLASS-VARIABLE: GOLANG_PKG_TAGS
179 -# @DESCRIPTION:
180 -# Sets the list of build tags during the build.
181 -# This eclass defaults to an empty list.
182 -GOLANG_PKG_TAGS="${GOLANG_PKG_TAGS:-}"
183 -
184 -# @ECLASS-VARIABLE: GOLANG_PKG_VENDOR
185 -# @DESCRIPTION:
186 -# Sets additional standard Go workspaces to be appended to the environment
187 -# variable GOPATH, as described in http://golang.org/doc/code.html.
188 -# This eclass defaults to an empty list.
189 -GOLANG_PKG_VENDOR=()
190 -
191 -# @ECLASS-VARIABLE: GOLANG_PKG_STATIK
192 -# @DESCRIPTION:
193 -# Sets the arguments to pass to dev-go/statik.
194 -# This eclass defaults to an empty list.
195 -GOLANG_PKG_STATIK="${GOLANG_PKG_STATIK:-}"
196 -
197 -# @ECLASS-VARIABLE: GOLANG_PKG_USE_MODULES
198 -# @DESCRIPTION:
199 -# Set to enable the compilation of the package with Go modules support.
200 -
201 -# @ECLASS-VARIABLE: GO
202 -# @DEFAULT_UNSET
203 -# @DESCRIPTION:
204 -# The absolute path to the current GoLang interpreter.
205 -#
206 -# This variable is set automatically after calling golang_setup().
207 -#
208 -# Default value:
209 -# @CODE
210 -# /usr/bin/go
211 -# @CODE
212 -
213 -# @ECLASS-VARIABLE: EGO
214 -# @DEFAULT_UNSET
215 -# @DESCRIPTION:
216 -# The executable name of the current GoLang interpreter.
217 -#
218 -# This variable is set automatically after calling golang_setup().
219 -#
220 -# Default value:
221 -# @CODE
222 -# go
223 -# @CODE
224 -
225 -# @ECLASS-VARIABLE: PATCHES
226 -# @DEFAULT_UNSET
227 -# @DESCRIPTION:
228 -# Array variable containing all the patches to be applied. This variable
229 -# is expected to be defined in the global scope of ebuilds. Make sure to
230 -# specify the full path. This variable is used in src_prepare phase.
231 -#
232 -# Example:
233 -# @CODE
234 -# PATCHES=(
235 -# "${FILESDIR}/mypatch.patch"
236 -# "${FILESDIR}/mypatch2.patch"
237 -# )
238 -# @CODE
239 -
240 -# Adds gccgo as a compile-time dependency when GOLANG_PKG_USE_CGO is set.
241 -#[[ -n ${GOLANG_PKG_USE_CGO} ]] && DEPEND+=" >=sys-devel/gcc-4.8.4[go]"
242 -
243 -# Adds dev-go/statik as a compile-time dependency when GOLANG_PKG_STATIK is set.
244 -[[ -n ${GOLANG_PKG_STATIK} ]] && DEPEND+=" dev-go/statik"
245 -
246 -# Validates GOLANG_PKG_IMPORTPATH.
247 -if [[ -z ${GOLANG_PKG_IMPORTPATH} ]]; then
248 - eerror "The remote import path for this package has not been declared"
249 - die "Mandatory variable GOLANG_PKG_IMPORTPATH is unset"
250 -fi
251 -
252 -# Forces a multiple package build when user specifies GOLANG_PKG_IS_MULTIPLE=1.
253 -if [[ -n ${GOLANG_PKG_IS_MULTIPLE} && -z ${GOLANG_PKG_BUILDPATH} ]]; then
254 - GOLANG_PKG_BUILDPATH="/..."
255 -fi
256 -
257 -# Validates use of GOLANG_PKG_BUILDPATH combined with GOLANG_PKG_IS_MULTIPLE
258 -# FIX: makes sure user isn't overriding GOLANG_PKG_BUILDPATH with inane values.
259 -if [[ -n ${GOLANG_PKG_IS_MULTIPLE} && ${GOLANG_PKG_BUILDPATH##*/} != "..." ]]; then
260 - ewarn "Ebuild ${CATEGORY}/${PF} specifies GOLANG_PKG_IS_MULTIPLE=1,"
261 - ewarn "but then GOLANG_PKG_BUILDPATH is overridden with \"${GOLANG_PKG_BUILDPATH}\"."
262 - ewarn "Please, fix it by appending \"/...\" to your GOLANG_PKG_BUILDPATH."
263 - ewarn "If in doubt, remove GOLANG_PKG_BUILDPATH entirely."
264 -fi
265 -
266 -# Even though xz-utils are in @system, they must still be added to DEPEND; see
267 -# http://archives.gentoo.org/gentoo-dev/msg_a0d4833eb314d1be5d5802a3b710e0a4.xml
268 -if [[ ${GOLANG_PKG_ARCHIVESUFFIX/.*} == "xz" ]]; then
269 - DEPEND+=" app-arch/xz-utils"
270 -fi
271 -
272 -# Defines common USE flags
273 -IUSE="${IUSE} debug pie"
274 -# Enables USE 'test' when required by GOLANG_PKG_HAVE_TEST.
275 -if [[ -n ${GOLANG_PKG_HAVE_TEST} ]]; then
276 - IUSE+=" test"
277 -fi
278 -
279 -# Defines HOMEPAGE.
280 -[ -z "$HOMEPAGE" ] && HOMEPAGE="https://${GOLANG_PKG_IMPORTPATH}/${PN}"
281 -
282 -# Defines SOURCE directory.
283 -S="${WORKDIR}/gopath/src/${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}"
284 -
285 -
286 -# @FUNCTION: _factorize_dependency_entities
287 -# @INTERNAL
288 -# @DESCRIPTION:
289 -# Factorizes the dependency declaration in specific tokens such as the import
290 -# path, the import path alias, the host name, the author name, the project name,
291 -# and the revision tag.
292 -_factorize_dependency_entities() {
293 - debug-print-function ${FUNCNAME} "${@}"
294 -
295 - local -A dependency=()
296 - local key_list=(importpathalias importpath host project_name author_name revision)
297 -
298 - # Strips all the white spaces from the supplied argument.
299 - local raw_dependency="${1//\ /}"
300 -
301 - # Determines the alias of the import path (if present).
302 - dependency[importpathalias]="${raw_dependency##*->}"
303 -
304 - # Strips the import path alias from the supplied argument.
305 - raw_dependency="${raw_dependency%%->*}"
306 -
307 - # Determines the import path.
308 - dependency[importpath]="${raw_dependency%:*}"
309 -
310 - # When the importpath alias is not specified, then this eclass sets the
311 - # alias as equal to the import path minus the project name.
312 - if [[ "${raw_dependency}" == "${dependency[importpathalias]}" ]]; then
313 - dependency[importpathalias]="${dependency[importpath]%/*}"
314 - fi
315 -
316 - # Determines the host.
317 - dependency[host]="${dependency[importpath]%%/*}"
318 -
319 - # Determines the project name.
320 - dependency[project_name]="${dependency[importpath]##*/}"
321 -
322 - # Determines the author name.
323 - dependency[author_name]="${dependency[importpath]#*/}"
324 - dependency[author_name]="${dependency[author_name]%/*}"
325 -
326 - # Determines the revision.
327 - dependency[revision]="${raw_dependency#*:}"
328 -
329 - # Exports all the dependency tokens as an associated list.
330 - for key in ${key_list[@]}; do
331 - echo "${key} ${dependency[${key}]}"
332 - done
333 -}
334 -
335 -# @FUNCTION: golang_setup
336 -# @DESCRIPTION:
337 -# Determines where is the GoLang implementation and then set-up the
338 -# GoLang build environment.
339 -golang_setup() {
340 - debug-print-function ${FUNCNAME} "${@}"
341 -
342 - # NOTE: Keep /usr/bin/go as index [0] and never overwrite it,
343 - # always append other binary paths after the index [0]
344 - local GOLANG_BINS=(
345 - /usr/bin/go
346 - /usr/bin/gofmt
347 - )
348 -
349 - [[ -n ${GOLANG_PKG_STATIK} ]] && GOLANG_BINS+=(/usr/bin/statik)
350 -
351 - # Reset GoLang environment variables
352 - unset EGO
353 - unset EGOFMT
354 - unset ESTATIK
355 - unset GO
356 - unset GOPATH
357 - unset GOBIN
358 -
359 - # Determine is the GoLang interpreter is working
360 - local IS_EXECUTABLE=1
361 - for binary in "${GOLANG_BINS[@]}"; do
362 - debug-print "${FUNCNAME}: Checking ... ${binary}"
363 -
364 - [[ -x "${EPREFIX}/${binary}" ]] && continue
365 - IS_EXECUTABLE=0
366 - ewarn "It seems that the binary '${binary}' is not executable."
367 - done
368 -
369 - # dev-lang/go isn't installed or one of its binaries aren't executable.
370 - # Either way, the Gentoo box is screwed; no need to set up the GoLang environment
371 - [[ ${IS_EXECUTABLE} == 0 ]] && exit
372 -
373 - # dev-lang/go is available and working.
374 - # Exports GO/EGO/EGOFMT global variables.
375 - export GO="${GOLANG_BINS[0]}"
376 - export EGO="${GOLANG_BINS[0]##*/}"
377 - export EGOFMT="${GOLANG_BINS[1]}"
378 -
379 - # dev-go/statik is available and working.
380 - # Exports ESTATIK global variable.
381 - [[ -n ${GOLANG_PKG_STATIK} ]] && export ESTATIK="${GOLANG_BINS[2]##*/}"
382 -
383 - debug-print "${FUNCNAME}: GO = ${GO}"
384 - debug-print "${FUNCNAME}: EGO = ${EGO}"
385 - debug-print "${FUNCNAME}: EGOFMT = ${EGOFMT}"
386 - debug-print "${FUNCNAME}: ESTATIK = ${ESTATIK}"
387 -
388 - # Determines go interpreter version.
389 - GOLANG_VERSION="$( ${GO} version )"
390 - GOLANG_VERSION="${GOLANG_VERSION/go\ version\ go}"
391 - export GOLANG_VERSION="${GOLANG_VERSION%\ *}"
392 - einfo "Found GoLang version: ${GOLANG_VERSION}"
393 -
394 - # Determines statik interpreter version.
395 - # TODO: add version detection when statik will provide a -version option.
396 - if [[ -n ${GOLANG_PKG_STATIK} ]]; then
397 - local STATIK_VERSION=""
398 - einfo "Found statik version: ${STATIK_VERSION}"
399 - fi
400 -
401 - # Enable/Disable frame pointers
402 - local GOEXPERIMENT="noframepointer"
403 - use debug && GOEXPERIMENT="framepointer"
404 -
405 - # Sets the build environment inside Portage's WORKDIR.
406 - ebegin "Setting up GoLang build environment"
407 -
408 - # Prepares CGO_ENABLED.
409 - CGO_ENABLED=0
410 - [[ -z ${GOLANG_PKG_USE_CGO} ]] || CGO_ENABLED=1
411 - use pie && CGO_ENABLED=1 # PIE requires CGO
412 -
413 - # Prepares gopath / gobin directories inside WORKDIR.
414 - local _GOPATH="${WORKDIR}/gopath"
415 - local _GOBIN="${WORKDIR}/gobin"
416 - mkdir -p "${_GOBIN}" || die
417 - mkdir -p "${_GOPATH}"/src || die
418 -
419 - # Exports special env variable EGO_SRC.
420 - export EGO_SRC="${_GOPATH}/src"
421 -
422 - # Exports GoLang env variables.
423 - export GOPATH="$_GOPATH"
424 - export GOBIN="$_GOBIN"
425 - export CGO_ENABLED
426 - #export GOEXPERIMENT
427 - #export GO15VENDOREXPERIMENT=0
428 -
429 - GO111MODULE="off"
430 - [[ -z ${GOLANG_PKG_USE_MODULES} ]] || GO111MODULE="on"
431 - export GO111MODULE
432 -
433 - debug-print "${FUNCNAME}: GOPATH = ${GOPATH}"
434 - debug-print "${FUNCNAME}: GOBIN = ${GOBIN}"
435 - debug-print "${FUNCNAME}: EGO_SRC = ${EGO_SRC}"
436 - debug-print "${FUNCNAME}: CGO_ENABLED = ${CGO_ENABLED}"
437 - eend
438 -}
439 -
440 -# @FUNCTION: golang-common_src_prepare
441 -# @DESCRIPTION:
442 -# Prepare source code.
443 -golang-common_src_prepare() {
444 - debug-print-function ${FUNCNAME} "${@}"
445 -
446 - pushd "${WORKDIR}" > /dev/null || die
447 - einfo "Preparing GoLang build environment in ${GOPATH}/src"
448 -
449 - # If the ebuild declares an importpath alias, then its path was
450 - # already created during the src_unpack phase. That means the eclass
451 - # needs to create the missing original import path (GOLANG_PKG_IMPORTPATH)
452 - # as a simbolic link pointing to the alias.
453 - if [[ "${GOLANG_PKG_IMPORTPATH}" != "${GOLANG_PKG_IMPORTPATH_ALIAS}" ]]; then
454 -
455 - # If the ebuild declares a GOLANG_PKG_NAME different from PN, then
456 - # the latter will be used as the simbolic link target.
457 - local TARGET="${GOLANG_PKG_NAME}"
458 - [[ "${PN}" != "${GOLANG_PKG_NAME}" ]] && TARGET="${PN}"
459 -
460 - golang_fix_importpath_alias \
461 - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${TARGET}" \
462 - "${GOLANG_PKG_IMPORTPATH}/${GOLANG_PKG_NAME}"
463 - fi
464 -
465 - # If the ebuild declares some GoLang dependencies, then they need to be
466 - # correctly installed into the sand-boxed GoLang build environment which
467 - # was set up automatically during src_unpack) phase.
468 - if [[ ${#GOLANG_PKG_DEPENDENCIES[@]} -gt 0 ]]; then
469 -
470 - for i in ${!GOLANG_PKG_DEPENDENCIES[@]} ; do
471 -
472 - # Collects all the tokens of the dependency.
473 - local -A DEPENDENCY=()
474 - while read -r -d $'\n' key value; do
475 - [[ -z ${key} ]] && continue
476 - DEPENDENCY[$key]="${value}"
477 - done <<-EOF
478 - $( _factorize_dependency_entities "${GOLANG_PKG_DEPENDENCIES[$i]}" )
479 - EOF
480 -
481 - # Debug
482 - debug-print "${FUNCNAME}: DEPENDENCY = ${GOLANG_PKG_DEPENDENCIES[$i]}"
483 - debug-print "${FUNCNAME}: importpath = ${DEPENDENCY[importpath]}"
484 - debug-print "${FUNCNAME}: importpathalias = ${DEPENDENCY[importpathalias]}"
485 - debug-print "${FUNCNAME}: host = ${DEPENDENCY[host]}"
486 - debug-print "${FUNCNAME}: author = ${DEPENDENCY[author_name]}"
487 - debug-print "${FUNCNAME}: project = ${DEPENDENCY[project_name]}"
488 - debug-print "${FUNCNAME}: revision = ${DEPENDENCY[revision]}"
489 -
490 - local message="Importing ${DEPENDENCY[importpath]}"
491 - local destdir
492 -
493 - # Prepares GOPATH structure.
494 - case ${DEPENDENCY[importpathalias]} in
495 - gopkg.in*)
496 - message+=" as ${DEPENDENCY[importpathalias]}"
497 - destdir="${DEPENDENCY[importpathalias]}"
498 -
499 - # Creates the import path in GOPATH.
500 - mkdir -p "${GOPATH}/src/${DEPENDENCY[importpathalias]%/*}" || die
501 - #einfo "\n${GOPATH}/src/${DEPENDENCY[importpathalias]%/*}"
502 - ;;
503 - *)
504 - [[ "${DEPENDENCY[importpath]}" != "${DEPENDENCY[importpathalias]}/${DEPENDENCY[project_name]}" ]] && message+=" as ${DEPENDENCY[importpathalias]}/${DEPENDENCY[project_name]}"
505 - destdir="${DEPENDENCY[importpathalias]}/${DEPENDENCY[project_name]}"
506 -
507 - # Creates the import path in GOPATH.
508 - mkdir -p "${GOPATH}/src/${DEPENDENCY[importpathalias]}" || die
509 - #einfo "\n${GOPATH}/src/${DEPENDENCY[importpathalias]}"
510 - ;;
511 - esac
512 -
513 - # Moves sources from WORKDIR into GOPATH.
514 - case ${DEPENDENCY[host]} in
515 - github*)
516 - ebegin "${message}"
517 - mv ${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}* "${GOPATH}"/src/${destdir} || die
518 - eend
519 -
520 - # FIX: sometimes the source code inside an importpath alias
521 - # (such as gopkg.in/mylib.v1) invokes imports from
522 - # the original import path instead of using the alias,
523 - # thus we need a symbolic link between the alias and
524 - # the original import path to avoid compilation issues.
525 - # Example: gopkg.in/Shopify/sarama.v1 erroneously
526 - # invokes imports from github.com/shopify/sarama
527 - if [[ ${destdir} != ${DEPENDENCY[importpath]} ]]; then
528 - golang_fix_importpath_alias ${destdir} ${DEPENDENCY[importpath]}
529 - fi
530 - ;;
531 - bitbucket*)
532 - #einfo "path: ${DEPENDENCY[author_name]}-${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}"
533 - ebegin "${message}"
534 - mv ${DEPENDENCY[author_name]}-${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}* "${GOPATH}"/src/${destdir} || die
535 - eend
536 - ;;
537 - code.google*)
538 - ebegin "${message}"
539 - mv ${DEPENDENCY[project_name]}-${DEPENDENCY[revision]}* "${GOPATH}"/src/${destdir} || die
540 - eend
541 - ;;
542 - *) die "Function 'golang-common_src_prepare' doesn't support '${DEPENDENCY[importpath]}'" ;;
543 - esac
544 - done
545 -
546 - fi
547 -
548 - popd > /dev/null || die
549 -
550 - # Auto-detects the presence of Go's vendored
551 - # dependencies inside $S/vendor.
552 - local VENDOR="${S}/vendor"
553 - if [[ -d "${VENDOR}" ]]; then
554 - golang_add_vendor "${VENDOR}"
555 - export GO15VENDOREXPERIMENT=1
556 - fi
557 -
558 - # Auto-detects the presence of Go's vendored
559 - # dependencies inside $S/*/vendor
560 - if [[ -n ${GOLANG_PKG_BUILDPATH} && ${GOLANG_PKG_BUILDPATH##*/} != "..." ]]; then
561 - while read -r -d $' ' path; do
562 - # Trims leading slash (if any).
563 - path="${path/\//}"
564 -
565 - # Extracts the root path.
566 - path="${path%%/*}"
567 -
568 - # Ignores $path when it's empty or a string of white spaces.
569 - [[ -n $path ]] || continue
570 -
571 - local vendor="${S}/${path}/vendor"
572 - if [[ -d "${vendor}" ]]; then
573 - golang_add_vendor "${vendor}"
574 - fi
575 - done <<< "$( echo ${GOLANG_PKG_BUILDPATH}) "
576 - fi
577 -
578 -
579 - # Auto-detects the presence of Godep's workspace
580 - # (see github.com/tools/godep for more infos).
581 - VENDOR="${S}/Godeps/_workspace"
582 - if [[ -d "${VENDOR}" ]]; then
583 - golang_add_vendor "${VENDOR}"
584 - fi
585 -
586 - # Evaluates PATCHES array.
587 - default_src_prepare
588 -}
589 -
590 -# @FUNCTION: golang-common_src_configure
591 -# @DESCRIPTION:
592 -# Configure the package.
593 -golang-common_src_configure() {
594 - debug-print-function ${FUNCNAME} "${@}"
595 -
596 - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)."
597 -
598 - # Defines the level of verbosity.
599 - local EGO_VERBOSE="-v"
600 - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x"
601 -
602 - # GoLang doesn't have a configure phase,
603 - # so instead this eclass prints the output of 'go env'.
604 - local -a GOLANG_ENV=()
605 - while read -r line; do
606 - GOLANG_ENV+=("${line}")
607 - done <<-EOF
608 - $( ${GO} env )
609 - EOF
610 -
611 - # Prints an error when 'go env' output is missing.
612 - if [[ ${#GOLANG_ENV[@]} -eq 1 ]]; then
613 - eerror "Your GoLang environment should be more verbose"
614 - fi
615 -
616 - # Prints GoLang environment summary.
617 - einfo " ${EGO} env"
618 - for env in "${GOLANG_ENV[@]}"; do
619 - einfo " - ${env}"
620 - done
621 -
622 -
623 - # Removes GoLang object files from package source directories (pkg/)
624 - # and temporary directories (_obj/ _test*/).
625 - local EGO_SUBPACKAGES="${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}"
626 - case $( ver_cut 1-2 ${GOLANG_VERSION} ) in
627 - 1.4*) ;;
628 - *)
629 - EGO_SUBPACKAGES+="/..."
630 - ;;
631 - esac
632 -# einfo "${EGO} clean -i ${EGO_VERBOSE} ${EGO_SUBPACKAGES}"
633 -# ${EGO} clean -i \
634 -# ${EGO_VERBOSE} \
635 -# "${EGO_SUBPACKAGES}" \
636 -# || die
637 -
638 - # Removes GoLang objects files from all the dependencies too.
639 -# if [[ ${#GOLANG_PKG_DEPENDENCIES[@]} -gt 0 ]]; then
640 -#
641 -# for i in ${!GOLANG_PKG_DEPENDENCIES[@]} ; do
642 -#
643 -# # Collects all the tokens of the dependency.
644 -# local -A DEPENDENCY=()
645 -# while read -r -d $'\n' key value; do
646 -# [[ -z ${key} ]] && continue
647 -# DEPENDENCY[$key]="${value}"
648 -# done <<-EOF
649 -# $( _factorize_dependency_entities "${GOLANG_PKG_DEPENDENCIES[$i]}" )
650 -# EOF
651 -#
652 -# [[ ! -d ${DEPENDENCY[importpath]} ]] && continue
653 -#
654 -# # Debug
655 -# debug-print "${FUNCNAME}: DEPENDENCY = ${GOLANG_PKG_DEPENDENCIES[$i]}"
656 -# debug-print "${FUNCNAME}: importpath = ${DEPENDENCY[importpath]}"
657 -#
658 -# # Cleans object files of the dependency.
659 -# einfo "${EGO} clean -i ${EGO_VERBOSE} ${DEPENDENCY[importpath]}"
660 -# ${EGO} clean \
661 -# -i ${EGO_VERBOSE} \
662 -# "${DEPENDENCY[importpath]}" \
663 -# || die
664 -# done
665 -# fi
666 -
667 - # Before to compile Godep's dependencies it's wise to wipe out
668 - # all pre-built object files from Godep's package source directories.
669 - if [[ -d "${S}"/Godeps/_workspace/pkg ]]; then
670 - ebegin "Cleaning up pre-built object files in Godep workspace"
671 - rm -r "${S}"/Godeps/_workspace/pkg || die
672 - eend
673 - fi
674 - if [[ -d "${S}"/Godeps/_workspace/bin ]]; then
675 - ebegin "Cleaning up executables in Godep workspace"
676 - rm -r "${S}"/Godeps/_workspace/bin || die
677 - eend
678 - fi
679 -
680 -
681 - # Executes 'go generate'.
682 - # NOTE: generate should never run automatically. It must be run explicitly.
683 - if [[ -n ${GOLANG_PKG_USE_GENERATE} ]]; then
684 - pushd "${GOPATH}/src/${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}" > /dev/null || die
685 - einfo "${EGO} generate ${EGO_VERBOSE} ${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}/..."
686 - ${EGO} generate \
687 - ${EGO_VERBOSE} \
688 - ./... \
689 - || die
690 - popd > /dev/null || die
691 - fi
692 -
693 -
694 - # Executes 'statik' when explicitly asked.
695 - if [[ -n ${GOLANG_PKG_STATIK} ]]; then
696 - ebegin "${ESTATIK} $GOLANG_PKG_STATIK"
697 - ${ESTATIK} $GOLANG_PKG_STATIK || die
698 - eend
699 - fi
700 -}
701 -
702 -# @FUNCTION: golang-common_src_compile
703 -# @DESCRIPTION:
704 -# Compiles the package.
705 -golang-common_src_compile() {
706 - debug-print-function ${FUNCNAME} "${@}"
707 -
708 - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)."
709 -
710 - # Populates env variable GOPATH with vendored workspaces (if present).
711 - if [[ -n ${GOLANG_PKG_VENDOR} ]]; then
712 - einfo "Using vendored dependencies from:"
713 -
714 - for path in "${GOLANG_PKG_VENDOR[@]}"; do
715 - [ -d ${path} ] || continue
716 -
717 - if [[ ${path//${S}\//} == "vendor" ]]; then
718 - einfo "- vendor/ (native vendoring support)"
719 - continue
720 - fi
721 -
722 - debug-print "$FUNCNAME: GOPATH: Adding vendor path ${path}"
723 - ebegin "- ${path//${S}\//}"
724 - GOPATH="${GOPATH}:$( echo ${path} )"
725 - eend
726 - done
727 -
728 - export GOPATH
729 - fi
730 -
731 - # Enables position-independent executables (PIE)
732 - local EGO_PIE
733 - use pie && EGO_PIE="-buildmode=pie"
734 -
735 - # Defines the install suffix.
736 - local EGO_INSTALLSUFFIX
737 - [[ -z ${GOLANG_PKG_INSTALLSUFFIX} ]] || EGO_INSTALLSUFFIX="-installsuffix=${GOLANG_PKG_INSTALLSUFFIX}"
738 -
739 - # Defines the level of verbosity.
740 - local EGO_VERBOSE="-v"
741 - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x"
742 -
743 - # Defines the number of builds that can be run in parallel.
744 - local EGO_PARALLEL="-p $(makeopts_jobs)"
745 -
746 - # Defines extra options.
747 - local EGO_EXTRA_OPTIONS="-a"
748 -
749 - # Prepares build flags for the go toolchain.
750 - local EGO_BUILD_FLAGS="$( echo ${EGO_VERBOSE} ) $( echo ${EGO_PARALLEL} ) $( echo ${EGO_EXTRA_OPTIONS} ) $( echo ${EGO_PIE} )"
751 - [[ -n ${EGO_INSTALLSUFFIX} ]] && EGO_BUILD_FLAGS+=" $( echo ${EGO_INSTALLSUFFIX} )"
752 -
753 - # Detects the total number of packages.
754 - local pkgs=0 ifs_save=${IFS} IFS=$' '
755 - for path in ${GOLANG_PKG_BUILDPATH[@]} ; do
756 - pkgs=$(( $pkgs + 1 ))
757 - done
758 - [[ ${pkgs} -eq 0 ]] && pkgs=1 # there is always at least 1 package
759 - IFS=${ifs_save}
760 -
761 - # Builds the package
762 - einfo "Compiling ${pkgs} package(s):"
763 - if [[ -n ${GOLANG_PKG_BUILDPATH} && ${GOLANG_PKG_BUILDPATH##*/} != "..." && ${pkgs} -gt 1 ]]; then
764 -
765 - # NOTE: This eclass trims all leading and trailing white spaces from the
766 - # input of the following 'while read' loop, then appends an extra
767 - # trailing space; this is necessary to avoid undefined behaviours
768 - # within the loop when GOLANG_PKG_BUILDPATH is populated with only
769 - # a single element.
770 - while read -r -d $' ' cmd; do
771 - # Ignores $cmd when it's empty or a string of white spaces
772 - #einfo "cmd: |$cmd| cmd: |${cmd##*/}|"
773 - [[ -n $cmd ]] || continue
774 -
775 - golang_do_build \
776 - ${EGO_BUILD_FLAGS} \
777 - -o "${GOBIN}/${cmd##*/}" \
778 - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${cmd}"
779 - done <<< "$( echo ${GOLANG_PKG_BUILDPATH}) "
780 - else
781 - # If the package is a multiple package (/...)
782 - # then this eclass doesn't specify the output name.
783 - [[ ${GOLANG_PKG_BUILDPATH##*/} != "..." ]] && EGO_BUILD_FLAGS+=" -o ${GOBIN}/${GOLANG_PKG_OUTPUT_NAME}"
784 -
785 - golang_do_build \
786 - ${EGO_BUILD_FLAGS} \
787 - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}"
788 - fi
789 -}
790 -
791 -# @FUNCTION: golang-common_src_install
792 -# @DESCRIPTION:
793 -# Installs binaries and documents from DOCS or HTML_DOCS arrays.
794 -golang-common_src_install() {
795 - debug-print-function ${FUNCNAME} "${@}"
796 -
797 - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)."
798 -
799 - # Enables position-independent executables (PIE)
800 - local EGO_PIE
801 - use pie && EGO_PIE="-buildmode=pie"
802 -
803 - # Defines the install suffix.
804 - local EGO_INSTALLSUFFIX
805 - [[ -z ${GOLANG_PKG_INSTALLSUFFIX} ]] || EGO_INSTALLSUFFIX="-installsuffix=${GOLANG_PKG_INSTALLSUFFIX}"
806 -
807 - # Defines the level of verbosity.
808 - local EGO_VERBOSE="-v"
809 - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x"
810 -
811 - # Defines the number of builds that can be run in parallel.
812 - local EGO_PARALLEL="-p $(makeopts_jobs)"
813 -
814 - # Defines extra options.
815 - local EGO_EXTRA_OPTIONS
816 -
817 - # Prepares build flags for the go toolchain.
818 - local EGO_BUILD_FLAGS="$( echo ${EGO_VERBOSE} ) $( echo ${EGO_PARALLEL} ) $( echo ${EGO_EXTRA_OPTIONS} ) $( echo ${EGO_PIE} )"
819 - [[ -n ${EGO_INSTALLSUFFIX} ]] && EGO_BUILD_FLAGS+=" $( echo ${EGO_INSTALLSUFFIX} )"
820 -
821 - # Defines sub-packages.
822 - local EGO_SUBPACKAGES="${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}"
823 -
824 - # Executes the pre-install phase (go install).
825 - if [[ -n ${GOLANG_PKG_IS_MULTIPLE} ]]; then
826 - einfo "${EGO} install -ldflags '$GOLANG_PKG_LDFLAGS' -tags '$GOLANG_PKG_TAGS' ${EGO_BUILD_FLAGS} ${EGO_SUBPACKAGES}"
827 - ${EGO} install \
828 - -ldflags "${GOLANG_PKG_LDFLAGS}" \
829 - -tags "${GOLANG_PKG_TAGS}" \
830 - ${EGO_BUILD_FLAGS} \
831 - "${EGO_SUBPACKAGES}" \
832 - || die
833 - fi
834 -
835 - # Installs binaries.
836 - into ${GOLANG_PKG_INSTALLPATH}
837 - for bin in "${GOBIN}"/* ; do
838 - dobin ${bin}
839 - done
840 -
841 - # Installs documentation.
842 - einstalldocs
843 -}
844 -
845 -# @FUNCTION: golang-common_src_test
846 -# @DESCRIPTION:
847 -# Runs the unit tests for the main package.
848 -golang-common_src_test() {
849 - debug-print-function ${FUNCNAME} "${@}"
850 -
851 - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)."
852 -
853 - # Appends S and GOBIN to exported main paths.
854 - # FIX: this is necessary for unit tests that need to invoke bins from
855 - # $GOBIN or from within $S/bin.
856 - export PATH="${S}/bin:${GOBIN}:${PATH}"
857 -
858 - # Defines the level of verbosity.
859 - local EGO_VERBOSE="-v"
860 - [[ -z ${PORTAGE_VERBOSE} ]] || EGO_VERBOSE+=" -x"
861 -
862 - # Defines the number of builds that can be run in parallel.
863 - local EGO_PARALLEL="-p $(makeopts_jobs)"
864 -
865 - # Defines extra options.
866 - #local EGO_EXTRA_OPTIONS="-a"
867 -
868 - # Enables data race detection.
869 - local EGO_RACE
870 - [[ -n ${GOLANG_PKG_HAVE_TEST_RACE} ]] && EGO_RACE=" -race"
871 -
872 - # Prepares build flags for the go toolchain.
873 - local EGO_BUILD_FLAGS="$( echo ${EGO_VERBOSE} ) $( echo ${EGO_PARALLEL} ) $( echo ${EGO_EXTRA_OPTIONS} )"
874 - [[ -n ${EGO_RACE} ]] && EGO_BUILD_FLAGS+=" $( echo ${EGO_RACE} )"
875 -
876 - # Sanitizes vars from entra white spaces.
877 - GOLANG_PKG_LDFLAGS="$( echo ${GOLANG_PKG_LDFLAGS} )"
878 - GOLANG_PKG_TAGS="$( echo ${GOLANG_PKG_TAGS} )"
879 -
880 - # Defines sub-packages.
881 - local EGO_SUBPACKAGES="${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}"
882 - [[ -z ${GOLANG_PKG_IS_MULTIPLE} ]] || EGO_SUBPACKAGES="./..."
883 -
884 - # Detects the total number of packages.
885 - local pkgs=0 ifs_save=${IFS} IFS=$' '
886 - for path in ${GOLANG_PKG_BUILDPATH[@]} ; do
887 - pkgs=$(( $pkgs + 1 ))
888 - done
889 - [[ ${pkgs} -eq 0 ]] && pkgs=1 # there is always at least 1 package
890 - IFS=${ifs_save}
891 -
892 - # Runs the Unit Tests
893 - einfo "Testing ${pkgs} package(s):"
894 - if [[ -n ${GOLANG_PKG_BUILDPATH} && ${GOLANG_PKG_BUILDPATH##*/} != "..." && ${pkgs} -gt 1 ]]; then
895 -
896 - # NOTE: This eclass trims all leading and trailing white spaces from the
897 - # input of the following 'while read' loop, then appends an extra
898 - # trailing space; this is necessary to avoid undefined behaviours
899 - # within the loop when GOLANG_PKG_BUILDPATH is populated with only
900 - # a single element.
901 - while read -r -d $' ' cmd; do
902 - # Ignores $cmd when it's empty or a string of white spaces
903 - #einfo "cmd: |$cmd| cmd: |${cmd##*/}|"
904 - [[ -n $cmd ]] || continue
905 -
906 - einfo "${EGO} test -ldflags '$GOLANG_PKG_LDFLAGS' -tags '$GOLANG_PKG_TAGS' ${EGO_BUILD_FLAGS} ${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${cmd}/..."
907 - ${EGO} test \
908 - -ldflags "${GOLANG_PKG_LDFLAGS}" \
909 - -tags "${GOLANG_PKG_TAGS}" \
910 - ${EGO_BUILD_FLAGS} \
911 - "${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${cmd}/..." \
912 - || die
913 - done <<< "$( echo ${GOLANG_PKG_BUILDPATH}) "
914 - else
915 - # It's a single package
916 - einfo "${EGO} test -ldflags '$GOLANG_PKG_LDFLAGS' -tags '$GOLANG_PKG_TAGS' ${EGO_BUILD_FLAGS} ${EGO_SUBPACKAGES}"
917 - ${EGO} test \
918 - -ldflags "${GOLANG_PKG_LDFLAGS}" \
919 - -tags "${GOLANG_PKG_TAGS}" \
920 - ${EGO_BUILD_FLAGS} \
921 - "${EGO_SUBPACKAGES}" \
922 - || die
923 - fi
924 -}
925 -
926 -# @FUNCTION: golang_do_build
927 -# @INTERNAL
928 -# @USAGE: <flags> <buildpath>
929 -# @DESCRIPTION:
930 -#
931 -# @CODE
932 -# Example:
933 -# GOLANG_PKG_LDFLAGS="-extldflags=-static"
934 -# GOLANG_PKG_TAGS="netgo"
935 -#
936 -# golang_do_build ${EGO_BUILD_FLAGS} ${GOLANG_PKG_IMPORTPATH}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}
937 -# @CODE
938 -golang_do_build() {
939 - debug-print-function ${FUNCNAME} $*
940 -
941 - [[ ${GOLANG_VERSION} ]] || die "No GoLang implementation set (golang_setup not called?)."
942 -
943 - # Filters "=" chars from ldflags declaration.
944 - # NOTE: from go1.5+ linker syntax is no more compatible with <go1.4;
945 - # this hack ensures that the old behaviour is honoured.
946 - if [[ $( ver_cut 1-2 ${GOLANG_VERSION} ) == "1.4" ]]; then
947 - GOLANG_PKG_LDFLAGS="${GOLANG_PKG_LDFLAGS//=/ }"
948 - fi
949 -
950 - # Disables debug symbols (DWARF) when not required.
951 - if ! use debug; then
952 - case "${GOLANG_PKG_LDFLAGS}" in
953 - *-s*|*-w*)
954 - # Do nothing
955 - ;;
956 - *)
957 - GOLANG_PKG_LDFLAGS+=" -s -w"
958 - esac
959 - fi
960 -
961 - # Sanitizes vars from entra white spaces.
962 - GOLANG_PKG_LDFLAGS="$( echo ${GOLANG_PKG_LDFLAGS} )"
963 - GOLANG_PKG_TAGS="$( echo ${GOLANG_PKG_TAGS} )"
964 -
965 - einfo "${EGO} build -ldflags '$GOLANG_PKG_LDFLAGS' -tags '$GOLANG_PKG_TAGS' $*"
966 - ${EGO} build \
967 - -ldflags "${GOLANG_PKG_LDFLAGS}" \
968 - -tags "${GOLANG_PKG_TAGS}" \
969 - $( echo $* ) \
970 - || die
971 -}
972 -
973 -# @FUNCTION: golang_add_vendor
974 -# @INTERNAL
975 -# @USAGE: <path>
976 -# @DESCRIPTION:
977 -#
978 -# @CODE
979 -# Example
980 -#
981 -# golang_add_vendor "${S}"/vendor
982 -# golang_add_vendor "${S}"/${PN}/vendor
983 -# @CODE
984 -golang_add_vendor() {
985 - debug-print-function ${FUNCNAME} $*
986 -
987 - [[ ${1} ]] || die "${FUNCNAME}: no paths given"
988 -
989 - [[ ${GOLANG_VERSION} ]] || die "No Golang implementation set (golang_setup not called?)."
990 -
991 - [[ ! -d "${1}" ]] && return
992 -
993 - # NOTE: this hack is required by Go v1.4 and older versions.
994 - #if [[ ! -d "${1}"/src ]]; then
995 - # ebegin "Fixing $1"
996 - # ln -s "${1}" "${1}"/src || die
997 - # eend
998 - #fi
999 -
1000 - GOLANG_PKG_VENDOR+=(${1})
1001 -}
1002 -
1003 -
1004 -# @FUNCTION: golang_fix_importpath_alias
1005 -# @USAGE: <target> <alias>
1006 -# @DESCRIPTION:
1007 -# Helper functions for generating a symbolic link for import path <target> as
1008 -# <alias>.
1009 -#
1010 -# WARNING: Use this function only if GOLANG_PKG_DEPENDENCIES declaration of
1011 -# import path aliases doesn't work (e.g.: the package name differs from both the
1012 -# import path and the alias, or if the package name is case sensitive but the
1013 -# import path is not).
1014 -#
1015 -# @CODE
1016 -# Example:
1017 -#
1018 -# src_prepare() {
1019 -# golang-single_src_prepare
1020 -#
1021 -# golang_fix_importpath_alias \
1022 -# "github.com/GoogleCloudPlatform/gcloud-golang" \
1023 -# "google.golang.org/cloud"
1024 -# }
1025 -# @CODE
1026 -golang_fix_importpath_alias() {
1027 - debug-print-function ${FUNCNAME} "${@}"
1028 -
1029 - [[ ${1} ]] || die "${FUNCNAME}: no target specified"
1030 - [[ ${2} ]] || die "${FUNCNAME}: no alias specified"
1031 -
1032 - [[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)."
1033 -
1034 -
1035 - local TARGET="${1}"
1036 - local ALIAS="${2}"
1037 -
1038 - if [[ ${ALIAS%/*} != ${ALIAS} ]]; then
1039 - mkdir -p "${GOPATH}/src/${ALIAS%/*}" || die
1040 - fi
1041 - ebegin "Linking ${TARGET} as ${ALIAS}"
1042 - ln -s "${GOPATH}/src/${TARGET}" \
1043 - "${GOPATH}/src/${ALIAS}" \
1044 - || die
1045 - eend
1046 -}
1047 -
1048 -fi
1049
1050 diff --git a/eclass/golang-single.eclass b/eclass/golang-single.eclass
1051 deleted file mode 100644
1052 index 692918bd9..000000000
1053 --- a/eclass/golang-single.eclass
1054 +++ /dev/null
1055 @@ -1,180 +0,0 @@
1056 -# Copyright 1999-2021 Gentoo Authors
1057 -# Distributed under the terms of the GNU General Public License v2
1058 -
1059 -# @ECLASS: golang-single.eclass
1060 -# @MAINTAINER:
1061 -#
1062 -# @AUTHOR:
1063 -# Mauro Toffanin <toffanin.mauro@×××××.com>
1064 -# @BLURB: An eclass for GoLang packages not installed inside GOPATH/GOBIN.
1065 -# @DESCRIPTION:
1066 -# This eclass allows to install arbitrary packages written in GoLang which
1067 -# don't support being installed inside the Go environment.
1068 -# This mostly includes traditional packages (C/C++/GUI) embedding tools written
1069 -# in GoLang, and GoLang packages that need to be compiled with GCC instead of
1070 -# the standard Go interpreter.
1071 -#
1072 -# @EXAMPLE:
1073 -# Typical ebuild using golang-single.eclass:
1074 -#
1075 -# @CODE
1076 -# EAPI=5
1077 -#
1078 -# GOLANG_PKG_IMPORTPATH="github.com/captObvious"
1079 -# GOLANG_PKG_ARCHIVESUFFIX=".zip"
1080 -# GOLANG_PKG_HAVE_TEST
1081 -# inherit golang-single qt4-r2
1082 -#
1083 -# DESCRIPTION="Foo bar application"
1084 -# HOMEPAGE="http://example.org/foo/"
1085 -#
1086 -# LICENSE="MIT"
1087 -# KEYWORDS="~amd64 ~x86"
1088 -# SLOT="0"
1089 -# IUSE="doc qt4"
1090 -#
1091 -# CDEPEND="
1092 -# qt4? (
1093 -# dev-qt/qtcore:4
1094 -# dev-qt/qtgui:4
1095 -# )"
1096 -# RDEPEND="${CDEPEND}
1097 -# !media-gfx/bar"
1098 -# DEPEND="${CDEPEND}
1099 -# doc? ( app-doc/doxygen )"
1100 -#
1101 -# DOCS=(AUTHORS ChangeLog README "Read me.txt" TODO)
1102 -#
1103 -# PATCHES=(
1104 -# "${FILESDIR}/${P}-qt4.patch" # bug 123458
1105 -# "${FILESDIR}/${P}-as-needed.patch"
1106 -# )
1107 -#
1108 -# src_install() {
1109 -# use doc && HTML_DOCS=("${BUILD_DIR}/apidocs/html/")
1110 -# autotools-utils_src_install
1111 -# if use examples; then
1112 -# dobin "${BUILD_DIR}"/foo_example{1,2,3} \\
1113 -# || die 'dobin examples failed'
1114 -# fi
1115 -# }
1116 -#
1117 -# @CODE
1118 -
1119 -inherit golang-common
1120 -
1121 -EXPORT_FUNCTIONS src_prepare src_unpack src_configure src_compile src_install src_test
1122 -
1123 -if [[ -z ${_GOLANG_SINGLE_ECLASS} ]]; then
1124 -_GOLANG_SINGLE_ECLASS=1
1125 -
1126 -# This eclass uses GOLANG_PKG_IMPORTPATH to populate SRC_URI.
1127 -SRC_URI="${SRC_URI:="https://${GOLANG_PKG_IMPORTPATH}/${GOLANG_PKG_NAME}/archive/${GOLANG_PKG_ARCHIVEPREFIX}${GOLANG_PKG_VERSION}${GOLANG_PKG_ARCHIVESUFFIX} -> ${P}${GOLANG_PKG_ARCHIVESUFFIX}"}"
1128 -
1129 -# This eclass uses GOLANG_PKG_DEPENDENCIES associative array to populate SRC_URI
1130 -# with the required snapshots of the supplied GoLang dependencies.
1131 -if [[ ${#GOLANG_PKG_DEPENDENCIES[@]} -gt 0 ]]; then
1132 -
1133 - for i in ${!GOLANG_PKG_DEPENDENCIES[@]} ; do
1134 -
1135 - # Collects all the tokens of the dependency.
1136 - local -A DEPENDENCY=()
1137 - while read -d $'\n' key value; do
1138 - [[ -z ${key} ]] && continue
1139 - DEPENDENCY[$key]="${value}"
1140 - done <<-EOF
1141 - $( _factorize_dependency_entities "${GOLANG_PKG_DEPENDENCIES[$i]}" )
1142 - EOF
1143 -
1144 - # Debug
1145 - debug-print "${FUNCNAME}: DEPENDENCY = ${GOLANG_PKG_DEPENDENCIES[$i]}"
1146 - debug-print "${FUNCNAME}: importpath = ${DEPENDENCY[importpath]}"
1147 - debug-print "${FUNCNAME}: revision = ${DEPENDENCY[revision]}"
1148 -
1149 - # Downloads the archive.
1150 - case ${DEPENDENCY[importpath]} in
1151 - github*)
1152 - SRC_URI+=" https://${DEPENDENCY[importpath]}/archive/${DEPENDENCY[revision]}${GOLANG_PKG_ARCHIVESUFFIX} -> ${DEPENDENCY[importpath]//\//-}-${DEPENDENCY[revision]}${GOLANG_PKG_ARCHIVESUFFIX}"
1153 - ;;
1154 - bitbucket*)
1155 - SRC_URI+=" https://${DEPENDENCY[importpath]}/get/${DEPENDENCY[revision]}.zip -> ${DEPENDENCY[importpath]//\//-}-${DEPENDENCY[revision]}.zip"
1156 - ;;
1157 - code.google*)
1158 - SRC_URI+=" https://${DEPENDENCY[project_name]}.googlecode.com/archive/${DEPENDENCY[revision]}.tar.gz -> ${DEPENDENCY[importpath]//\//-}-${DEPENDENCY[revision]}.tar.gz"
1159 - ;;
1160 - *) die "This eclass doesn't support '${DEPENDENCY[importpath]}'" ;;
1161 - esac
1162 -
1163 - done
1164 -fi
1165 -
1166 -# @FUNCTION: golang-single_src_unpack
1167 -# @DESCRIPTION:
1168 -# Unpack the source archive.
1169 -golang-single_src_unpack() {
1170 - debug-print-function ${FUNCNAME} "${@}"
1171 -
1172 - default
1173 -
1174 - # Creates S.
1175 - mkdir -p "${S%/*}" || die
1176 -
1177 - # Moves main GoLang package from WORKDIR into GOPATH.
1178 - if [[ "${GOLANG_PKG_IMPORTPATH}" != "${GOLANG_PKG_IMPORTPATH_ALIAS}" ]]; then
1179 - local alias_abspath="${WORKDIR}/gopath/src/${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}"
1180 - mkdir -p "${alias_abspath%/*}" || die
1181 - mv "${GOLANG_PKG_NAME}-${GOLANG_PKG_VERSION}" "${alias_abspath}"/ || die
1182 - else
1183 - mv "${GOLANG_PKG_NAME}-${GOLANG_PKG_VERSION}" "${S}"/ || die
1184 - fi
1185 -}
1186 -
1187 -# @FUNCTION: golang-single_src_prepare
1188 -# @DESCRIPTION:
1189 -# Prepare source code.
1190 -golang-single_src_prepare() {
1191 - debug-print-function ${FUNCNAME} "$@"
1192 -
1193 - # Sets up GoLang build environment.
1194 - golang_setup
1195 -
1196 - golang-common_src_prepare
1197 -}
1198 -
1199 -# @FUNCTION: golang-single_src_configure
1200 -# @DESCRIPTION:
1201 -# Configure the package.
1202 -golang-single_src_configure() {
1203 - debug-print-function ${FUNCNAME} "$@"
1204 -
1205 - golang-common_src_configure
1206 -}
1207 -
1208 -# @FUNCTION: golang-single_src_compile
1209 -# @DESCRIPTION:
1210 -# Compiles the package.
1211 -golang-single_src_compile() {
1212 - debug-print-function ${FUNCNAME} "$@"
1213 -
1214 - golang-common_src_compile
1215 -}
1216 -
1217 -# @FUNCTION: golang-single_src_install
1218 -# @DESCRIPTION:
1219 -# Installs binaries and documents from DOCS or HTML_DOCS arrays.
1220 -golang-single_src_install() {
1221 - debug-print-function ${FUNCNAME} "$@"
1222 -
1223 - golang-common_src_install
1224 -}
1225 -
1226 -# @FUNCTION: golang-single_src_test
1227 -# @DESCRIPTION:
1228 -# Runs the unit tests for the main package.
1229 -golang-single_src_test() {
1230 - debug-print-function ${FUNCNAME} "$@"
1231 -
1232 - golang-common_src_test
1233 -}
1234 -
1235 -fi