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
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:
@@ -170,34 +170,14 @@ cp -r /system/include /usr/include && rm -rf /system/include
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
source := pkg.NewHTTPGetTar(
|
return t.NewViaCMake("llvm", version, variant, t.NewPatchedSource(
|
||||||
nil, "https://github.com/llvm/llvm-project/archive/refs/tags/"+
|
"llvmorg", pkg.NewHTTPGetTar(
|
||||||
"llvmorg-"+version+".tar.gz",
|
nil, "https://github.com/llvm/llvm-project/archive/refs/tags/"+
|
||||||
mustDecode(checksum),
|
"llvmorg-"+version+".tar.gz",
|
||||||
pkg.TarGzip,
|
mustDecode(checksum),
|
||||||
)
|
pkg.TarGzip,
|
||||||
|
), true, attr.patches...,
|
||||||
patches := make([]pkg.ExecPath, len(attr.patches)+1)
|
), &CMakeAttr{
|
||||||
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{
|
|
||||||
Cache: slices.Concat(cache, attr.cmake),
|
Cache: slices.Concat(cache, attr.cmake),
|
||||||
Append: cmakeAppend,
|
Append: cmakeAppend,
|
||||||
Extra: stage3Concat(t, attr.extra,
|
Extra: stage3Concat(t, attr.extra,
|
||||||
|
|||||||
@@ -271,3 +271,38 @@ ln -vs ../usr/bin /work/bin
|
|||||||
)}, paths)...,
|
)}, paths)...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPatchedSource returns [pkg.Artifact] of source with patches applied. If
|
||||||
|
// passthrough is true, source is returned as is for zero length patches.
|
||||||
|
func (t Toolchain) NewPatchedSource(
|
||||||
|
name string,
|
||||||
|
source pkg.Artifact,
|
||||||
|
passthrough bool,
|
||||||
|
patches ...[2]string,
|
||||||
|
) pkg.Artifact {
|
||||||
|
if passthrough && len(patches) == 0 {
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
|
||||||
|
paths := make([]pkg.ExecPath, len(patches)+1)
|
||||||
|
for i, p := range patches {
|
||||||
|
paths[i+1] = pkg.Path(
|
||||||
|
AbsUsrSrc.Append(name+"-patches", p[0]+".patch"), false,
|
||||||
|
pkg.NewFile(p[0]+".patch", []byte(p[1])),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
paths[0] = pkg.Path(AbsUsrSrc.Append(name), false, source)
|
||||||
|
|
||||||
|
aname := name + "-src"
|
||||||
|
script := `
|
||||||
|
cp -r /usr/src/` + name + `/. /work/.
|
||||||
|
chmod -R +w /work && cd /work
|
||||||
|
`
|
||||||
|
if len(paths) > 1 {
|
||||||
|
script += `cat /usr/src/` + name + `-patches/* | patch -p 1`
|
||||||
|
aname += "-patched"
|
||||||
|
}
|
||||||
|
return t.New(aname, stage3Concat(t, []pkg.Artifact{},
|
||||||
|
t.Load(Patch),
|
||||||
|
), nil, nil, script, paths...)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user