Skip to content

Commit 3459775

Browse files
authored
View diffs of patch operations in Sorcerer (#891)
1 parent ff45d4f commit 3459775

5 files changed

Lines changed: 1012 additions & 9 deletions

File tree

tools/sorcerer/build.zig

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,37 @@ pub fn build(b: *std.Build) void {
7474
});
7575
}
7676

77+
const tree_sitter_diff_dep = b.lazyDependency("tree_sitter_diff", .{
78+
.target = target,
79+
.optimize = optimize,
80+
});
81+
if (tree_sitter_diff_dep) |tsd| {
82+
exe_mod.addIncludePath(tsd.path("src"));
83+
exe_mod.addCSourceFiles(.{
84+
.root = tsd.path(""),
85+
.files = &.{"src/parser.c"},
86+
.flags = &.{"-std=c11"},
87+
});
88+
}
89+
90+
const diffz_dep = b.dependency("diffz", .{
91+
.target = target,
92+
.optimize = optimize,
93+
});
94+
exe_mod.addImport("diffz", diffz_dep.module("diffz"));
95+
7796
const exe = b.addExecutable(.{
7897
.name = "sorcerer",
7998
.root_module = exe_mod,
8099
});
81100
b.installArtifact(exe);
82101

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

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

93110
if (b.args) |args| {
@@ -104,6 +121,21 @@ pub fn build(b: *std.Build) void {
104121
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
105122
const test_step = b.step("test", "Run unit tests");
106123
test_step.dependOn(&run_exe_unit_tests.step);
124+
125+
// Diff algorithm unit tests
126+
const diff_test_mod = b.createModule(.{
127+
.root_source_file = b.path("src/test_diff.zig"),
128+
.target = target,
129+
.optimize = optimize,
130+
});
131+
diff_test_mod.addImport("diffz", diffz_dep.module("diffz"));
132+
133+
const diff_tests = b.addTest(.{
134+
.root_module = diff_test_mod,
135+
});
136+
137+
const run_diff_tests = b.addRunArtifact(diff_tests);
138+
test_step.dependOn(&run_diff_tests.step);
107139
}
108140

109141
const TargetWithPath = struct {

tools/sorcerer/build.zig.zon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
.url = "git+https://github.com/tree-sitter-grammars/tree-sitter-zig#6479aa13f32f701c383083d8b28360ebd682fb7d",
1818
.hash = "tree_sitter_zig-1.1.2-AAAAAJ57XACsD_XBHC4i6G6rnCsZ1dZj7CLRTC09toEB",
1919
},
20+
.tree_sitter_diff = .{
21+
.url = "git+https://github.com/tree-sitter-grammars/tree-sitter-diff#2520c3f934b3179bb540d23e0ef45f75304b5fed",
22+
.hash = "N-V-__8AAAULEwDDBPj9cGOTHPT1iE6oZabnwo70bstgVEf_",
23+
},
24+
.diffz = .{
25+
.url = "git+https://github.com/ziglibs/diffz#a20dd1f11b10819a6f570f98b42e1c91e3704357",
26+
.hash = "diffz-0.0.1-G2tlIQrOAQCfH15jdyaLyrMgV8eGPouFhkCeYFTmJaLk",
27+
},
2028
},
2129
.minimum_zig_version = "0.15.2",
2230
.fingerprint = 0x5f77e0bc82473a35,

0 commit comments

Comments
 (0)