Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@
const Builder = @import("std").build.Builder;
const std = @import("std");

pub fn build(b: *Builder) void {
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const exe = b.addExecutable(.{
.name = "sdl-zig-demo",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
.name = "sdl_zig_demo",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
if (target.isNativeOs() and target.getOsTag() == .linux) {

if (target.result.os.tag == .linux) {
// The SDL package doesn't work for Linux yet, so we rely on system
// packages for now.
exe.linkSystemLibrary("SDL2");
exe.linkLibC();
} else {
const sdl_dep = b.dependency("sdl", .{
.optimize = .ReleaseFast,
const sdl_dep = b.lazyDependency("SDL", .{
.optimize = .ReleaseSafe,
.target = target,
});
exe.linkLibrary(sdl_dep.artifact("SDL2"));

if (sdl_dep) |sdl| {
exe.linkLibrary(sdl.artifact("SDL2"));
}
}

b.installArtifact(exe);

const run = b.step("run", "Run the demo");
const run_step = b.step("run", "Run the app");

const run_cmd = b.addRunArtifact(exe);
run.dependOn(&run_cmd.step);
run_step.dependOn(&run_cmd.step);

run_cmd.step.dependOn(b.getInstallStep());

if (b.args) |args| {
run_cmd.addArgs(args);
}

const exe_tests = b.addTest(.{
.root_module = exe.root_module,
});

const run_exe_tests = b.addRunArtifact(exe_tests);

const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_exe_tests.step);

}
15 changes: 9 additions & 6 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
.{
.name = "sdl-zig-demo",
.fingerprint = 0xd536f9a26dace7fd,
.name = .sdl_zig_demo,
.version = "0.0.0",
.minimum_zig_version = "0.15.0",
.dependencies = .{
.sdl = .{
.url = "https://github.com/andrewrk/SDL/archive/3eb87f0f5b8d815d5a608b732e1d77f0876712d9.tar.gz",
.hash = "12206de2e590f0866e7d96a5e60dd352ec28c7006c7a883c9ede84e25b6c61c7c088",
.SDL = .{
.url = "git+https://github.com/allyourcodebase/SDL?ref=main#005c64130effb6019c42769d3a277180bdbeb0b2",
.hash = "SDL-2.32.6-JToi32yUEgFuZPcB2O6IbBHHsP2Ul8QuRYh488w2VnMy",
.lazy = true,
},
},
.paths = .{
"LICENSE",
"README.md",
"build.zig",
"build.zig.zon",
"src",
"LICENSE",
"README.md",
},
}