Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions tools/sorcerer/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,37 @@ pub fn build(b: *std.Build) void {
});
}

const tree_sitter_diff_dep = b.lazyDependency("tree_sitter_diff", .{
.target = target,
.optimize = optimize,
});
if (tree_sitter_diff_dep) |tsd| {
exe_mod.addIncludePath(tsd.path("src"));
exe_mod.addCSourceFiles(.{
.root = tsd.path(""),
.files = &.{"src/parser.c"},
.flags = &.{"-std=c11"},
});
}

const diffz_dep = b.dependency("diffz", .{
.target = target,
.optimize = optimize,
});
exe_mod.addImport("diffz", diffz_dep.module("diffz"));

const exe = b.addExecutable(.{
.name = "sorcerer",
.root_module = exe_mod,
});
b.installArtifact(exe);

const run_cmd = b.addRunArtifact(exe);
//run_cmd.addArg("--register-schemas");

// I only want the path to the register schema file, not the lazy path,
// because I want to be able to refresh it with `zig build` while sorcerer
// is running. Sorcerer will watch the file for changes and update itself
// automatically.
//run_cmd.addArg(b.getInstallPath(.prefix, register_schema_install.dest_rel_path));
run_cmd.step.dependOn(b.getInstallStep());

if (b.args) |args| {
Expand All @@ -104,6 +121,21 @@ pub fn build(b: *std.Build) void {
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step);

// Diff algorithm unit tests
const diff_test_mod = b.createModule(.{
.root_source_file = b.path("src/test_diff.zig"),
.target = target,
.optimize = optimize,
});
diff_test_mod.addImport("diffz", diffz_dep.module("diffz"));

const diff_tests = b.addTest(.{
.root_module = diff_test_mod,
});

const run_diff_tests = b.addRunArtifact(diff_tests);
test_step.dependOn(&run_diff_tests.step);
}

const TargetWithPath = struct {
Expand Down
8 changes: 8 additions & 0 deletions tools/sorcerer/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
.url = "git+https://github.com/tree-sitter-grammars/tree-sitter-zig#6479aa13f32f701c383083d8b28360ebd682fb7d",
.hash = "tree_sitter_zig-1.1.2-AAAAAJ57XACsD_XBHC4i6G6rnCsZ1dZj7CLRTC09toEB",
},
.tree_sitter_diff = .{
.url = "git+https://github.com/tree-sitter-grammars/tree-sitter-diff#2520c3f934b3179bb540d23e0ef45f75304b5fed",
.hash = "N-V-__8AAAULEwDDBPj9cGOTHPT1iE6oZabnwo70bstgVEf_",
},
.diffz = .{
.url = "git+https://github.com/ziglibs/diffz#a20dd1f11b10819a6f570f98b42e1c91e3704357",
.hash = "diffz-0.0.1-G2tlIQrOAQCfH15jdyaLyrMgV8eGPouFhkCeYFTmJaLk",
},
},
.minimum_zig_version = "0.15.2",
.fingerprint = 0x5f77e0bc82473a35,
Expand Down
Loading
Loading