place build_runner.zig in cache directory (#635)

This commit is contained in:
Techatrix 2022-09-07 17:34:48 +00:00 committed by GitHub
parent 6269eef776
commit 0428b970b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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" }); 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) { if (null == config.build_runner_path) {
var exe_dir_bytes: [std.fs.MAX_PATH_BYTES]u8 = undefined; config.build_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "build_runner.zig" });
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" });
const file = try std.fs.createFileAbsolute(config.build_runner_path.?, .{}); const file = try std.fs.createFileAbsolute(config.build_runner_path.?, .{});
defer file.close(); defer file.close();
@ -214,10 +217,6 @@ pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_crea
} }
if (null == config.global_cache_path) { 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); defer allocator.free(cache_dir_path);
config.global_cache_path = try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "zls" }); config.global_cache_path = try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "zls" });
} }