Merge pull request #646 from Techatrix/cache-build-runner
Place build_runner.zig in zls subfolder
This commit is contained in:
		
						commit
						6363e7a064
					
				@ -202,13 +202,24 @@ 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.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" });
 | 
			
		||||
 | 
			
		||||
        std.fs.makeDirAbsolute(config.global_cache_path.?) catch |err| switch(err) {
 | 
			
		||||
            error.PathAlreadyExists => {},
 | 
			
		||||
            else => return err,
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (null == config.build_runner_path) {
 | 
			
		||||
        config.build_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "build_runner.zig" });
 | 
			
		||||
        config.build_runner_path = try std.fs.path.resolve(allocator, &[_][]const u8{ config.global_cache_path.?, "build_runner.zig" });
 | 
			
		||||
 | 
			
		||||
        const file = try std.fs.createFileAbsolute(config.build_runner_path.?, .{});
 | 
			
		||||
        defer file.close();
 | 
			
		||||
@ -216,8 +227,4 @@ pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_crea
 | 
			
		||||
        try file.writeAll(@embedFile("special/build_runner.zig"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (null == config.global_cache_path) {
 | 
			
		||||
        defer allocator.free(cache_dir_path);
 | 
			
		||||
        config.global_cache_path = try std.fs.path.resolve(allocator, &[_][]const u8{ cache_dir_path, "zls" });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user