Skip to content

Commit d732b05

Browse files
authored
update to zig 0.16.0-dev.1976+8e091047b
2 parents 26e0192 + 3fbfb8f commit d732b05

17 files changed

+178
-162
lines changed

build.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const zls_version = std.SemanticVersion.parse(@import("build.zig.zon").version)
66
const minimum_build_zig_version = @import("build.zig.zon").minimum_zig_version;
77

88
/// Specify the minimum Zig version that is usable with ZLS:
9-
/// std.Io.Threaded: performance enhancements, bugfixes, and better Windows and NetBSD support
9+
/// std: delete `os.environ`, `os.argv`, add new parameter to `main`, move process API to `std.Io`
1010
///
1111
/// A breaking change to the Zig Build System should be handled by updating ZLS's build runner (see src\build_runner)
12-
const minimum_runtime_zig_version = "0.16.0-dev.1910+8226d706e";
12+
const minimum_runtime_zig_version = "0.16.0-dev.1974+de25a6ffe";
1313

1414
const release_targets = [_]std.Target.Query{
1515
.{ .cpu_arch = .aarch64, .os_tag = .linux },
@@ -345,7 +345,7 @@ fn getVersion(b: *Build) std.SemanticVersion {
345345
"git", "-C", b.pathFromRoot("."), "--git-dir", ".git", "describe", "--match", "*.*.*", "--tags",
346346
};
347347
var code: u8 = undefined;
348-
const git_describe_untrimmed = b.runAllowFail(argv, &code, .Ignore) catch |err| {
348+
const git_describe_untrimmed = b.runAllowFail(argv, &code, .ignore) catch |err| {
349349
const argv_joined = std.mem.join(b.allocator, " ", argv) catch @panic("OOM");
350350
std.log.warn(
351351
\\Failed to run git describe to resolve ZLS version: {}

build.zig.zon

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// nix flake update --commit-lock-file
1111
// ```
1212
// If you do not use Nix, a ZLS maintainer can take care of this.
13-
.minimum_zig_version = "0.16.0-dev.1912+0cbaaa5eb",
13+
.minimum_zig_version = "0.16.0-dev.1976+8e091047b",
1414
// If you do not use Nix, a ZLS maintainer can take care of this.
1515
// Whenever the dependencies are updated, run the following command:
1616
// ```bash
@@ -19,16 +19,16 @@
1919
// The `deps.nix` should also be updated to not fetch `tracy`.
2020
.dependencies = .{
2121
.known_folders = .{
22-
.url = "https://github.com/ziglibs/known-folders/archive/ffe1e44e1e7fa5dcac0ce5da1cd91e52cf054107.tar.gz",
23-
.hash = "known_folders-0.0.0-Fy-PJoPNAACH-fVI5tF-Z9GpkQke98LCVU01rxv09Kwy",
22+
.url = "https://github.com/ziglibs/known-folders/archive/84bfe726c8f94bb8e90ac2e96a6949b794a185a0.tar.gz",
23+
.hash = "known_folders-0.0.0-Fy-PJs_KAAAI2L9hC8gAY7Zwc_-QkeC6nN2n5xuSOaUQ",
2424
},
2525
.diffz = .{
2626
.url = "https://github.com/ziglibs/diffz/archive/669e6ed7470100bfd9d2aa9f6f96b93c45996179.tar.gz",
2727
.hash = "diffz-0.0.1-G2tlISLPAQDzXkUIRWWUfdgIsIb1dAyVwRPXMt5kRpui",
2828
},
2929
.lsp_kit = .{
30-
.url = "https://github.com/zigtools/lsp-kit/archive/1d4a41092286029f541082fe15fc45f0bbf1d210.tar.gz",
31-
.hash = "lsp_kit-0.1.0-bi_PL7stDADM03s6vUGZPk4GsWNC7BruKNsrn3ukhFI_",
30+
.url = "https://github.com/zigtools/lsp-kit/archive/f34a177f3a9bd7c0328c468889316868b884e84e.tar.gz",
31+
.hash = "lsp_kit-0.1.0-bi_PL8gtDADzuOHLTfjrx-LNFVzWF5GIx-lMKjWMjQAU",
3232
},
3333
.tracy = .{
3434
.url = "https://github.com/wolfpld/tracy/archive/refs/tags/v0.13.1.tar.gz",

deps.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ linkFarm "zig-packages" [
1111
};
1212
}
1313
{
14-
name = "known_folders-0.0.0-Fy-PJoPNAACH-fVI5tF-Z9GpkQke98LCVU01rxv09Kwy";
14+
name = "known_folders-0.0.0-Fy-PJs_KAAAI2L9hC8gAY7Zwc_-QkeC6nN2n5xuSOaUQ";
1515
path = fetchzip {
16-
url = "https://github.com/ziglibs/known-folders/archive/ffe1e44e1e7fa5dcac0ce5da1cd91e52cf054107.tar.gz";
17-
hash = "sha256-PJZXupqVmzDKWX07f0h6Z7x4d0U2pXCNHlASsIj8ssA=";
16+
url = "https://github.com/ziglibs/known-folders/archive/84bfe726c8f94bb8e90ac2e96a6949b794a185a0.tar.gz";
17+
hash = "sha256-KB2zvnQPF4Lk9oGNModmqdWhHZBSO2VIpsbhj8/5FxA=";
1818
};
1919
}
2020
{
21-
name = "lsp_kit-0.1.0-bi_PL7stDADM03s6vUGZPk4GsWNC7BruKNsrn3ukhFI_";
21+
name = "lsp_kit-0.1.0-bi_PL8gtDADzuOHLTfjrx-LNFVzWF5GIx-lMKjWMjQAU";
2222
path = fetchzip {
23-
url = "https://github.com/zigtools/lsp-kit/archive/1d4a41092286029f541082fe15fc45f0bbf1d210.tar.gz";
24-
hash = "sha256-ko8SvkpOt1H+9DDDVzrRZdiZRXcG4TjK9D/78PL0Lk0=";
23+
url = "https://github.com/zigtools/lsp-kit/archive/f34a177f3a9bd7c0328c468889316868b884e84e.tar.gz";
24+
hash = "sha256-97Qf3v3v6jwwxfFsgdgkKQtI9TAd8BYQuq4r5v5GTLo=";
2525
};
2626
}
2727
]

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DocumentStore.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub fn computeHash(bytes: []const u8) Hash {
5151
}
5252

5353
pub const Config = struct {
54+
environ_map: *const std.process.Environ.Map,
5455
zig_exe_path: ?[]const u8,
5556
zig_lib_dir: ?std.Build.Cache.Directory,
5657
build_runner_path: ?[]const u8,
@@ -1108,7 +1109,7 @@ fn loadBuildConfiguration(self: *DocumentStore, build_file_uri: Uri, build_file_
11081109
const zig_run_result = blk: {
11091110
const tracy_zone2 = tracy.trace(@src());
11101111
defer tracy_zone2.end();
1111-
break :blk try std.process.Child.run(
1112+
break :blk try std.process.run(
11121113
self.allocator,
11131114
self.io,
11141115
.{
@@ -1122,7 +1123,7 @@ fn loadBuildConfiguration(self: *DocumentStore, build_file_uri: Uri, build_file_
11221123
defer self.allocator.free(zig_run_result.stderr);
11231124

11241125
const is_ok = switch (zig_run_result.term) {
1125-
.Exited => |exit_code| exit_code == 0,
1126+
.exited => |exit_code| exit_code == 0,
11261127
else => false,
11271128
};
11281129

@@ -1495,7 +1496,8 @@ pub fn collectIncludeDirs(
14951496
.ofmt = comptime std.Target.ObjectFormat.default(builtin.os.tag, builtin.cpu.arch),
14961497
.dynamic_linker = std.Target.DynamicLinker.none,
14971498
};
1498-
const native_paths: std.zig.system.NativePaths = try .detect(arena_allocator.allocator(), store.io, &target_info);
1499+
const arena_allocator_allocator = arena_allocator.allocator();
1500+
const native_paths: std.zig.system.NativePaths = try .detect(arena_allocator_allocator, store.io, &target_info, @constCast(store.config.environ_map));
14991501

15001502
try include_dirs.ensureUnusedCapacity(allocator, native_paths.include_dirs.items.len);
15011503
for (native_paths.include_dirs.items) |native_include_dir| {

src/Server.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ pub fn resolveConfiguration(server: *Server) error{OutOfMemory}!void {
11161116

11171117
fn createDocumentStoreConfig(config_manager: *const configuration.Manager) DocumentStore.Config {
11181118
return .{
1119+
.environ_map = config_manager.environ_map,
11191120
.zig_exe_path = config_manager.config.zig_exe_path,
11201121
.zig_lib_dir = config_manager.zig_lib_dir,
11211122
.build_runner_path = config_manager.config.build_runner_path,

src/build_runner/build_runner.zig

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub const std_options: std.Options = .{
3636

3737
///! This is a modified build runner to extract information out of build.zig
3838
///! Modified version of lib/build_runner.zig
39-
pub fn main() !void {
39+
pub fn main(init: process.Init.Minimal) !void {
4040
// Here we use an ArenaAllocator backed by a DirectAllocator because a build is a short-lived,
4141
// one shot program. We don't need to waste time freeing memory and finding places to squish
4242
// bytes into. So we free everything all at once at the very end.
@@ -48,9 +48,12 @@ pub fn main() !void {
4848
};
4949
const arena = thread_safe_arena.allocator();
5050

51-
const args = try process.argsAlloc(arena);
51+
const args = try init.args.toSlice(arena);
5252

53-
var threaded: std.Io.Threaded = .init(arena, .{});
53+
var threaded: std.Io.Threaded = .init(arena, .{
54+
.environ = init.environ,
55+
.argv0 = .init(init.args),
56+
});
5457
defer threaded.deinit();
5558
const io = threaded.ioBasic();
5659

@@ -92,9 +95,10 @@ pub fn main() !void {
9295
.io = io,
9396
.gpa = arena,
9497
.manifest_dir = try local_cache_directory.handle.createDirPathOpen(io, "h", .{}),
98+
.cwd = try process.getCwdAlloc(single_threaded_arena.allocator()),
9599
},
96100
.zig_exe = zig_exe,
97-
.env_map = try process.getEnvMap(arena),
101+
.environ_map = try init.environ.createMap(arena),
98102
.global_cache_root = global_cache_directory,
99103
.zig_lib_directory = zig_lib_directory,
100104
.host = .{
@@ -388,7 +392,7 @@ pub fn main() !void {
388392
return;
389393
}
390394

391-
var w = try Watch.init(io);
395+
var w = try Watch.init(io, graph.cache.cwd);
392396

393397
const message_thread = try std.Thread.spawn(.{}, struct {
394398
fn do(ww: *Watch) void {
@@ -475,10 +479,10 @@ const Watch = struct {
475479
manual_event: std.Io.Event,
476480
steps: []const *Step,
477481

478-
fn init(io: std.Io) !Watch {
482+
fn init(io: std.Io, cwd_path: []const u8) !Watch {
479483
return .{
480484
.io = io,
481-
.fs_watch = if (@TypeOf(std.Build.Watch) != void) try std.Build.Watch.init() else {},
485+
.fs_watch = if (@TypeOf(std.Build.Watch) != void) try std.Build.Watch.init(cwd_path) else {},
482486
.supports_fs_watch = @TypeOf(std.Build.Watch) != void and shared.BuildOnSaveSupport.isSupportedRuntime(builtin.zig_version) == .supported,
483487
.manual_event = .unset,
484488
.steps = &.{},
@@ -1395,7 +1399,7 @@ const copied_from_zig = struct {
13951399
pkg_name,
13961400
"--cflags",
13971401
"--libs",
1398-
}, &code, .Ignore)) |stdout| stdout else |err| switch (err) {
1402+
}, &code, .ignore)) |stdout| stdout else |err| switch (err) {
13991403
error.ProcessTerminated => return error.PkgConfigCrashed,
14001404
error.ExecNotSupported => return error.PkgConfigFailed,
14011405
error.ExitCodeFailure => return error.PkgConfigFailed,
@@ -1437,7 +1441,7 @@ const copied_from_zig = struct {
14371441
}
14381442

14391443
fn execPkgConfigList(self: *std.Build, out_code: *u8) (std.Build.PkgConfigError || std.Build.RunError)![]const std.Build.PkgConfigPkg {
1440-
const stdout = try self.runAllowFail(&.{ "pkg-config", "--list-all" }, out_code, .Ignore);
1444+
const stdout = try self.runAllowFail(&.{ "pkg-config", "--list-all" }, out_code, .ignore);
14411445
var list = ArrayListManaged(std.Build.PkgConfigPkg).init(self.allocator);
14421446
errdefer list.deinit();
14431447
var line_it = mem.tokenizeAny(u8, stdout, "\r\n");

src/configuration.zig

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const log = std.log.scoped(.config);
1010
pub const Manager = struct {
1111
io: std.Io,
1212
allocator: std.mem.Allocator,
13+
environ_map: *const std.process.Environ.Map,
1314
config: Config,
1415
zig_exe: ?struct {
1516
/// Same as `Manager.config.zig_exe_path.?`
@@ -41,10 +42,11 @@ pub const Manager = struct {
4142
arena: std.heap.ArenaAllocator.State,
4243
},
4344

44-
pub fn init(io: std.Io, allocator: std.mem.Allocator) error{OutOfMemory}!Manager {
45+
pub fn init(io: std.Io, allocator: std.mem.Allocator, environ_map: *const std.process.Environ.Map) error{OutOfMemory}!Manager {
4546
return .{
4647
.io = io,
4748
.allocator = allocator,
49+
.environ_map = environ_map,
4850
.zig_exe = null,
4951
.zig_lib_dir = null,
5052
.global_cache_dir = null,
@@ -169,7 +171,7 @@ pub const Manager = struct {
169171

170172
if (config.zig_exe_path == null) blk: {
171173
if (!std.process.can_spawn) break :blk;
172-
const zig_exe_path = try findZig(io, manager.allocator) orelse break :blk;
174+
const zig_exe_path = try findZig(io, manager.allocator, manager.environ_map) orelse break :blk;
173175
defer manager.allocator.free(zig_exe_path);
174176
config.zig_exe_path = try arena.dupe(u8, zig_exe_path);
175177
}
@@ -320,7 +322,7 @@ pub const Manager = struct {
320322
"--show-builtin",
321323
};
322324

323-
const run_result = std.process.Child.run(
325+
const run_result = std.process.run(
324326
manager.allocator,
325327
io,
326328
.{
@@ -565,7 +567,7 @@ pub fn getZigEnv(
565567
result_arena: std.mem.Allocator,
566568
zig_exe_path: []const u8,
567569
) error{OutOfMemory}!?Env {
568-
const zig_env_result = std.process.Child.run(
570+
const zig_env_result = std.process.run(
569571
allocator,
570572
io,
571573
.{ .argv = &.{ zig_exe_path, "env" } },
@@ -580,7 +582,7 @@ pub fn getZigEnv(
580582
}
581583

582584
switch (zig_env_result.term) {
583-
.Exited => |code| {
585+
.exited => |code| {
584586
if (code != 0) {
585587
log.err("zig env command exited with error code {d}.", .{code});
586588
if (zig_env_result.stderr.len != 0) {
@@ -589,7 +591,7 @@ pub fn getZigEnv(
589591
return null;
590592
}
591593
},
592-
.Signal, .Stopped, .Unknown => {
594+
.signal, .stopped, .unknown => {
593595
log.err("zig env command terminated unexpectedly.", .{});
594596
if (zig_env_result.stderr.len != 0) {
595597
log.err("stderr: {s}", .{zig_env_result.stderr});
@@ -685,29 +687,15 @@ pub const DidConfigChange = @Struct(
685687
&@splat(.{ .default_value_ptr = &false }),
686688
);
687689

688-
pub fn findZig(io: std.Io, allocator: std.mem.Allocator) error{OutOfMemory}!?[]const u8 {
690+
pub fn findZig(
691+
io: std.Io,
692+
allocator: std.mem.Allocator,
693+
environ_map: *const std.process.Environ.Map,
694+
) error{OutOfMemory}!?[]const u8 {
689695
const is_windows = builtin.target.os.tag == .windows;
690696

691-
const env_path = std.process.getEnvVarOwned(allocator, "PATH") catch |err| switch (err) {
692-
error.EnvironmentVariableNotFound => return null,
693-
error.OutOfMemory => |e| return e,
694-
error.InvalidWtf8 => |e| {
695-
log.err("failed to load 'PATH' environment variable: {}", .{e});
696-
return null;
697-
},
698-
};
699-
defer allocator.free(env_path);
700-
701-
const env_path_ext = if (is_windows)
702-
std.process.getEnvVarOwned(allocator, "PATHEXT") catch |err| switch (err) {
703-
error.EnvironmentVariableNotFound => return null,
704-
error.OutOfMemory => |e| return e,
705-
error.InvalidWtf8 => |e| {
706-
log.err("failed to load 'PATH' environment variable: {}", .{e});
707-
return null;
708-
},
709-
};
710-
defer if (is_windows) allocator.free(env_path_ext);
697+
const env_path = environ_map.get("PATH") orelse return null;
698+
const env_path_ext = if (is_windows) environ_map.get("PATHEXT") orelse return null;
711699

712700
var filename_buffer: std.ArrayList(u8) = .empty;
713701
defer filename_buffer.deinit(allocator);

0 commit comments

Comments
 (0)