From f2315e0c7a68c7bdbb37ec3aa329a2e5ba72425c Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:28:27 +0000 Subject: [PATCH 1/2] Format `zls.json` in setup wizard (#568) --- src/setup.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/setup.zig b/src/setup.zig index 4c43de9..71d20fd 100644 --- a/src/setup.zig +++ b/src/setup.zig @@ -199,7 +199,9 @@ pub fn wizard(allocator: std.mem.Allocator) !void { .operator_completions = operator_completions, .include_at_in_builtins = include_at_in_builtins, .max_detail_length = max_detail_length, - }, .{}, out); + }, .{ + .whitespace = .{}, + }, out); write("successful.\n\n\n\n"); From d83e37d99a7e182f649b33f03eb4886081d9c526 Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Wed, 3 Aug 2022 18:43:34 +0100 Subject: [PATCH 2/2] provide build_runner command on failure (#569) --- src/DocumentStore.zig | 48 +++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/DocumentStore.zig b/src/DocumentStore.zig index 5f75631..6683da5 100644 --- a/src/DocumentStore.zig +++ b/src/DocumentStore.zig @@ -134,24 +134,26 @@ fn loadPackages(context: LoadPackagesContext) !void { defer if (context.build_file_path == null) allocator.free(build_file_path); const directory_path = build_file_path[0 .. build_file_path.len - "build.zig".len]; + const args: []const []const u8 = &[_][]const u8{ + zig_exe_path, + "run", + build_runner_path, + "--cache-dir", + build_runner_cache_path, + "--pkg-begin", + "@build@", + build_file_path, + "--pkg-end", + "--", + zig_exe_path, + directory_path, + context.cache_root, + context.global_cache_root, + }; + const zig_run_result = try std.ChildProcess.exec(.{ .allocator = allocator, - .argv = &[_][]const u8{ - zig_exe_path, - "run", - build_runner_path, - "--cache-dir", - build_runner_cache_path, - "--pkg-begin", - "@build@", - build_file_path, - "--pkg-end", - "--", - zig_exe_path, - directory_path, - context.cache_root, - context.global_cache_root, - }, + .argv = args, }); defer { @@ -159,6 +161,16 @@ fn loadPackages(context: LoadPackagesContext) !void { allocator.free(zig_run_result.stderr); } + errdefer blk: { + const joined = std.mem.join(allocator, " ", args) catch break :blk; + defer allocator.free(joined); + + log.err( + "Failed to execute build runner to collect packages, command:\n{s}\nError: {s}", + .{ joined, zig_run_result.stderr }, + ); + } + switch (zig_run_result.term) { .Exited => |exit_code| { if (exit_code == 0) { @@ -271,7 +283,7 @@ fn newDocument(self: *DocumentStore, uri: []const u8, text: [:0]u8) anyerror!*Ha .cache_root = self.zig_cache_root, .global_cache_root = self.zig_global_cache_root, }) catch |err| { - log.warn("Failed to load packages of build file {s} (error: {})", .{ build_file.uri, err }); + log.err("Failed to load packages of build file {s} (error: {})", .{ build_file.uri, err }); }; try self.build_files.append(self.allocator, build_file); @@ -540,7 +552,7 @@ pub fn applySave(self: *DocumentStore, handle: *Handle) !void { .cache_root = self.zig_cache_root, .global_cache_root = self.zig_global_cache_root, }) catch |err| { - log.warn("Failed to load packages of build file {s} (error: {})", .{ build_file.uri, err }); + log.err("Failed to load packages of build file {s} (error: {})", .{ build_file.uri, err }); }; } }