dotfiles/scripts/withjava/build.zig

38 lines
1 KiB
Zig
Raw 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",
2024-06-21 18:43:42 +02:00
.root_source_file = b.path("src/main.zig"),
2023-07-01 21:28:50 +02:00
.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);
}