import{_ as s,o as a,c as n,Q as l}from"./chunks/framework.ec8f7e8e.js";const u=JSON.parse('{"title":"如何构建 KernelSU?","description":"","frontmatter":{},"headers":[],"relativePath":"zh_CN/guide/how-to-build.md","filePath":"zh_CN/guide/how-to-build.md"}'),o={name:"zh_CN/guide/how-to-build.md"},e=l(`
首先,您应该阅读内核构建的 Android 官方文档:
WARNING
本文档适用于 GKI 设备,如果你是旧内核,请参考如何为非GKI设备集成 KernelSU
repo init -u https://android.googlesource.com/kernel/manifest
mv <kernel_manifest.xml> .repo/manifests
repo init -m manifest.xml
repo syncrepo init -u https://android.googlesource.com/kernel/manifest
mv <kernel_manifest.xml> .repo/manifests
repo init -m manifest.xml
repo sync<kernel_manifest.xml> 是一个可以唯一确定构建的清单文件,您可以使用该清单进行可重新预测的构建。 您应该从 通用内核映像 (GKI) 发布构建 下载清单文件
请先查看 官方文档。
例如,我们需要构建 aarch64 内核镜像:
LTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.shLTO=thin BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh不要忘记添加 LTO=thin, 否则,如果您的计算机内存小于 24GB,构建可能会失败.
从 Android 13 开始,内核由 bazel 构建:
tools/bazel build --config=fast //common:kernel_aarch64_disttools/bazel build --config=fast //common:kernel_aarch64_dist如果您可以成功构建内核,那么构建 KernelSU 就很容易,根据自己的需求在内核源代码根目录中运行以下任一命令:
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s maincurl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s maincurl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s v0.5.2curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s v0.5.2然后重建内核,您将获得带有 KernelSU 的内核映像!
`,24),p=[e];function t(r,c,i,y,d,E){return a(),n("div",null,p)}const F=s(o,[["render",t]]);export{u as __pageData,F as default};