From 90f8109639252c2b77c99b894690e19c71f4af77 Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Thu, 7 Oct 2021 12:34:14 +0100 Subject: [PATCH 1/2] Update to use @import("builtin") where required --- src/main.zig | 5 +++-- src/setup.zig | 7 ++++--- src/uri.zig | 5 +++-- tests/sessions.zig | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main.zig b/src/main.zig index f0bcba2..27555a4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const zig_builtin = @import("builtin"); const build_options = @import("build_options"); const Config = @import("./config.zig"); const DocumentStore = @import("./document_store.zig"); @@ -29,7 +30,7 @@ const logger = std.log.scoped(.main); // value in the definition below. pub const log_level = .debug; -var actual_log_level: std.log.Level = switch (std.builtin.mode) { +var actual_log_level: std.log.Level = switch (zig_builtin.mode) { .Debug => .debug, else => .notice, }; @@ -1654,7 +1655,7 @@ fn processJsonRpc(arena: *std.heap.ArenaAllocator, parser: *std.json.Parser, jso logger.debug("Method without return value not implemented: {s}", .{method}); } -const stack_frames = switch (std.builtin.mode) { +const stack_frames = switch (zig_builtin.mode) { .Debug => 10, else => 0, }; diff --git a/src/setup.zig b/src/setup.zig index 3158b23..5c44d8d 100644 --- a/src/setup.zig +++ b/src/setup.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); const zinput = @import("zinput"); const known_folders = @import("known-folders"); @@ -72,7 +73,7 @@ pub fn wizard(allocator: *std.mem.Allocator) !void { print("Found zig executable '{s}' in PATH.\n", .{path}); } else { write("Could not find 'zig' in PATH\n"); - zig_exe_path = try zinput.askString(allocator, if (std.builtin.os.tag == .windows) + zig_exe_path = try zinput.askString(allocator, if (builtin.os.tag == .windows) \\What is the path to the 'zig' executable you would like to use? \\Note that due to a bug in zig (https://github.com/ziglang/zig/issues/6044), \\your zig directory cannot contain the '/' character. @@ -221,13 +222,13 @@ pub fn findZig(allocator: *std.mem.Allocator) !?[]const u8 { }; defer allocator.free(env_path); - const exe_extension = std.Target.current.exeFileExt(); + const exe_extension = builtin.target.exeFileExt(); const zig_exe = try std.fmt.allocPrint(allocator, "zig{s}", .{exe_extension}); defer allocator.free(zig_exe); var it = std.mem.tokenize(u8, env_path, &[_]u8{std.fs.path.delimiter}); while (it.next()) |path| { - if (std.builtin.os.tag == .windows) { + if (builtin.os.tag == .windows) { if (std.mem.indexOfScalar(u8, path, '/') != null) continue; } const full_path = try std.fs.path.join(allocator, &[_][]const u8{ path, zig_exe }); diff --git a/src/uri.zig b/src/uri.zig index f9ad498..e4a1ed1 100644 --- a/src/uri.zig +++ b/src/uri.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const builtin = @import("builtin"); // http://tools.ietf.org/html/rfc3986#section-2.2 const reserved_chars = &[_]u8{ @@ -20,7 +21,7 @@ const reserved_escapes = blk: { /// Returns a URI from a path, caller owns the memory allocated with `allocator` pub fn fromPath(allocator: *std.mem.Allocator, path: []const u8) ![]const u8 { if (path.len == 0) return ""; - const prefix = if (std.builtin.os.tag == .windows) "file:///" else "file://"; + const prefix = if (builtin.os.tag == .windows) "file:///" else "file://"; var buf = std.ArrayList(u8).init(allocator); try buf.appendSlice(prefix); @@ -36,7 +37,7 @@ pub fn fromPath(allocator: *std.mem.Allocator, path: []const u8) ![]const u8 { } // On windows, we need to lowercase the drive name. - if (std.builtin.os.tag == .windows) { + if (builtin.os.tag == .windows) { if (buf.items.len > prefix.len + 1 and std.ascii.isAlpha(buf.items[prefix.len]) and std.mem.startsWith(u8, buf.items[prefix.len + 1 ..], "%3A")) diff --git a/tests/sessions.zig b/tests/sessions.zig index 922572b..91db7aa 100644 --- a/tests/sessions.zig +++ b/tests/sessions.zig @@ -1,7 +1,8 @@ const std = @import("std"); const headerPkg = @import("header"); +const builtin = @import("builtin"); -const suffix = if (std.builtin.os.tag == .windows) ".exe" else ""; +const suffix = if (builtin.os.tag == .windows) ".exe" else ""; const allocator = std.heap.page_allocator; const initialize_msg = From b88a95a617add7b270784ce5eeffe64d724fe245 Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Mon, 11 Oct 2021 09:21:24 +0100 Subject: [PATCH 2/2] Update submodule --- src/known-folders | 2 +- src/zinput | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/known-folders b/src/known-folders index 234b589..a282c26 160000 --- a/src/known-folders +++ b/src/known-folders @@ -1 +1 @@ -Subproject commit 234b589d3cd0c00f2f675f98fd9674e208fd2bd0 +Subproject commit a282c26da51e5d2c01fec5c744e321ae248cf409 diff --git a/src/zinput b/src/zinput index 0622255..56da848 160000 --- a/src/zinput +++ b/src/zinput @@ -1 +1 @@ -Subproject commit 0622255c35a8fbe7d09c8d45f357cec776bd2e3a +Subproject commit 56da848c9aa8b5637114acff48576773a0ee998e