| ... | @@ -9,6 +9,8 @@ const is_darwin = Target.current.isDarwin(); | ... | @@ -9,6 +9,8 @@ const is_darwin = Target.current.isDarwin(); |
| 9 | const is_windows = Target.current.os.tag == .windows; | 9 | const is_windows = Target.current.os.tag == .windows; |
| 10 | const is_gnu = Target.current.isGnu(); | 10 | const is_gnu = Target.current.isGnu(); |
| 11 | | 11 | |
| | 12 | const log = std.log.scoped(.libc_installation); |
| | 13 | |
| 12 | usingnamespace @import("windows_sdk.zig"); | 14 | usingnamespace @import("windows_sdk.zig"); |
| 13 | | 15 | |
| 14 | /// See the render function implementation for documentation of the fields. | 16 | /// See the render function implementation for documentation of the fields. |
| ... | @@ -37,7 +39,6 @@ pub const LibCInstallation = struct { | ... | @@ -37,7 +39,6 @@ pub const LibCInstallation = struct { |
| 37 | pub fn parse( | 39 | pub fn parse( |
| 38 | allocator: *Allocator, | 40 | allocator: *Allocator, |
| 39 | libc_file: []const u8, | 41 | libc_file: []const u8, |
| 40 | stderr: anytype, | | |
| 41 | ) !LibCInstallation { | 42 | ) !LibCInstallation { |
| 42 | var self: LibCInstallation = .{}; | 43 | var self: LibCInstallation = .{}; |
| 43 | | 44 | |
| ... | @@ -62,7 +63,7 @@ pub const LibCInstallation = struct { | ... | @@ -62,7 +63,7 @@ pub const LibCInstallation = struct { |
| 62 | if (line.len == 0 or line[0] == '#') continue; | 63 | if (line.len == 0 or line[0] == '#') continue; |
| 63 | var line_it = std.mem.split(line, "="); | 64 | var line_it = std.mem.split(line, "="); |
| 64 | const name = line_it.next() orelse { | 65 | const name = line_it.next() orelse { |
| 65 | try stderr.print("missing equal sign after field name\n", .{}); | 66 | log.err("missing equal sign after field name\n", .{}); |
| 66 | return error.ParseError; | 67 | return error.ParseError; |
| 67 | }; | 68 | }; |
| 68 | const value = line_it.rest(); | 69 | const value = line_it.rest(); |
| ... | @@ -81,31 +82,31 @@ pub const LibCInstallation = struct { | ... | @@ -81,31 +82,31 @@ pub const LibCInstallation = struct { |
| 81 | } | 82 | } |
| 82 | inline for (fields) |field, i| { | 83 | inline for (fields) |field, i| { |
| 83 | if (!found_keys[i].found) { | 84 | if (!found_keys[i].found) { |
| 84 | try stderr.print("missing field: {}\n", .{field.name}); | 85 | log.err("missing field: {}\n", .{field.name}); |
| 85 | return error.ParseError; | 86 | return error.ParseError; |
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 88 | if (self.include_dir == null) { | 89 | if (self.include_dir == null) { |
| 89 | try stderr.print("include_dir may not be empty\n", .{}); | 90 | log.err("include_dir may not be empty\n", .{}); |
| 90 | return error.ParseError; | 91 | return error.ParseError; |
| 91 | } | 92 | } |
| 92 | if (self.sys_include_dir == null) { | 93 | if (self.sys_include_dir == null) { |
| 93 | try stderr.print("sys_include_dir may not be empty\n", .{}); | 94 | log.err("sys_include_dir may not be empty\n", .{}); |
| 94 | return error.ParseError; | 95 | return error.ParseError; |
| 95 | } | 96 | } |
| 96 | if (self.crt_dir == null and !is_darwin) { | 97 | if (self.crt_dir == null and !is_darwin) { |
| 97 | try stderr.print("crt_dir may not be empty for {}\n", .{@tagName(Target.current.os.tag)}); | 98 | log.err("crt_dir may not be empty for {}\n", .{@tagName(Target.current.os.tag)}); |
| 98 | return error.ParseError; | 99 | return error.ParseError; |
| 99 | } | 100 | } |
| 100 | if (self.msvc_lib_dir == null and is_windows and !is_gnu) { | 101 | if (self.msvc_lib_dir == null and is_windows and !is_gnu) { |
| 101 | try stderr.print("msvc_lib_dir may not be empty for {}-{}\n", .{ | 102 | log.err("msvc_lib_dir may not be empty for {}-{}\n", .{ |
| 102 | @tagName(Target.current.os.tag), | 103 | @tagName(Target.current.os.tag), |
| 103 | @tagName(Target.current.abi), | 104 | @tagName(Target.current.abi), |
| 104 | }); | 105 | }); |
| 105 | return error.ParseError; | 106 | return error.ParseError; |
| 106 | } | 107 | } |
| 107 | if (self.kernel32_lib_dir == null and is_windows and !is_gnu) { | 108 | if (self.kernel32_lib_dir == null and is_windows and !is_gnu) { |
| 108 | try stderr.print("kernel32_lib_dir may not be empty for {}-{}\n", .{ | 109 | log.err("kernel32_lib_dir may not be empty for {}-{}\n", .{ |
| 109 | @tagName(Target.current.os.tag), | 110 | @tagName(Target.current.os.tag), |
| 110 | @tagName(Target.current.abi), | 111 | @tagName(Target.current.abi), |
| 111 | }); | 112 | }); |