@@ -10,20 +10,20 @@ pub fn build(b: *std.Build) void {
const options = b.addOptions();
options.addOption(bool, "libcurl", enable_libcurl);
var bins = std.ArrayList(*std.Build.Step.Compile).init(b.allocator);
defer bins.clearAndFree();
// Dependencies
const verse = b.dependency("verse", .{
.target = target,
.optimize = optimize,
});
// Set up verse
const comptime_templates = Compiler.buildTemplates(b, "templates") catch unreachable;
const comptime_structs = Compiler.buildStructs(b, "templates") catch unreachable;
const verse_module = verse.module("verse");
verse_module.addImport("comptime_templates", comptime_templates);
verse_module.addImport("comptime_structs", comptime_structs);
// srctree
const exe = b.addExecutable(.{
.name = "srctree",
.root_source_file = b.path("src/main.zig"),
@@ -31,11 +31,10 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
b.installArtifact(exe);
bins.append(exe) catch unreachable;
exe.root_module.addOptions("config", options);
exe.root_module.addImport("verse", verse_module);
//exe.linkLibrary(verse.artifact("verse"));
// build run
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
@@ -44,34 +43,18 @@ pub fn build(b: *std.Build) void {
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// srctree tests
const unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
unit_tests.root_module.addOptions("config", options);
unit_tests.root_module.addImport("verse", verse_module);
bins.append(unit_tests) catch unreachable;
for (bins.items) |ex| {
ex.root_module.addImport("comptime_templates", comptime_templates);
ex.root_module.addImport("comptime_structs", comptime_templates);
ex.root_module.addOptions("config", options);
if (enable_libcurl) {
ex.linkSystemLibrary2("curl", .{ .preferred_link_mode = .static });
ex.linkLibC();
}
}
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
//for (bins.items) |bin| bin.root_module.addImport("comptime_template_structs", b.addModule(
// "comptime_template_structs",
// .{ .root_source_file = tc_structs },
//));
// Partner Binaries
const mailer = b.addExecutable(.{
.name = "srctree-mailer",