b2ba7d2a4f
【变量学习】添加了变量的学习代码及md说明文件
37 lines
1.3 KiB
Zig
37 lines
1.3 KiB
Zig
const std = @import("std");
|
||
|
||
pub fn build(b: *std.Build) void {
|
||
// 标准构建目标
|
||
const target = b.standardTargetOptions(.{});
|
||
// 标准构建模式
|
||
const optimize = b.standardOptimizeOption(.{});
|
||
// ---------------------------unit test---------------------------------
|
||
// 单元测试步骤构建
|
||
// 添加测试目标
|
||
const test_exe = b.addTest(.{
|
||
.root_source_file = .{ .path = "src/main.zig" },
|
||
.target = target,
|
||
.optimize = optimize,
|
||
});
|
||
// 执行单元测试
|
||
const run_exe_unit_tests = b.addRunArtifact(test_exe);
|
||
// 构建一个 step,用于执行测试
|
||
const test_step = b.step("test", "运行单元测试");
|
||
// 测试 step 依赖上方构建的run_exe_unit_tests
|
||
test_step.dependOn(&run_exe_unit_tests.step);
|
||
|
||
// -----------------------------run--------------------------------------
|
||
// 添加一个运行目标
|
||
const run = b.addExecutable(.{
|
||
.name = "zig-test",
|
||
.root_source_file = .{ .path = "src/main.zig" },
|
||
.target = target,
|
||
.optimize = optimize,
|
||
});
|
||
// 执行测试
|
||
const run_exe = b.addRunArtifact(run);
|
||
// 构建一个 step,用于执行程序
|
||
const run_step = b.step("run", "运行程序");
|
||
run_step.dependOn(&run_exe.step);
|
||
}
|