11const std = @import ("std" );
22
33pub fn build (b : * std.Build ) void {
4- const zig_lsp = b .dependency ("zig-lsp" , .{}).module ("zig-lsp" );
5-
64 const target = b .standardTargetOptions (.{});
75 const optimize = b .standardOptimizeOption (.{});
86
9- const exe = b .addExecutable (.{
10- .name = "sus" ,
11- .root_source_file = .{ .path = "src/main.zig" },
7+ const block_len = b .option (
8+ u8 ,
9+ "block-len" ,
10+ "how many bytes to consider when predicting the next character. " ++
11+ "defaults to 8. " ++
12+ "note: this may affect performance." ,
13+ ) orelse 8 ;
14+
15+ const options = b .addOptions ();
16+ options .addOption (u8 , "block_len" , block_len );
17+
18+ const lsp_module = b .dependency ("lsp_kit" , .{}).module ("lsp" );
19+
20+ const root_module = b .createModule (.{
21+ .root_source_file = b .path ("src/main.zig" ),
1222 .target = target ,
1323 .optimize = optimize ,
24+ .imports = &.{
25+ .{ .name = "lsp" , .module = lsp_module },
26+ .{ .name = "build_options" , .module = options .createModule () },
27+ },
28+ });
29+
30+ const exe = b .addExecutable (.{
31+ .name = "sus" ,
32+ .root_module = root_module ,
1433 });
15- exe .root_module .addImport ("zig-lsp" , zig_lsp );
1634 b .installArtifact (exe );
1735
36+ const exe_check = b .addExecutable (.{
37+ .name = "zls" ,
38+ .root_module = root_module ,
39+ });
40+
41+ const check = b .step ("check" , "Check if sus compiles" );
42+ check .dependOn (& exe_check .step );
43+
1844 const run_cmd = b .addRunArtifact (exe );
1945 run_cmd .step .dependOn (b .getInstallStep ());
2046 if (b .args ) | args | {
@@ -23,25 +49,4 @@ pub fn build(b: *std.Build) void {
2349
2450 const run_step = b .step ("run" , "Run the app" );
2551 run_step .dependOn (& run_cmd .step );
26-
27- const build_exe_tests = b .addTest (.{
28- .root_source_file = .{ .path = "src/main.zig" },
29- .target = target ,
30- .optimize = .Debug ,
31- });
32- const run_exe_tests = b .addRunArtifact (build_exe_tests );
33-
34- const test_step = b .step ("test" , "Run unit tests" );
35- test_step .dependOn (& run_exe_tests .step );
36-
37- const block_len = b .option (
38- u8 ,
39- "block-len" ,
40- "how many bytes to consider when predicting the next character. " ++
41- "defaults to 8. " ++
42- "note: this may affect performance." ,
43- ) orelse 8 ;
44- const options = b .addOptions ();
45- options .addOption (u8 , "block_len" , block_len );
46- exe .root_module .addOptions ("build_options" , options );
4752}
0 commit comments