internal/rosa: key metadata by string

For upcoming azalea integration. The API is quite ugly right now to ease migration.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-17 13:07:12 +09:00
parent c2ff9c9fa5
commit 30eb0d6a61
95 changed files with 1514 additions and 1567 deletions

View File

@@ -7,12 +7,12 @@ import (
"hakurei.app/internal/pkg"
)
func (t Toolchain) newPython() (pkg.Artifact, string) {
func (t Toolchain) newPython(s *S) (pkg.Artifact, string) {
const (
version = "3.14.5"
checksum = "zYIpDlk2ftZ-UVGCQS1rthle2OHoyXV653ztWiopKV1NhmIJf1K2hHbkwM4DozQ9"
)
return t.NewPackage("python", version, newTar(
return s.NewPackage(t, "python", version, newTar(
"https://www.python.org/ftp/python/"+version+
"/Python-"+version+".tgz",
checksum,
@@ -73,7 +73,7 @@ index 19aea290b58..51603ba9510 100644
// _ctypes appears to infer something from the linker name
"LDFLAGS=-Wl,--dynamic-linker=/system/lib/" +
"ld-musl-" + linuxArch() + ".so.1",
"ld-musl-" + s.linuxArch() + ".so.1",
},
}, &MakeHelper{
Check: []string{"test"},
@@ -88,7 +88,7 @@ index 19aea290b58..51603ba9510 100644
), version
}
func init() {
artifactsM[Python] = Metadata{
native.MustRegister(&Artifact{
f: Toolchain.newPython,
Name: "python",
@@ -103,7 +103,7 @@ func init() {
},
ID: 13254,
}
})
}
// PipHelper is the [Python] pip packaging helper.
@@ -150,7 +150,7 @@ func (*PipHelper) createDir() bool { return false }
func (*PipHelper) wantsDir() string { return `"$(mktemp -d)"` }
// script generates the pip3 install command.
func (attr *PipHelper) script(name string) string {
func (attr *PipHelper) script(_ *S, name string) string {
if attr == nil {
attr = new(PipHelper)
}
@@ -193,16 +193,16 @@ pip3 install \
` + script
}
// newPythonPackage creates [Metadata] for a [Python] package.
func newPythonPackage(
// newPythonPackage registers a new [Python] package.
func (s *S) newPythonPackage(
name string, id int, description, website, version string,
source pkg.Artifact, attrP *PackageAttr, attr *PipHelper,
build P, extra ...PArtifact,
) Metadata {
build P, extra ...ArtifactH,
) {
name = "python-" + name
return Metadata{
f: func(t Toolchain) (pkg.Artifact, string) {
return t.NewPackage(name, version, source, attrP, attr, slices.Concat(
s.MustRegister(&Artifact{
f: func(t Toolchain, s *S) (pkg.Artifact, string) {
return s.NewPackage(t, name, version, source, attrP, attr, slices.Concat(
P{Python},
extra,
build,
@@ -216,7 +216,7 @@ func newPythonPackage(
Dependencies: slices.Concat(P{Python}, extra),
ID: id,
}
})
}
func init() {
@@ -224,7 +224,7 @@ func init() {
version = "0.47.0"
checksum = "HZ-MvkUP8mbbx2YmsRNswj_bbOCIiXckuHqL5Qbvb5NxN5DYfWnqwkGNyS7OrId0"
)
artifactsM[PythonWheel] = newPythonPackage(
native.newPythonPackage(
"wheel", 11428,
"the official binary distribution format for Python",
"https://peps.python.org/pep-0427/",
@@ -242,7 +242,7 @@ func init() {
version = "82.0.1"
checksum = "nznP46Tj539yqswtOrIM4nQgwLA1h-ApKX7z7ghazROCpyF5swtQGwsZoI93wkhc"
)
artifactsM[PythonSetuptools] = newPythonPackage(
native.newPythonPackage(
"setuptools", 4021,
"the autotools of the Python ecosystem",
"https://pypi.org/project/setuptools/",
@@ -262,7 +262,7 @@ func init() {
version = "1.1.1"
checksum = "rXZixTsZcRcIoUC1LvWrjySsiXSv5uhW6ng2P-yXZrbdj7FrSrDeJLCfC2b-ladV"
)
artifactsM[PythonVCSVersioning] = newPythonPackage(
native.newPythonPackage(
"vcs-versioning", 389421,
"core VCS versioning functionality extracted as a standalone library",
"https://setuptools-scm.readthedocs.io/en/latest/",
@@ -289,7 +289,7 @@ func init() {
version = "10.0.5"
checksum = "vTN_TPd-b4Wbsw5WmAcsWjrs-FNXXznOeVTDnb54NtXve9Oy-eb2HPy-RG3FzNqp"
)
artifactsM[PythonSetuptoolsSCM] = newPythonPackage(
native.newPythonPackage(
"setuptools-scm", 7874,
"extracts Python package versions from Git or Mercurial metadata",
"https://setuptools-scm.readthedocs.io/en/latest/",
@@ -316,7 +316,7 @@ func init() {
version = "3.12.0"
checksum = "VcTsiGiDU1aPLbjSPe38f9OjJDCLcxFz9loObJqUI1ZxDHXAaQMxBpNyLz_G1Rff"
)
artifactsM[PythonFlitCore] = newPythonPackage(
native.newPythonPackage(
"flit-core", 44841,
"a PEP 517 build backend for packages using Flit",
"https://flit.pypa.io/",
@@ -337,7 +337,7 @@ func init() {
version = "26.2"
checksum = "rdpGa2EkPFbj1mFtLKLnSwIX9gPfELcuneiICjRVDNw6By49szTFVoW8gtMMZ6ZS"
)
artifactsM[PythonPackaging] = newPythonPackage(
native.newPythonPackage(
"packaging", 60461,
"reusable core utilities for various Python Packaging interoperability specifications",
"https://packaging.pypa.io/",
@@ -352,10 +352,10 @@ func init() {
}
func init() {
artifactsM[LIT] = Metadata{
f: func(t Toolchain) (pkg.Artifact, string) {
version := t.Version(LLVM)
return t.NewPackage("lit", version, t.Load(llvmSource), nil, &PipHelper{
native.MustRegister(&Artifact{
f: func(t Toolchain, s *S) (pkg.Artifact, string) {
source, version := s.Load(t, llvmSource)
return s.NewPackage(t, "lit", version, source, nil, &PipHelper{
Append: []string{"llvm", "utils", "lit"},
// already checked during llvm
SkipCheck: true,
@@ -371,7 +371,7 @@ func init() {
Dependencies: P{
Python,
},
}
})
}
func init() {
@@ -379,7 +379,7 @@ func init() {
version = "1.1.1"
checksum = "1fVwoal6FoKXczoG3qRUi87TxSWESSGcgvnbEZDYuaOgsO25o36iF3SbAhwkr4Va"
)
artifactsM[PythonPathspec] = newPythonPackage(
native.newPythonPackage(
"pathspec", 23424,
"utility library for gitignore style pattern matching of file paths",
"https://github.com/cpburnz/python-pathspec",
@@ -398,7 +398,7 @@ func init() {
version = "2026.5.7.17"
checksum = "1Fcps0gK9P4ofwGL8MISN9k1Q40-quxX7NDpIna50TmziBNrZy-0Vz0I9yIeHCoP"
)
artifactsM[PythonTroveClassifiers] = newPythonPackage(
native.newPythonPackage(
"trove-classifiers", 88298,
"canonical source for classifiers on PyPI",
"https://pypi.org/p/trove-classifiers/",
@@ -417,7 +417,7 @@ func init() {
version = "1.6.0"
checksum = "GiUgDkKjF8Xn1cmq6iMhTGXzcPIYeaJrvQpHBSAJapNVx4UyuiTXqd5eVlxSClJu"
)
artifactsM[PythonPluggy] = newPythonPackage(
native.newPythonPackage(
"pluggy", 7500,
"the core framework used by the pytest, tox, and devpi projects",
"https://pluggy.readthedocs.io/en/latest/",
@@ -440,7 +440,7 @@ func init() {
version = "1.16.5"
checksum = "V2eREtqZLZeV85yb4O-bfAJCUluHcQP76Qfs0QH5s7RF_Oc8xIP8jD0jl85qFyWk"
)
artifactsM[PythonHatchling] = newPythonPackage(
native.newPythonPackage(
"hatchling", 16137,
"the extensible, standards compliant build backend used by Hatch",
"https://hatch.pypa.io/latest/",
@@ -465,7 +465,7 @@ func init() {
version = "2.20.0"
checksum = "L-2P6vn7c_CNZYliE5CJAWLxO1ziDQVVkf8bnZbHj8aSCQ43oWv11wC9KzU9MeCa"
)
artifactsM[PythonPygments] = newPythonPackage(
native.newPythonPackage(
"pygments", 3986,
"a syntax highlighting package written in Python",
"https://pygments.org/",
@@ -484,7 +484,7 @@ func init() {
version = "2.3.0"
checksum = "mH7VBZaXcYatBPE3RQQZvSzz_Ay8IPPek60NpPHZulPq4ReAFUUsA4EPWfiyMknZ"
)
artifactsM[PythonIniConfig] = newPythonPackage(
native.newPythonPackage(
"iniconfig", 114778,
"a small and simple INI-file parser module",
"https://github.com/pytest-dev/iniconfig",
@@ -507,7 +507,7 @@ func init() {
version = "9.0.3"
checksum = "qfLL_znWhbJCDbNJvrx9H3-orJ86z4ifhaW0bIn21jl2sDP-FVoX_1yieOypArQe"
)
artifactsM[PythonPyTest] = newPythonPackage(
native.newPythonPackage(
"pytest", 3765,
"the pytest framework",
"https://pytest.org",
@@ -534,7 +534,7 @@ func init() {
version = "3.0.3"
checksum = "txRGYdWE3his1lHHRI-lZADw0-ILvUg2l5OGdFHtFXIb_QowGxwdxHCUSJIgmjQs"
)
artifactsM[PythonMarkupSafe] = newPythonPackage(
native.newPythonPackage(
"markupsafe", 3918,
"implements a text object that escapes characters so it is safe to use in HTML and XML",
"https://markupsafe.palletsprojects.com/",
@@ -553,7 +553,7 @@ func init() {
version = "1.3.12"
checksum = "OZbBsQe2MzRuAo5Mr4qRwWHGqU1EEZeBuSprDDIceAtMLIUJtO7SbERlxHIxNhLk"
)
artifactsM[PythonMako] = newPythonPackage(
native.newPythonPackage(
"mako", 3915,
"a template library written in Python",
"https://www.makotemplates.org/",
@@ -571,7 +571,7 @@ func init() {
version = "6.0.3"
checksum = "7wDv0RW9chBdu9l5Q4Hun5F2HHdo105ZSIixwdFPKbEYbftW9YxmsegfL-zafnbJ"
)
artifactsM[PythonPyYAML] = newPythonPackage(
native.newPythonPackage(
"pyyaml", 4123,
"a YAML parser and emitter for Python",
"https://pyyaml.org/",
@@ -590,7 +590,7 @@ func init() {
version = "3.00"
checksum = "4qfCMFKp0fLsRsloOAF780tXX_Ce_68RwinCmjNGObAX32WpF_iBafIKW1S1bYlA"
)
artifactsM[PythonPycparser] = newPythonPackage(
native.newPythonPackage(
"pycparser", 8175,
"complete C99 parser in pure Python",
"https://github.com/eliben/pycparser",