newbuild.zig 798 B

12345678910111213141516171819202122232425262728293031
  1. const std = @import("std");
  2. pub fn build(b: *std.Build) void {
  3. const target = b.standardTargetOptions(.{});
  4. const optimize = b.standardOptimizeOption(.{});
  5. const exe = b.addExecutable(.{
  6. .name = "drawing_app",
  7. .root_source_file = b.path("src/main.zig"),
  8. .target = target,
  9. .optimize = optimize,
  10. });
  11. // 链接 SDL2 和 SDL2_ttf
  12. exe.linkSystemLibrary("SDL2");
  13. exe.linkSystemLibrary("SDL2_ttf");
  14. exe.linkLibC();
  15. // 安装可执行文件
  16. b.installArtifact(exe);
  17. // 运行命令
  18. const run_cmd = b.addRunArtifact(exe);
  19. run_cmd.step.dependOn(b.getInstallStep());
  20. if (b.args) |args| {
  21. run_cmd.addArgs(args);
  22. }
  23. const run_step = b.step("run", "Run the app");
  24. run_step.dependOn(&run_cmd.step);
  25. }