From 0428b970b18cfe2707e380e7e11a8aeea2420a78 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:34:48 +0000 Subject: [PATCH] place build_runner.zig in cache directory (#635) --- src/Config.zig | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Config.zig b/src/Config.zig index 5211ec1..bb19677 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -202,10 +202,13 @@ pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_crea config.builtin_path = try std.fs.path.join(allocator, &.{ builtin_creation_dir.?, "builtin.zig" }); } + const cache_dir_path = (try known_folders.getPath(allocator, .cache)) orelse { + logger.warn("Known-folders could not fetch the cache path", .{}); + return; + }; + if (null == config.build_runner_path) { - var exe_dir_bytes: [std.fs.MAX_PATH_BYTES]u8 = undefined; - const exe_dir_path = try std.fs.selfExeDirPath(&exe_dir_bytes); - config.build_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ exe_dir_path, "build_runner.zig" }); + config.build_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "build_runner.zig" }); const file = try std.fs.createFileAbsolute(config.build_runner_path.?, .{}); defer file.close(); @@ -214,10 +217,6 @@ pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_crea } if (null == config.global_cache_path) { - const cache_dir_path = (try known_folders.getPath(allocator, .cache)) orelse { - logger.warn("Known-folders could not fetch the cache path", .{}); - return; - }; defer allocator.free(cache_dir_path); config.global_cache_path = try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "zls" }); }