zig-learn/variable/build.zig
邵静 b2ba7d2a4f 【添加md文件】添加了README.md、hello.md、variable.md
【变量学习】添加了变量的学习代码及md说明文件
2024-05-15 15:51:06 +08:00

37 lines
1.3 KiB
Zig
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}