99 lines
2.9 KiB
Zig
99 lines
2.9 KiB
Zig
const std = @import("std");
|
|
const ResolvedTarget = std.Build.ResolvedTarget;
|
|
const OptimizeMode = std.Build.OptimizeMode;
|
|
const Module = std.Build.Module;
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
var api: *Module = undefined;
|
|
{
|
|
const s2s_dep = b.dependency("s2s", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
api = b.createModule(.{
|
|
.root_source_file = b.path("api/root.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.link_libc = true,
|
|
});
|
|
api.addIncludePath(b.path("api/date_time"));
|
|
api.addCSourceFile(.{ .file = b.path("api/date_time/timegm.c") });
|
|
api.addImport("s2s", s2s_dep.module("s2s"));
|
|
}
|
|
|
|
var lib: *Module = undefined;
|
|
{
|
|
lib = b.createModule(.{
|
|
.root_source_file = b.path("lib/root.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
lib.addImport("artifacts-api", api);
|
|
|
|
const unit_tests = b.addTest(.{
|
|
.root_source_file = b.path("lib/root.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
const run_unit_tests = b.addRunArtifact(unit_tests);
|
|
const test_step = b.step("test-lib", "Run lib unit tests");
|
|
test_step.dependOn(&run_unit_tests.step);
|
|
}
|
|
|
|
{
|
|
const cli = b.addExecutable(.{
|
|
.name = "artificer",
|
|
.root_source_file = b.path("cli/main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
cli.root_module.addImport("artificer", lib);
|
|
cli.root_module.addImport("artifacts-api", api);
|
|
b.installArtifact(cli);
|
|
|
|
const run_cmd = b.addRunArtifact(cli);
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
if (b.args) |args| {
|
|
run_cmd.addArgs(args);
|
|
}
|
|
|
|
const run_step = b.step("run-cli", "Run the CLI");
|
|
run_step.dependOn(&run_cmd.step);
|
|
}
|
|
|
|
{
|
|
const raylib_dep = b.dependency("raylib-zig", .{
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
const gui = b.addExecutable(.{
|
|
.name = "artificer-gui",
|
|
.root_source_file = b.path("gui/main.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
gui.root_module.addImport("artificer", lib);
|
|
gui.linkLibrary(raylib_dep.artifact("raylib"));
|
|
gui.root_module.addImport("raylib", raylib_dep.module("raylib"));
|
|
|
|
b.installArtifact(gui);
|
|
|
|
const run_cmd = b.addRunArtifact(gui);
|
|
run_cmd.step.dependOn(b.getInstallStep());
|
|
|
|
if (b.args) |args| {
|
|
run_cmd.addArgs(args);
|
|
}
|
|
|
|
const run_step = b.step("run-gui", "Run the GUI");
|
|
run_step.dependOn(&run_cmd.step);
|
|
}
|
|
}
|