Module-based builds are the default way to build software in Go as of Go
1.16. go-package.mk implements the older GOPATH-based build type, which
will go away in one of the next Go releases (probably in early 2022).
We don't currently build any packages using modules, and the switch to
newer versions of Go has resulted in the default changing to modules
being sometimes enabled.
This now causes random packages to begin fetching from the Internet during
builds, which goes against pkgsrc policy.
Doesn't seem to harm the ability to build a random subset of the Go packages
in pkgsrc.
This supports packages that require a large number of go-based dependencies,
treating them as additional distfiles and built inline as part of the package
build. The print-go-deps target is helpful to generate the list of GO_DEPS
required for each package by parsing the Gopkg.lock file in the extracted
sources.
Thanks to rillig@ for various suggestions and comments.
Up to now, there was a central list of variable name patterns that
defined whether a variable was printed as a sorted list, as a list or as
a single value.
Now each variable group decides on its own which of the variables are
printed in which way, using the usual glob patterns. This is more
flexible since different files sometimes differ in their naming
conventions.
Two variable groups are added: license (for everything related to
LICENSE) and go (for lang/go).
- Move GO_PLATFORM definition in lang/go/version.mk in order that also lang/go*
packages can (re)use it
- Change PRINT_PLIST_AWK pattern that replace all ${GO_PLATFORM} and apply it
only when ${GO_PLATFORM} is a directory (between two "/"). There are only
3 exceptions to that in lang/go14.
Move it to version.mk so lang/go* PLIST can be mostly automatically
generated.
These changes should help to avoid (most) manual editing of
lang/go*/PLIST.
Discussed with and thanks to <bsiegert>!
This moves builds of packages using Go off the unversioned lang/go package
and onto Go 1.11 or Go 1.9 (on NetBSD 6) by default.
There is a new, user-settable variable GO_VERSION_DEFAULT.
NOTE: not all Go packages completely implement this yet. For example,
net/syncthing does its own thing. This will be fixed.
Go packages create ${PREFIX}/bin and ${PREFIX}/gopkg even when they
don't install anything in them. This change sets PRINT_PLIST_AWK to
ignore such empty directories.
Previously GOCACHE was not passed as environment variable and hence
during the build of packages the cache was stored in `${GO} env
GOCACHE' (${XDG_CACHE_HOME} if defined or ${HOME}/.cache).
Pass GOCACHE so that all cached file will ends up under ${WRKDIR}.
While here also pass both GOPATH and GOCACHE via MAKE_ENV.
Thanks to Antonio Huete Jimenez for spotting this problem!
Discussed and ok by <bsiegert>, thanks!
Otherwise, you will not be able to build Go code in pkgsrc if you do not
have pkg_alternatives installed.
Introduce a variable (user-settable for now) GOVERSSUFFIX.
$GO is now the Go tool with full path.
leot@ convinced me to go full Python (e.g. one directory per major version,
GO_VERSION_ACCEPTED etc.) but that will be another series of commits.
Previously all lines (matching or not /${GO_PLATFORM}/) were printed
unconditionally and could interfere with other PRINT_PLIST_AWKs used by always
printing every line in `print-PLIST' phase.
Avoid that by limiting the pattern of PRINT_PLIST_AWK in go-package.mk.
Prevented the error message "*** Error 1 (ignored) ***" during installation
by using || instead of &&.
Shell commands are hidden during normal operation.
Go packages can be tested using "bmake test".
ok @bsiegert
Go packages now define a set of files to buildlink in their buildlink3.mk.
go-packages.mk no longer looks in ${PREFIX}/gopkg during the build. This
should also fix the spurious issues with rebuilds of .a files during bulk
builds of Go packages.