Skip to content

Commit

Permalink
更新构建系统缺失部分
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhongjia committed Dec 28, 2023
1 parent 7a6d9ca commit 91c0beb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions learn/engineering/build-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ pub fn build(b: *std.Build) void {
}
```

::: info 🅿️ 提示

值得注意的是,`b.installArtifact` 是将构建放入 `install` 这一 step 中,即默认的 step。

如果我们想要重新创建一个全新的 install,可以使用 [`b.addInstallArtifact`](https://ziglang.org/documentation/master/std/#A;std:Build.addInstallArtifact),它的原型为:

```zig
fn addInstallArtifact(self: *Build, artifact: *Step.Compile, options: Step.InstallArtifact.Options) *Step.InstallArtifact
```

它会返回一个新的 [`InstallArtifact`](https://ziglang.org/documentation/master/std/#A;std:Build.Step.InstallArtifact),让对应的 step 依赖它即可!

:::

## CLI 参数

通过 `b.option` 使构建脚本部分配置由用户决定(通过命令行参数传递),这也可用于依赖于当前包的其他包。
Expand Down
2 changes: 1 addition & 1 deletion learn/more/reflection.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ zig 除了获取类型信息外,还提供了在编译期构建全新类型的

该函数实际上就是 `@typeInfo` 的反函数,它将类型信息具体化为一个类型。

TODO
TODO

0 comments on commit 91c0beb

Please sign in to comment.