Update to use @import("builtin") where required

This commit is contained in:
Lee Cannon 2021-10-07 12:34:14 +01:00
parent b63339e350
commit 90f8109639
4 changed files with 12 additions and 8 deletions

View File

@ -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,
};

View File

@ -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 });

View File

@ -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"))

View File

@ -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 =