sdl3-sample/build.zig

73 lines
1.9 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const sdl_dep = b.dependency("sdl", .{
.target = target,
.optimize = optimize,
});
const sdl_lib = sdl_dep.artifact("SDL3");
// Create the sdl3-zig module
const sdl3_module = b.createModule(.{
.root_source_file = b.path("sdl3-zig/sdl3.zig"),
.target = target,
.optimize = optimize,
});
// Link SDL library to the module so C imports work
sdl3_module.linkLibrary(sdl_lib);
const exe = b.addExecutable(.{
.name = "sdl3-sample",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
// Add the sdl3 module to the executable
exe.root_module.addImport("sdl3", sdl3_module);
exe.linkLibrary(sdl_lib);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// GPU Sample
const gpu_exe = b.addExecutable(.{
.name = "gpu-sample",
.root_module = b.createModule(.{
.root_source_file = b.path("src/gpu_sample.zig"),
.target = target,
.optimize = optimize,
}),
});
gpu_exe.root_module.addImport("sdl3", sdl3_module);
gpu_exe.linkLibrary(sdl_lib);
b.installArtifact(gpu_exe);
const gpu_run_cmd = b.addRunArtifact(gpu_exe);
gpu_run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
gpu_run_cmd.addArgs(args);
}
const gpu_run_step = b.step("run-gpu", "Run the GPU sample");
gpu_run_step.dependOn(&gpu_run_cmd.step);
}