1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-13 03:19:47 +03:00

pmb.config: mount go caching directories

Always set GOCACHE during build and let it point to pmbootstrap's work
dir. This has a similar effect as using ccache for C/C++.

Set GOMODCACHE conditionally: this is for caching the go modules (git
repositories) that get cloned during a build if they are not bundled
with the source. Usually APKBUILDs should cache them, but when using
pmbootstrap build --src, they would get downloaded over and over again.
Set GOMODCACHE automatically for --src and allow enabling/disabling this
manually with new --go-mod-cache / --no-go-mod-cache.

This speeds up multiple iterations of building the same package
significantly. I'm using it for:

$ pmbootstrap build postmarketos-mkinitfs --src=...

I've verified that using the same GOCACHE dir for multiple architectures
doesn't result in build artifacts for the wrong arch getting used.

Reviewed-by: Clayton Craft <clayton@craftyguy.net>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230223064743.1773-1-ollieparanoid@postmarketos.org%3E
This commit is contained in:
Oliver Smith 2023-02-23 07:47:43 +01:00
parent 3ad159f98d
commit a0cea6255a
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 41 additions and 1 deletions

View file

@ -855,6 +855,18 @@ def arguments():
build.add_argument("-n", "--no-depends", action="store_true",
help="never build dependencies, abort instead",
dest="no_depends")
build.add_argument("--go-mod-cache", action="store_true", default=None,
help="for go packages: Usually they should bundle the"
" dependency sources instead of downloading them"
" at build time. But if they don't (e.g. with"
" pmbootstrap build --src), then this option can"
" be used to let GOMODCACHE point into"
" pmbootstrap's work dir to only download"
" dependencies once. (default: true with --src,"
" false otherwise)")
build.add_argument("--no-go-mod-cache",
action="store_false", dest="go_mod_cache", default=None,
help="don't set GOMODCACHE")
build.add_argument("--envkernel", action="store_true",
help="Create an apk package from the build output of"
" a kernel compiled locally on the host or with envkernel.sh.")
@ -909,4 +921,9 @@ def arguments():
setattr(args, "from_argparse", copy.deepcopy(args))
setattr(args.from_argparse, "from_argparse", args.from_argparse)
pmb.helpers.args.init(args)
if getattr(args, "go_mod_cache", None) is None:
gomodcache = True if getattr(args, "src", None) else False
setattr(args, "go_mod_cache", gomodcache)
return args