internal/rosa: isolate patching helper
All checks were successful
Test / Create distribution (push) Successful in 51s
Test / Sandbox (push) Successful in 3m10s
Test / Hakurei (push) Successful in 4m33s
Test / ShareFS (push) Successful in 4m33s
Test / Sandbox (race detector) (push) Successful in 5m16s
Test / Hpkg (push) Successful in 5m26s
Test / Hakurei (race detector) (push) Successful in 4m59s
Test / Flake checks (push) Successful in 1m52s

This is useful outside llvm as well.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-26 20:47:11 +09:00
parent 68b7d41c65
commit 4f17dad645
2 changed files with 43 additions and 28 deletions

View File

@@ -170,34 +170,14 @@ cp -r /system/include /usr/include && rm -rf /system/include
)
}
source := pkg.NewHTTPGetTar(
nil, "https://github.com/llvm/llvm-project/archive/refs/tags/"+
"llvmorg-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
)
patches := make([]pkg.ExecPath, len(attr.patches)+1)
for i, p := range attr.patches {
patches[i+1] = pkg.Path(
AbsUsrSrc.Append("llvm-patches", p[0]+".patch"), false,
pkg.NewFile(p[0], []byte(p[1])),
)
}
patches[0] = pkg.Path(AbsUsrSrc.Append("llvmorg"), false, source)
if len(patches) > 1 {
source = t.New(
"llvmorg-patched", stage3Concat(t, []pkg.Artifact{},
t.Load(Patch),
), nil, nil, `
cp -r /usr/src/llvmorg/. /work/.
chmod -R +w /work && cd /work
cat /usr/src/llvm-patches/* | patch -p 1
`, patches...,
)
}
return t.NewViaCMake("llvm", version, variant, source, &CMakeAttr{
return t.NewViaCMake("llvm", version, variant, t.NewPatchedSource(
"llvmorg", pkg.NewHTTPGetTar(
nil, "https://github.com/llvm/llvm-project/archive/refs/tags/"+
"llvmorg-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
), true, attr.patches...,
), &CMakeAttr{
Cache: slices.Concat(cache, attr.cmake),
Append: cmakeAppend,
Extra: stage3Concat(t, attr.extra,