1
1
const std = @import ("std" );
2
2
3
3
pub fn build (b : * std.Build ) void {
4
- const zig_lsp = b .dependency ("zig-lsp" , .{}).module ("zig-lsp" );
5
-
6
4
const target = b .standardTargetOptions (.{});
7
5
const optimize = b .standardOptimizeOption (.{});
8
6
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" ),
12
22
.target = target ,
13
23
.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 ,
14
33
});
15
- exe .root_module .addImport ("zig-lsp" , zig_lsp );
16
34
b .installArtifact (exe );
17
35
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
+
18
44
const run_cmd = b .addRunArtifact (exe );
19
45
run_cmd .step .dependOn (b .getInstallStep ());
20
46
if (b .args ) | args | {
@@ -23,25 +49,4 @@ pub fn build(b: *std.Build) void {
23
49
24
50
const run_step = b .step ("run" , "Run the app" );
25
51
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 );
47
52
}
0 commit comments