52 lines
1.8 KiB
Zig
52 lines
1.8 KiB
Zig
const std = @import("std");
|
|
|
|
const Build = @import("std").Build;
|
|
|
|
pub fn build(b: *Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
const exe = b.addExecutable(.{
|
|
.name = "zsdl",
|
|
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/main.zig" } },
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
const sdl_dep = b.dependency("SDL", .{
|
|
.optimize = .ReleaseFast,
|
|
.target = target,
|
|
});
|
|
const sdl_lib = sdl_dep.artifact("SDL2");
|
|
exe.root_module.addIncludePath(sdl_lib.getEmittedIncludeTree().path(b, "SDL2"));
|
|
exe.linkLibrary(sdl_lib);
|
|
const sdl_ttf_dep = b.dependency("SDL_ttf", .{
|
|
.optimize = .ReleaseFast,
|
|
.target = target,
|
|
});
|
|
exe.linkLibrary(sdl_ttf_dep.artifact("SDL2_ttf"));
|
|
const sdl_image_dep = b.dependency("SDL_image", .{
|
|
.optimize = .ReleaseFast,
|
|
.target = target,
|
|
});
|
|
exe.linkLibrary(sdl_image_dep.artifact("SDL2_image"));
|
|
b.installArtifact(exe);
|
|
|
|
// Create Check step for zls
|
|
const exe_check = b.addExecutable(.{
|
|
.name = "zsdl",
|
|
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/main.zig" } },
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
exe_check.root_module.addIncludePath(sdl_lib.getEmittedIncludeTree().path(b, "SDL2"));
|
|
exe_check.linkLibrary(sdl_lib);
|
|
exe_check.linkLibrary(sdl_ttf_dep.artifact("SDL2_ttf"));
|
|
exe_check.linkLibrary(sdl_image_dep.artifact("SDL2_image"));
|
|
const check = b.step("check", "Check if project compiles, used by Zig Language Server");
|
|
check.dependOn(&exe_check.step);
|
|
|
|
const run = b.step("run", "Run the demo");
|
|
const run_cmd = b.addRunArtifact(exe);
|
|
run.dependOn(&run_cmd.step);
|
|
}
|