Files
zig-experiments/hotswap/build.zig
David Allemang 32954bb7ac Add 'hotswap/' from commit '5487901d10f5a7ed200b2fbfe0a5b5cd730ba3a9'
git-subtree-dir: hotswap
git-subtree-mainline: 614695d55b
git-subtree-split: 5487901d10
2025-08-04 22:14:43 -04:00

48 lines
1.4 KiB
Zig

const std = @import("std");
pub fn installModule(b: *std.Build, plug: *std.Build.Step.Compile) void {
std.debug.assert(plug.isDynamicLibrary());
const install = b.addInstallArtifact(plug, .{
.dest_dir = .{ .override = .{ .custom = "mods" } },
});
b.getInstallStep().dependOn(&install.step);
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exedriver = b.addExecutable(.{
.name = "driver",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
b.installArtifact(exedriver);
const libfoo = b.addSharedLibrary(.{
.name = "foo",
.root_source_file = b.path("src/foo.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
installModule(b, libfoo);
const libbar = b.addSharedLibrary(.{
.name = "bar",
.root_source_file = b.path("src/bar.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
installModule(b, libbar);
const run = b.addRunArtifact(exedriver);
run.step.dependOn(b.getInstallStep());
run.setEnvironmentVariable("MODS_DIR", b.getInstallPath(.{ .custom = "mods" }, ""));
b.step("run", "").dependOn(&run.step);
}