打包 — Zig 构建系统全书¶
「Packing」(打包)是原书的玩笑标题,内容是 Zig 构建系统的全书级讲解—— 这也是第 1 章承诺「构建脚本就是 Zig 代码」的兑现章。 六个板块:build.zig 解剖(它是程序,不是配置)、交叉编译(target 旋钮)、 四种 release 模式(安全与速度的交易)、自定义构建选项、依赖管理 (ZON 清单 + 哈希锁供应链)、缓存与
--watch(增量构建的心脏与自动化)。
1. 这一章讲什么¶
链条位置:第 3 章见过 zig init 的四件套,第 2 章在 build.zig 里加过 check 步骤,
本章把「构建系统」从工具升级为完整的编程领域——读完后你应该能读懂任何
Zig 项目的 build.zig,并为自己的项目写出一个。
2. 顶层全景:施工队模型¶
原书给的团队比喻很精确,照单接住1:
Build = 项目经理:b: *std.Build,管选项、依赖、整张图
Steps = 工人:编译、运行、安装……每个只做一件事
Modules = 交付物:库、可执行文件
Dependencies = 分包商:外部包(b.dependency 请来)
LazyPath / Cache = 后勤:文件在哪、什么不用重做
DAG = 工序表:谁先谁后,不许循环
图说:zbuild --help 里的 Steps 列表(install/run/test/uninstall)
就是这张图的入口;dependOn 就是工序之间的箭头。
主线例子(贯穿全章):从 zig init 出发 → zig build run 跑起来 →
-Dtarget 交叉编译 → -Doptimize=ReleaseSafe 换档 →
zig fetch --save 拉依赖 → zig build --watch 常驻。
一条命令链走完全部六个板块。
3. build.zig 解剖:它是程序¶
zig init 生成的 build.zig 里,你现在能认出的每一行都是学过的 Zig:
b.addExecutable(.{ .name = "zigt", .root_source_file = b.path("src/main.zig") })
声明可执行产物;b.addTest(...) + b.addRunArtifact(...) +
b.step("test", "Run unit tests") 的 dependOn 链,注册 test 步骤2。
原书在这里点破一个教学事实:你已经能读 build.zig 了——它没有任何新语法,
全是 Zig 函数调用3。四个标准步骤 install(默认)/ uninstall / run / test,
zig build --help 的 Steps 区可见4。
run 步骤的标准配方(照原书):addRunArtifact(exe) 产生运行命令,
run_cmd.step.dependOn(b.getInstallStep()) 保证先编译后运行,
再 b.step("run", ...) 挂名5。
4. DAG:工序表¶
DAG = 有向无环图:节点是任务,边是「必须先完成」的依赖,无环保证能排出确定顺序、能并行6。
test_step.dependOn(&run_tests.step) 的本质是把一条规则刻进这张图:
测试没跑完,不许过7。自定义步骤就是往图里塞自己的节点:
const bundle_step = b.step("bundle-assets", "Pack textures and sounds");
const bundle = b.addSystemCommand(&.{ "python3", "scripts/bundle_assets.py", ... });
bundle_step.dependOn(&bundle.step); // zig build bundle-assets 现在存在
8 这让构建系统成为「逃生舱」:Zig 没预见的事(打包资源、发 Slack), 你用自己的命令补位,但执行时机仍由 DAG 保证。
5. 交叉编译:Zig 的派对 trick¶
const target = b.standardTargetOptions(.{}) 那行就是交叉编译的旋钮9。
目标用「三重串」写:<arch>-<os>-<abi>,如 x86_64-linux-gnu、
aarch64-macos-none、wasm32-freestanding-musl10。
命令行:zig build -Dtarget=aarch64-macos-none,一条命令出另一个平台的二进制
——原书的评价:「没有 ./configure && make && sudo make install 那套破事」11。
支持度分四层(原书给了完整清单)12:
| 层 | 含义 | 例子 |
|---|---|---|
| Tier 1 | 生产可用:ABI 稳定、std 全覆盖、CI 常测 | x86_64(三系统)、aarch64、riscv64 |
| Tier 2 | 社区维护:部分 std、测试较少 | ARM32、MIPS、SPARC |
| Tier 3 | 实验性:几乎没 std、要手工配置 | Hexagon、 AMDGPU |
| Tier 4 | 废弃/遗产 | AVR、MSP430 |
standardTargetOptions 收两个参数:whitelist(允许的目标清单,
越界直接报错并列出合法项)和 default_target(不指定时的默认)13。
报错样例照原书:riscv65-windows-msvc → UnknownArchitecture;
windows11 → unknown OS;windows-hello → UnknownApplicationBinaryInterface——
错误信息本身就是文档14。
6. Release 模式:四档交易的实战面¶
第 1 章给了四档的概念,本章给了逐档的行为演示。演示程序只有五行:
var x: u8 = 255; x += 1;(u8 最大 255,加一必溢出)15:
| 模式 | 这行代码的后果 | 一句话 |
|---|---|---|
| Debug(默认) | panic:「Integer overflow detected!」 | 不优化、全检查、编译快 |
| ReleaseSafe | 一样 panic,「但更快」 | 生产首选:优化 + 保留检查、构建可复现 |
| ReleaseFast | 未定义行为(可能绕回 0) | 性能的野蛮人:检查全关 |
| ReleaseSmall | 未定义行为,但二进制小 | stealth:同 Safe 的速度、体积最小 |
原书的判词:要速度就得舍安全,像盾和巨剑不能同时挥16。
两条例外的灵活度:混档——核心逻辑 ReleaseFast、测试保持 Debug,同一项目内可行17;
粒度控制——@setRuntimeSafety(false) 在函数或块级关掉检查,
「我知道我在做什么,Zig,相信我」18。(原书还留了条未来注:它可能改名
@optimizeFor——1.0 前语言的常态。)
7. 自定义构建选项:编译期配置¶
b.option(bool, "dark_mode", "Enable Dark Mode UI") orelse false 声明一个
命令行开关;b.addOptions() + addOption + exe.root_module.addOptions("config", options)
把它在编译期送进程序;代码里 @import("config") 读它,
if (config.is_dark_mode_enabled) 直接决定编译进哪个分支——
未用的代码路径被优化掉19。命令行:zig build run -Ddark_mode=true20。
这条链路是第 12 章 comptime 的前哨:构建选项是「编译期已知」的正规军用法。
第 7 章覆盖率示例里的 -Dcoverage 用的就是同一个机制。
8. 依赖管理:ZON、fetch 与哈希锁¶
三件套,名字一条链,错一个就报错(原书叫它 naming trifecta)21:
① build.zig.zon .zap = .{ .url = "...", .hash = "1220..." } ← 清单
② build.zig const zap = b.dependency("zap", .{...}); ← 请进来
exe.root_module.addImport("zap", zap.module("zap"));
③ 源代码 const zap = @import("zap"); ← 用
build.zig.zon(ZON = Zig Object Notation)是项目的清单文件:名字、版本、
依赖表;每个依赖 = URL + SHA-256 哈希22。
zig fetch --save <url> 做三件事:下载、算哈希、自动改写你的 zon 文件23。
URL 花样(原书列了一串):裸文件 HTTP(S)(GitHub 记得加 ?raw=true)、
file://(内网共享盘)、GitHub release 资产、IPFS 网关、Debian 包、
S3 签名 URL,以及 rebels 专用的 .path 本地目录(哈希验证作废,链锯杂耍级危险)24。
哈希为什么存在:供应链攻击防护。镜像站被攻陷、包被换成带后门的版本时, 哈希对不上,Zig 直接拒绝——「信任,但要验证;说验证,就是密码学哈希级别的验证」。 它还是可复现构建的保证:今天编和一年后编,同样的 zon 给出同样的依赖25。
9. 文档生成:编译器的副业¶
/// 注释声明、//! 注释文件级说明,zig build-lib -femit-docs src/x.zig
一步出 HTML 文档站26。错误集合并(A || B)时最左边错误的文档胜出——
FireBreathIncident 在龙错误集里有注释「吃了你的作业」、在地图错误集里有
「隐形墨水写的」,合并后继承龙的版本27。文档也能进构建管线:
getEmittedDocs() + addInstallDirectory 装进 zig-out,zig build scrolls 一步出文档28。
10. 缓存:编译器的记忆¶
原书的定性:「不是附加功能,是快速构建的地基」29。机制三层:
① 内容寻址:每个产物的内容指纹 = SipHash128(源文件字节、编译器版本、
标志位),改一位,哈希全变30。
② 清单文件(h/ 目录):每个构建步骤一份 .txt,记录输入的规范化相对路径
(绝不允许绝对路径——跨机器共享缓存的关键)、每个输入的尺寸/修改时间/inode/哈希、
锁信息31。条目格式极简:<size> <inode> <mtime> <hexdigest> <prefix-id> <file-path>32。
③ 两级查验:先看 o/ 目录里产物的元数据(纳秒级快),元数据对上了再用 h/ 的清单做
内容哈希的终验——「快路径 + 安全网」33。
目录分工:h/ = 清单(只有 .txt);o/ = 真产物(.o、.a、可执行文件、
.wasm,文件名即输出名);z/ = 全局 Zig 数据(跨项目共享缓存、
预编译的 std 片段、下载的包信息);tmp/ = 临时工,别依赖34。
两个工程细节值得记住:
- 前缀 ID 表:清单里那个
0不是绝对路径,是查表键——你机器上 0 映射/home/alexrios/.cache/zig/p/...,别人机器上映射别的;「无绝对路径」规则靠这个 workaround 技术性地成立35; - 网络文件系统:时间戳不可靠时,Zig 自动退回全内容哈希——慢,但永远对; 正确性优先于速度36。
--watch 是缓存之上的自动化:先全量构建,然后靠操作系统的文件通知 API 盯源文件,
一变就用依赖图 + 缓存做外科手术式的最小重建;出编译错误也不退出,继续盯着等你修;
zig build test --watch = 每次保存自动重跑测试37。三条边界:初建还是要全量;
依赖图之外的文件不盯;build.zig 本身的改动不触发重建,要重启 --watch(防止构建脚本发疯)38。
11. Modules:组织单元¶
模块生命周期三步(原书):声明(addStaticLibrary/addExecutable/createModule)
→ 配置(addImport、addIncludePath、setTarget 等)
→ 集成(installArtifact)39。多模块靠 exe.addImport("mylib", lib)
连线——库是补给舰,可执行是主力舰40。什么时候拆模块:代码复用、依赖管理、
交叉编译、混合语言项目41。
12. 作者的判断与证据¶
可核的: 全部命令、API、报错文本(UnknownArchitecture 等)、u8 溢出四档行为、 缓存目录结构、清单格式——都可跑可验14153234。
立场: 「构建系统是 Zig 表达力的最佳广告」是本章的潜台词; 「embrace the pain」框承认学习曲线陡,但承诺回报是「精干、强大」的代码库42。 依赖管理「开箱即核心功能」的夸耀忽略了一点:Zig 的包生态当时(0.15 时代) 还很年轻,zon 里的 URL 大多指向 Git 仓库而非注册中心——机制先进,生态另说。
13. 边界与局限¶
| 缺什么 | 说明 |
|---|---|
| 没有讲 build runner 的测试/调试入口 | zig build --verbose、构建脚本本身的单测,未提 |
| 包注册中心缺席 | 全靠 URL,没有 crates.io 式的中央索引(写作时 zigpm 生态仍早期) |
| 缓存的失效排障没展开 | 「缓存导致怪 bug 时怎么办」只给了句 good luck |
| CI/CD 集成只有一句 | whitelist 的 CI 可靠性提了,没有完整示例 |
| 跨编译的 C 依赖链接没讲 | 交叉编译 C 库(最痛的场景)留给读者自己撞 |
| 章节内部 API 版本混杂 | 有的示例用 root_module 新 API,有的还用 .root_source_file = .{ .path = ... } 过渡形态——照抄前先确认你的 Zig 版本 |
14. 可带走的¶
主线例子一行: zig init → zig build run →
zig build -Dtarget=aarch64-macos-none(交叉)→
zig build -Doptimize=ReleaseSafe(换档)→
zig fetch --save "git+https://..."(拉依赖)→
zig build --watch(常驻重建+测试)。
- build.zig 是 Zig 程序:Build 管项目、Step 干活、Module 交付、DAG 排序;
dependOn是工序之间的边; - 四个标准步骤 install(默认)/uninstall/run/test,
--help可查,自定义步骤靠b.step+addSystemCommand; - 交叉编译 = 换 target:三重串
arch-os-abi,四层支持分级(Tier 1 才敢上生产), whitelist 防止团队编错目标; - 四档模式是行为差异:同一个 u8 溢出,Debug/ReleaseSafe panic、
ReleaseFast/Small 未定义行为;
@setRuntimeSafety(false)块级放权; - 自定义选项进编译期:
b.option→addOptions→@import("config"), 未用分支被优化掉; - 依赖三件套一条名链:zon 清单(key)= b.dependency(名) = @import(名), 错一个就报错;
zig fetch --save下载 + 算 SHA-256 + 自动写 zon;哈希是供应链锁 + 可复现性保证;- 缓存 = 内容寻址:h/ 清单(相对路径+锁)、o/ 产物、z/ 全局、tmp/ 临时工; 两级查验(元数据快检 + 哈希终验),网络文件系统退回全哈希;
--watch:文件通知驱动增量重建,错误不退出,test --watch是质量守门员; build.zig 改动要重启;- 文档是编译器的副业:
-femit-docs出 HTML;错误集合并时左边的注释赢。
15. 原文地图¶
| 主题 | 原书章 | 原文位置 |
|---|---|---|
| build.zig 解剖(addExecutable 等) | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:99(搜「addStaticLibrary」) · text/18-ch11-chapter-11-packing.txt:107(搜「b.addExecutable」) |
| test 步骤链 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:121(搜「Run unit tests」) |
| 四个标准步骤 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:139(搜「install (default)」) |
| run 步骤配方 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:193(搜「Ensure it's built first」) |
| DAG 定义 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:214(搜「directed acyclic graph」) |
| zig targets | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:246(搜「zig targets」) |
| 四层目标分级 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:262(搜「four tiers」) · text/18-ch11-chapter-11-packing.txt:266(搜「production-ready」) |
| 三重串格式 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:379(搜「arch>-<os>-<abi」) |
| whitelist 与报错 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:411(搜「whitelist」) · text/18-ch11-chapter-11-packing.txt:457(搜「not in allowed list」) |
| OptimizeMode 四值 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:516(搜「OptimizeMode = enum」) |
| u8 溢出四档演示 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:636(搜「panics with overflow detection」) · text/18-ch11-chapter-11-packing.txt:638(搜「likely wraps to 0」) |
| 混档与 @setRuntimeSafety | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:642(搜「mix modes」) · text/18-ch11-chapter-11-packing.txt:660(搜「@setRuntimeSafety(false)」) |
| 自定义选项 → config | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:700(搜「b.option(bool」) · text/18-ch11-chapter-11-packing.txt:758(搜「Import the options module」) |
| 施工队模型 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:784(搜「Build is the project manager」) |
| Step 分类学 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:804(搜「taxonomy of steps」) |
| 自定义步骤 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:855(搜「bundle-assets」) |
| 模块生命周期 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:925(搜「life cycle」) |
| addImport 连线 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:987(搜「addImport」) |
| 文档注释与 -femit-docs | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1103(搜「annotate declarations」) · text/18-ch11-chapter-11-packing.txt:1144(搜「-femit-docs」) |
| 错误集文档左者优先 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1158(搜「leftmost」) |
| ZON 与依赖声明 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1248(搜「Zig Object Notation」) · text/18-ch11-chapter-11-packing.txt:1262(搜「git+https://github.com/zigzap」——示例 URL 为原书所引(查阅于 2026-10-19)) |
| zig fetch --save | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1294(搜「zig fetch --save」) |
| b.dependency + addImport | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1352(搜「const zap = b.dependency」) |
| 命名三连 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1376(搜「must match」) |
| 哈希与供应链 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1390(搜「SHA-256」) · text/18-ch11-chapter-11-packing.txt:1397(搜「supply chain attack」) |
| URL 花样 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1419(搜「Raw file URLs」) · text/18-ch11-chapter-11-packing.txt:1447(搜「directory URL」) |
| 内容寻址与 SipHash128 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1476(搜「Content-addressable」) |
| 清单文件格式 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1508(搜「prefix-id」) |
| 缓存目录 h/o/z/tmp | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1537(搜「h/ directory」) · text/18-ch11-chapter-11-packing.txt:1558(搜「o/ directory」) · text/18-ch11-chapter-11-packing.txt:1582(搜「z/ directory」) |
| 前缀 ID 表 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1620(搜「prefix ID」) |
| 网络文件系统回退 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1634(搜「flaky timestamps」) |
| 两级查验 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1643(搜「doesn’t blindly trust」) |
| --watch 行为 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1687(搜「tireless」) · text/18-ch11-chapter-11-packing.txt:1716(搜「testing nirvana」) |
| --watch 限制 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1755(搜「build.zig file itself」) |
| 全章总结 | Chapter 11: Packing | text/18-ch11-chapter-11-packing.txt:1774(搜「zig init is your friend」) |
-
出处:「Chapter 11: Packing」第 781–790 段(
text/18-ch11-chapter-11-packing.txt:793,搜「coordinating all workers」)。 ↩ -
出处:同章第 93–129 段(
text/18-ch11-chapter-11-packing.txt:99,搜「addStaticLibrary」;text/18-ch11-chapter-11-packing.txt:107,搜「b.addExecutable」;text/18-ch11-chapter-11-packing.txt:121,搜「Run unit tests」)。 ↩ -
出处:同章第 127–129 段(
text/18-ch11-chapter-11-packing.txt:128,搜「just reading the build」)。 ↩ -
出处:同章第 133–143 段(
text/18-ch11-chapter-11-packing.txt:139,搜「install (default)」)。 ↩ -
出处:同章第 170–198 段(
text/18-ch11-chapter-11-packing.txt:193,搜「Ensure it's built first」;text/18-ch11-chapter-11-packing.txt:193,搜「getInstallStep」)。 ↩ -
出处:同章第 217–224 段(
text/18-ch11-chapter-11-packing.txt:214,搜「directed acyclic graph」;text/18-ch11-chapter-11-packing.txt:222,搜「no circular dependencies」)。 ↩ -
出处:同章第 824–832 段(
text/18-ch11-chapter-11-packing.txt:829,搜「dependOn」)。 ↩ -
出处:同章第 852–864 段(
text/18-ch11-chapter-11-packing.txt:855,搜「bundle-assets」)。 ↩ -
出处:同章第 355–363 段(
text/18-ch11-chapter-11-packing.txt:360,搜「ResolvedTarget」)。 ↩ -
出处:同章第 372–390 段(
text/18-ch11-chapter-11-packing.txt:379,搜「arch>-<os>-<abi」)。 ↩ -
出处:同章第 469–472 段(
text/18-ch11-chapter-11-packing.txt:471,搜「configure」)。 ↩ -
出处:同章第 262–353 段(
text/18-ch11-chapter-11-packing.txt:262,搜「four tiers」;text/18-ch11-chapter-11-packing.txt:267,搜「continuous integration」)。 ↩ -
出处:同章第 404–427 段(
text/18-ch11-chapter-11-packing.txt:411,搜「whitelist」;text/18-ch11-chapter-11-packing.txt:412,搜「default_target」)。 ↩ -
出处:同章第 455–467 段(
text/18-ch11-chapter-11-packing.txt:457,搜「not in allowed list」;text/18-ch11-chapter-11-packing.txt:463,搜「UnknownArchitecture」)。 ↩↩ -
出处:同章第 594–639 段(
text/18-ch11-chapter-11-packing.txt:624,搜「var x: u8 = 255」;text/18-ch11-chapter-11-packing.txt:636,搜「panics with overflow detection」;text/18-ch11-chapter-11-packing.txt:638,搜「likely wraps to 0」)。 ↩↩ -
出处:同章第 590–592 段(
text/18-ch11-chapter-11-packing.txt:591,搜「shield and a zweihander」)。 ↩ -
出处:同章第 641–654 段(
text/18-ch11-chapter-11-packing.txt:643,搜「ReleaseFast」)。 ↩ -
出处:同章第 656–678 段(
text/18-ch11-chapter-11-packing.txt:660,搜「@setRuntimeSafety(false)」;text/18-ch11-chapter-11-packing.txt:677,搜「rename」)。 ↩ -
出处:同章第 684–718 段(
text/18-ch11-chapter-11-packing.txt:700,搜「b.option(bool」;text/18-ch11-chapter-11-packing.txt:716,搜「compile-time known」)。 ↩ -
出处:同章第 768–772 段(
text/18-ch11-chapter-11-packing.txt:771,搜「-Ddark_mode=true」)。 ↩ -
出处:同章第 1375–1381 段(
text/18-ch11-chapter-11-packing.txt:1376,搜「must match」;text/18-ch11-chapter-11-packing.txt:1380,搜「trifecta」)。 ↩ -
出处:同章第 1245–1274 段(
text/18-ch11-chapter-11-packing.txt:1248,搜「Zig Object Notation」;text/18-ch11-chapter-11-packing.txt:1262,搜「git+https://github.com/zigzap」——示例 URL 为原书所引(查阅于 2026-10-19))。 ↩ -
出处:同章第 1276–1333 段(
text/18-ch11-chapter-11-packing.txt:1294,搜「zig fetch --save」;text/18-ch11-chapter-11-packing.txt:1306,搜「SHA-256」)。 ↩ -
出处:同章第 1412–1454 段(
text/18-ch11-chapter-11-packing.txt:1419,搜「Raw file URLs」;text/18-ch11-chapter-11-packing.txt:1447,搜「directory URL」)。 ↩ -
出处:同章第 1386–1410 段(
text/18-ch11-chapter-11-packing.txt:1390,搜「SHA-256」;text/18-ch11-chapter-11-packing.txt:1397,搜「supply chain attack」;text/18-ch11-chapter-11-packing.txt:1405,搜「consistent build output」)。 ↩ -
出处:同章第 1094–1156 段(
text/18-ch11-chapter-11-packing.txt:1103,搜「annotate declarations」;text/18-ch11-chapter-11-packing.txt:1144,搜「-femit-docs」)。 ↩ -
出处:同章第 1157–1178 段(
text/18-ch11-chapter-11-packing.txt:1158,搜「leftmost」;text/18-ch11-chapter-11-packing.txt:1162,搜「ate your homework」)。 ↩ -
出处:同章第 1180–1223 段(
text/18-ch11-chapter-11-packing.txt:1198,搜「addInstallDirectory」;text/18-ch11-chapter-11-packing.txt:1220,搜「zig build scrolls」)。 ↩ -
出处:同章第 1462–1470 段(
text/18-ch11-chapter-11-packing.txt:1468,搜「foundation」)。 ↩ -
出处:同章第 1476–1490 段(
text/18-ch11-chapter-11-packing.txt:1483,搜「SipHash128」)。 ↩ -
出处:同章第 1492–1511 段(
text/18-ch11-chapter-11-packing.txt:1500,搜「No absolute paths」)。 ↩ -
出处:同章第 1508 段(
text/18-ch11-chapter-11-packing.txt:1508,搜「prefix-id」)。 ↩↩ -
出处:同章第 1638–1651 段(
text/18-ch11-chapter-11-packing.txt:1643,搜「doesn’t blindly trust」;text/18-ch11-chapter-11-packing.txt:1645,搜「two-stage check」)。 ↩ -
出处:同章第 1532–1600 段(
text/18-ch11-chapter-11-packing.txt:1537,搜「h/ directory」;text/18-ch11-chapter-11-packing.txt:1558,搜「o/ directory」;text/18-ch11-chapter-11-packing.txt:1582,搜「z/ directory」)。 ↩↩ -
出处:同章第 1618–1629 段(
text/18-ch11-chapter-11-packing.txt:1620,搜「prefix ID」)。 ↩ -
出处:同章第 1634–1635 段(
text/18-ch11-chapter-11-packing.txt:1634,搜「flaky timestamps」)。 ↩ -
出处:同章第 1676–1741 段(
text/18-ch11-chapter-11-packing.txt:1687,搜「tireless」;text/18-ch11-chapter-11-packing.txt:1706,搜「dependency graph」;text/18-ch11-chapter-11-packing.txt:1716,搜「testing nirvana」)。 ↩ -
出处:同章第 1752–1757 段(
text/18-ch11-chapter-11-packing.txt:1755,搜「build.zig file itself」)。 ↩ -
出处:同章第 924–965 段(
text/18-ch11-chapter-11-packing.txt:925,搜「life cycle」)。 ↩ -
出处:同章第 967–1006 段(
text/18-ch11-chapter-11-packing.txt:987,搜「addImport」)。 ↩ -
出处:同章第 996–1006 段(
text/18-ch11-chapter-11-packing.txt:998,搜「Code reuse」)。 ↩ -
出处:同章第 1081–1089 段(
text/18-ch11-chapter-11-packing.txt:1084,搜「high-intensity workout」)。 ↩