aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/all.go
blob: 4213a077d1a5b9b1b1b2a0b98f8b30ab7ba76f9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package rosa

import (
	"sync"

	"hakurei.app/internal/pkg"
)

// PArtifact is a lazily-initialised [pkg.Artifact] preset.
type PArtifact int

const (
	ACL PArtifact = iota
	Attr
	Autoconf
	Bash
	Busybox
	CMake
	Coreutils
	Diffutils
	Gettext
	Git
	Go
	Gperf
	Hakurei
	KernelHeaders
	LibXau
	Libexpat
	Libffi
	Libgd
	Libseccomp
	Libxml2
	M4
	Make
	Meson
	Ninja
	Patch
	Perl
	PkgConfig
	Python
	Rsync
	Setuptools
	Wayland
	WaylandProtocols
	XCB
	XCBProto
	Xproto
	Zlib

	// _presetEnd is the total number of presets and does not denote a preset.
	_presetEnd
)

var (
	// artifactsF is an array of functions for the result of [PArtifact].
	artifactsF [_presetEnd]func(t Toolchain) pkg.Artifact

	// artifacts stores the result of artifactsF.
	artifacts [_toolchainEnd][len(artifactsF)]pkg.Artifact
	// artifactsOnce is for lazy initialisation of artifacts.
	artifactsOnce [_toolchainEnd][len(artifactsF)]sync.Once
)

// Load returns the resulting [pkg.Artifact] of [PArtifact].
func (t Toolchain) Load(p PArtifact) pkg.Artifact {
	artifactsOnce[t][p].Do(func() {
		artifacts[t][p] = artifactsF[p](t)
	})
	return artifacts[t][p]
}