dotfiles/scripts/withjava/build.zig

38 lines
1 KiB
Zig
Raw Permalink Normal View History

2023-07-01 21:28:50 +02:00
const std = @import("std");
2024-04-10 18:03:17 +02:00
const common = @import("common");
2023-07-01 21:28:50 +02:00
2024-04-10 18:03:17 +02:00
pub fn build(b: *std.Build) !void {
2023-07-01 21:28:50 +02:00
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "withjava",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
2024-04-10 18:03:17 +02:00
const cgopt = try common.confgenGet(struct {
nix: struct {
jvm: ?[:0]const u8 = null,
},
}, b.allocator);
const opts = b.addOptions();
opts.addOption(?[:0]const u8, "jvm", cgopt.nix.jvm);
2024-03-20 20:45:59 +01:00
exe.root_module.addImport("common", b.dependency("common", .{}).module("common"));
2024-04-10 18:03:17 +02:00
exe.root_module.addImport("opts", opts.createModule());
2024-03-20 20:45:59 +01:00
2023-07-01 21:28:50 +02:00
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}