49 lines
1.2 KiB
Zig
49 lines
1.2 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);
|
|
}
|