diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-03-01 23:50:22 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-03-01 23:50:22 +0900 |
| commit | 9deaf853f0676ee4475468bffd35aae7e1160a74 (patch) | |
| tree | b0fe283249a853e64b76f9585c623c745ec9796e /internal/rosa/llvm.go | |
| parent | 2baa9df1331721ea6e0cbd384784fcb97101b8dc (diff) | |
internal/rosa/cmake: migrate to helper interface
This change also removes some unused options.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/llvm.go')
| -rw-r--r-- | internal/rosa/llvm.go | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/internal/rosa/llvm.go b/internal/rosa/llvm.go index 9a848cdb..c8cdfed8 100644 --- a/internal/rosa/llvm.go +++ b/internal/rosa/llvm.go @@ -7,33 +7,27 @@ import ( "strings" "sync" - "hakurei.app/container/check" "hakurei.app/internal/pkg" ) // llvmAttr holds the attributes that will be applied to a new [pkg.Artifact] // containing a LLVM variant. type llvmAttr struct { + // Passed through to PackageAttr.Flag. flags int - // Concatenated with default environment for CMakeAttr.Env. + // Concatenated with default environment for PackageAttr.Env. env []string - // Concatenated with generated entries for CMakeAttr.Cache. + // Concatenated with generated entries for CMakeHelper.Cache. cmake [][2]string - // Override CMakeAttr.Append. + // Override CMakeHelper.Append. append []string - // Concatenated with default dependencies for Toolchain.NewViaCMake. - extra []pkg.Artifact - // Passed through to CMakeAttr.Paths. + // Passed through to PackageAttr.NonStage0. + nonStage0 []pkg.Artifact + // Passed through to PackageAttr.Paths. paths []pkg.ExecPath - // Passed through to CMakeAttr.ScriptConfigured. - scriptConfigured string - // Concatenated with default fixup for CMakeAttr.Script. + // Concatenated with default fixup for CMakeHelper.Script. script string - // Passed through to CMakeAttr.Prefix. - prefix *check.Absolute - // Passed through to CMakeAttr.Writable. - writable bool // Patch name and body pairs. patches [][2]string @@ -101,7 +95,7 @@ func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact { } } - var script, scriptEarly string + var script string cache := [][2]string{ {"CMAKE_BUILD_TYPE", "Release"}, @@ -167,43 +161,41 @@ ln -s ld.lld /work/system/bin/ld ) } - return t.NewViaCMake("llvm", version, t.NewPatchedSource( + return t.NewPackage("llvm", version, t.NewPatchedSource( "llvmorg", version, pkg.NewHTTPGetTar( nil, "https://github.com/llvm/llvm-project/archive/refs/tags/"+ "llvmorg-"+version+".tar.gz", mustDecode(checksum), pkg.TarGzip, ), true, attr.patches..., - ), &CMakeAttr{ - Variant: variant, - - Cache: slices.Concat(cache, attr.cmake), - Append: cmakeAppend, - Prefix: attr.prefix, + ), &PackageAttr{ + NonStage0: attr.nonStage0, Env: slices.Concat([]string{ "ROSA_LLVM_PROJECTS=" + strings.Join(projects, ";"), "ROSA_LLVM_RUNTIMES=" + strings.Join(runtimes, ";"), }, attr.env), - ScriptEarly: scriptEarly, - ScriptConfigured: attr.scriptConfigured, - Script: script + attr.script, - Writable: attr.writable, Paths: attr.paths, Flag: TExclusive, - }, stage0Concat(t, attr.extra, - t.Load(Libffi), - t.Load(Python), - t.Load(Perl), - t.Load(Diffutils), - t.Load(Bash), - t.Load(Gawk), - t.Load(Coreutils), - t.Load(Findutils), + }, &CMakeHelper{ + Variant: variant, - t.Load(KernelHeaders), - )...) + Cache: slices.Concat(cache, attr.cmake), + Append: cmakeAppend, + Script: script + attr.script, + }, + Libffi, + Python, + Perl, + Diffutils, + Bash, + Gawk, + Coreutils, + Findutils, + + KernelHeaders, + ) } // newLLVM returns LLVM toolchain across multiple [pkg.Artifact]. @@ -246,21 +238,21 @@ func (t Toolchain) newLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) { {"COMPILER_RT_BUILD_XRAY", "OFF"}, }, append: []string{"compiler-rt"}, - extra: []pkg.Artifact{t.newMusl(true, []string{ + nonStage0: []pkg.Artifact{t.newMusl(true, []string{ "CC=clang", })}, script: ` -mkdir -p "${ROSA_INSTALL_PREFIX}/lib/clang/21/lib/" +mkdir -p "/work/system/lib/clang/21/lib/" ln -s \ "../../../${ROSA_TRIPLE}" \ - "${ROSA_INSTALL_PREFIX}/lib/clang/21/lib/" + "/work/system/lib/clang/21/lib/" ln -s \ "clang_rt.crtbegin-` + linuxArch() + `.o" \ - "${ROSA_INSTALL_PREFIX}/lib/${ROSA_TRIPLE}/crtbeginS.o" + "/work/system/lib/${ROSA_TRIPLE}/crtbeginS.o" ln -s \ "clang_rt.crtend-` + linuxArch() + `.o" \ - "${ROSA_INSTALL_PREFIX}/lib/${ROSA_TRIPLE}/crtendS.o" + "/work/system/lib/${ROSA_TRIPLE}/crtendS.o" `, }) @@ -287,7 +279,7 @@ ln -s \ {"LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL", "OFF"}, }, minimalDeps), append: []string{"runtimes"}, - extra: []pkg.Artifact{ + nonStage0: []pkg.Artifact{ compilerRT, musl, }, @@ -305,7 +297,7 @@ ln -s \ {"CMAKE_CROSSCOMPILING", "OFF"}, {"CXX_SUPPORTS_CUSTOM_LINKER", "ON"}, }, minimalDeps), - extra: []pkg.Artifact{ + nonStage0: []pkg.Artifact{ musl, compilerRT, runtimes, |
