2021-12-29 21:09:00 +00:00
|
|
|
const std = @import("std");
|
2022-11-30 03:10:29 +00:00
|
|
|
const builtin = @import("builtin");
|
2022-12-15 07:44:17 +00:00
|
|
|
|
2024-09-08 23:17:11 +00:00
|
|
|
const sdl = @import("lib/SDL.zig/build.zig");
|
2024-02-09 05:11:36 +00:00
|
|
|
|
|
|
|
const SemVer = std.SemanticVersion;
|
|
|
|
|
2024-09-08 23:17:11 +00:00
|
|
|
const target_version = "0.13.0";
|
2021-12-29 21:09:00 +00:00
|
|
|
|
2023-03-27 21:22:07 +00:00
|
|
|
pub fn build(b: *std.Build) void {
|
2024-09-08 23:17:11 +00:00
|
|
|
const actual_version = builtin.zig_version;
|
|
|
|
if (comptime actual_version.order(SemVer.parse(target_version) catch unreachable) != .eq) {
|
|
|
|
@compileError("ZBA must be built with Zig v" ++ target_version ++ ".");
|
2022-11-30 03:10:29 +00:00
|
|
|
}
|
|
|
|
|
2021-12-29 21:09:00 +00:00
|
|
|
const target = b.standardTargetOptions(.{});
|
2023-02-03 22:15:25 +00:00
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
2021-12-29 21:09:00 +00:00
|
|
|
|
2023-02-03 22:15:25 +00:00
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = "zba",
|
2024-09-08 23:17:11 +00:00
|
|
|
.root_source_file = b.path("src/main.zig"),
|
2023-02-03 22:15:25 +00:00
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-01-02 19:19:09 +00:00
|
|
|
|
2024-09-08 23:17:11 +00:00
|
|
|
const sdk = sdl.init(b, null, null);
|
2024-03-22 17:53:11 +00:00
|
|
|
const zgui = b.dependency("zgui", .{ .shared = false, .with_implot = true, .backend = .sdl2_opengl3 });
|
|
|
|
const imgui = zgui.artifact("imgui");
|
|
|
|
|
2024-02-09 05:11:36 +00:00
|
|
|
exe.root_module.addImport("known_folders", b.dependency("known-folders", .{}).module("known-folders")); // https://github.com/ziglibs/known-folders
|
|
|
|
exe.root_module.addImport("datetime", b.dependency("zig-datetime", .{}).module("zig-datetime")); // https://github.com/frmdstryr/zig-datetime
|
|
|
|
exe.root_module.addImport("clap", b.dependency("zig-clap", .{}).module("clap")); // https://github.com/Hejsil/zig-clap
|
|
|
|
exe.root_module.addImport("zba-util", b.dependency("zba-util", .{}).module("zba-util")); // https://git.musuka.dev/paoda/zba-util
|
|
|
|
exe.root_module.addImport("tomlz", b.dependency("tomlz", .{}).module("tomlz")); // https://github.com/mattyhall/tomlz
|
|
|
|
exe.root_module.addImport("arm32", b.dependency("arm32", .{}).module("arm32")); // https://git.musuka.dev/paoda/arm32
|
2024-09-08 23:17:11 +00:00
|
|
|
exe.root_module.addImport("gdbstub", b.dependency("zba-gdbstub", .{}).module("zba-gdbstub")); // https://git.musuka.dev/paoda/gdbstub
|
2024-02-09 05:11:36 +00:00
|
|
|
exe.root_module.addImport("nfd", b.dependency("nfd", .{}).module("nfd")); // https://github.com/fabioarnold/nfd-zig
|
2024-03-22 17:53:11 +00:00
|
|
|
exe.root_module.addImport("zgui", zgui.module("root")); // https://git.musuka.dev/paoda/zgui
|
2024-09-08 23:17:11 +00:00
|
|
|
exe.root_module.addImport("sdl2", sdk.getNativeModule()); // https://github.com/MasterQ32/SDL.zig
|
2023-12-15 08:35:33 +00:00
|
|
|
|
2024-09-08 23:17:11 +00:00
|
|
|
exe.root_module.addAnonymousImport("bitfield", .{ .root_source_file = b.path("lib/bitfield.zig") }); // https://github.com/FlorenceOS/
|
|
|
|
exe.root_module.addAnonymousImport("gl", .{ .root_source_file = b.path("lib/gl.zig") }); // https://github.com/MasterQ32/zig-opengl
|
|
|
|
exe.root_module.addAnonymousImport("example.toml", .{ .root_source_file = b.path("example.toml") });
|
2022-09-16 12:32:52 +00:00
|
|
|
|
2024-09-08 23:17:11 +00:00
|
|
|
sdk.link(exe, .dynamic, .SDL2);
|
|
|
|
sdk.link(imgui, .dynamic, .SDL2);
|
2024-03-22 17:53:11 +00:00
|
|
|
exe.linkLibrary(imgui);
|
2023-06-19 16:14:21 +00:00
|
|
|
|
2023-04-14 03:14:31 +00:00
|
|
|
b.installArtifact(exe);
|
2021-12-29 21:09:00 +00:00
|
|
|
|
2023-04-14 03:14:31 +00:00
|
|
|
const run_cmd = b.addRunArtifact(exe);
|
2021-12-29 21:09:00 +00:00
|
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
2024-02-09 05:11:36 +00:00
|
|
|
if (b.args) |args| run_cmd.addArgs(args);
|
2021-12-29 21:09:00 +00:00
|
|
|
|
|
|
|
const run_step = b.step("run", "Run the app");
|
|
|
|
run_step.dependOn(&run_cmd.step);
|
|
|
|
|
2023-02-03 22:15:25 +00:00
|
|
|
const exe_tests = b.addTest(.{
|
2024-09-08 23:17:11 +00:00
|
|
|
.root_source_file = b.path("src/main.zig"),
|
2023-02-03 22:15:25 +00:00
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2021-12-29 21:09:00 +00:00
|
|
|
|
|
|
|
const test_step = b.step("test", "Run unit tests");
|
|
|
|
test_step.dependOn(&exe_tests.step);
|
|
|
|
}
|