srctree

Gregory Mullen parent 9dd7110c 99f544a8
fixup build system

build.zig added: 14, removed: 27, total 0
@@ -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",
 
build.zig.zon added: 14, removed: 27, total 0
@@ -5,7 +5,11 @@
.dependencies = .{
.verse = .{
//.url = "git+https://srctree.gr.ht/repo/verse",
.path = "../verse",
// The above URL is the real upstream source but Zig's TLS
// implementation is currently broken so an alt is provided
.url = "git+https://github.com/GrayHatter/verse.git#a5062626b7345c778f25f6aa8e1eae5d332829cf",
.hash = "12201420bbe65aa40a7abd3f67c939a9fa6c9a16dc4e06e0f4941334a02de6c8f800",
// .path = "../verse",
},
},