| ... | ... | @@ -36,6 +36,7 @@ pub const LibCInstallation = struct { |
| 36 | 36 | LibCStdLibHeaderNotFound, |
| 37 | 37 | LibCKernel32LibNotFound, |
| 38 | 38 | UnsupportedArchitecture, |
| 39 | WindowsSdkNotFound, |
| 39 | 40 | }; |
| 40 | 41 | |
| 41 | 42 | pub fn parse( |
| ... | ... | @@ -174,7 +175,7 @@ pub const LibCInstallation = struct { |
| 174 | 175 | } |
| 175 | 176 | |
| 176 | 177 | /// Finds the default, native libc. |
| 177 | | pub fn findNative(allocator: *Allocator) !LibCInstallation { |
| 178 | pub fn findNative(allocator: *Allocator) FindError!LibCInstallation { |
| 178 | 179 | var self: LibCInstallation = .{}; |
| 179 | 180 | |
| 180 | 181 | if (is_windows) { |
| ... | ... | @@ -199,8 +200,8 @@ pub const LibCInstallation = struct { |
| 199 | 200 | try batch.wait(); |
| 200 | 201 | }, |
| 201 | 202 | .OutOfMemory => return error.OutOfMemory, |
| 202 | | .NotFound => return error.NotFound, |
| 203 | | .PathTooLong => return error.NotFound, |
| 203 | .NotFound => return error.WindowsSdkNotFound, |
| 204 | .PathTooLong => return error.WindowsSdkNotFound, |
| 204 | 205 | } |
| 205 | 206 | } |
| 206 | 207 | } else { |
| ... | ... | @@ -311,7 +312,11 @@ pub const LibCInstallation = struct { |
| 311 | 312 | return error.LibCStdLibHeaderNotFound; |
| 312 | 313 | } |
| 313 | 314 | |
| 314 | | fn findNativeIncludeDirWindows(self: *LibCInstallation, allocator: *Allocator, sdk: *ZigWindowsSDK) !void { |
| 315 | fn findNativeIncludeDirWindows( |
| 316 | self: *LibCInstallation, |
| 317 | allocator: *Allocator, |
| 318 | sdk: *ZigWindowsSDK, |
| 319 | ) FindError!void { |
| 315 | 320 | var search_buf: [2]Search = undefined; |
| 316 | 321 | const searches = fillSearch(&search_buf, sdk); |
| 317 | 322 | |
| ... | ... | @@ -432,6 +437,48 @@ pub const LibCInstallation = struct { |
| 432 | 437 | } |
| 433 | 438 | return error.LibCKernel32LibNotFound; |
| 434 | 439 | } |
| 440 | |
| 441 | fn findNativeMsvcIncludeDir( |
| 442 | self: *LibCInstallation, |
| 443 | allocator: *Allocator, |
| 444 | sdk: *ZigWindowsSDK, |
| 445 | ) FindError!void { |
| 446 | const msvc_lib_dir_ptr = sdk.msvc_lib_dir_ptr orelse return error.LibCStdLibHeaderNotFound; |
| 447 | const msvc_lib_dir = msvc_lib_dir_ptr[0..sdk.msvc_lib_dir_len]; |
| 448 | const up1 = fs.path.dirname(msvc_lib_dir) orelse return error.LibCStdLibHeaderNotFound; |
| 449 | const up2 = fs.path.dirname(up1) orelse return error.LibCStdLibHeaderNotFound; |
| 450 | |
| 451 | var result_buf = try std.Buffer.init(allocator, up2); |
| 452 | defer result_buf.deinit(); |
| 453 | |
| 454 | try result_buf.append("\\include"); |
| 455 | |
| 456 | var dir = fs.cwd().openDirList(result_buf.toSliceConst()) catch |err| switch (err) { |
| 457 | error.FileNotFound, |
| 458 | error.NotDir, |
| 459 | error.NoDevice, |
| 460 | => return error.LibCStdLibHeaderNotFound, |
| 461 | |
| 462 | else => return error.FileSystem, |
| 463 | }; |
| 464 | defer dir.close(); |
| 465 | |
| 466 | dir.accessZ("vcruntime.h", .{}) catch |err| switch (err) { |
| 467 | error.FileNotFound => return error.LibCStdLibHeaderNotFound, |
| 468 | else => return error.FileSystem, |
| 469 | }; |
| 470 | |
| 471 | self.sys_include_dir = result_buf.toOwnedSlice(); |
| 472 | } |
| 473 | |
| 474 | fn findNativeMsvcLibDir( |
| 475 | self: *LibCInstallation, |
| 476 | allocator: *Allocator, |
| 477 | sdk: *ZigWindowsSDK, |
| 478 | ) FindError!void { |
| 479 | const msvc_lib_dir_ptr = sdk.msvc_lib_dir_ptr orelse return error.LibCRuntimeNotFound; |
| 480 | self.msvc_lib_dir = try std.mem.dupeZ(allocator, u8, msvc_lib_dir_ptr[0..sdk.msvc_lib_dir_len]); |
| 481 | } |
| 435 | 482 | }; |
| 436 | 483 | |
| 437 | 484 | const default_cc_exe = if (is_windows) "cc.exe" else "cc"; |