| ... | ... | @@ -39,7 +39,7 @@ pub fn build(b: *Builder) !void { |
| 39 | 39 | "config_h", |
| 40 | 40 | "Path to the generated config.h", |
| 41 | 41 | )) |config_h_path| |
| 42 | | try std.fs.cwd().readFileAlloc(b.allocator, config_h_path, max_config_h_bytes) |
| 42 | try std.fs.cwd().readFileAlloc(b.allocator, toNativePathSep(b, config_h_path), max_config_h_bytes) |
| 43 | 43 | else |
| 44 | 44 | try findAndReadConfigH(b); |
| 45 | 45 | |
| ... | ... | @@ -65,7 +65,7 @@ pub fn build(b: *Builder) !void { |
| 65 | 65 | |
| 66 | 66 | const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; |
| 67 | 67 | if (!only_install_lib_files and !skip_self_hosted) { |
| 68 | | var ctx = parseConfigH(config_h_text); |
| 68 | var ctx = parseConfigH(b, config_h_text); |
| 69 | 69 | ctx.llvm = try findLLVM(b, ctx.llvm_config_exe); |
| 70 | 70 | |
| 71 | 71 | try configureStage2(b, test_stage2, ctx); |
| ... | ... | @@ -377,7 +377,7 @@ fn findAndReadConfigH(b: *Builder) ![]const u8 { |
| 377 | 377 | } else unreachable; // TODO should not need `else unreachable`. |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | | fn parseConfigH(config_h_text: []const u8) Context { |
| 380 | fn parseConfigH(b: *Builder, config_h_text: []const u8) Context { |
| 381 | 381 | var ctx: Context = .{ |
| 382 | 382 | .cmake_binary_dir = undefined, |
| 383 | 383 | .cxx_compiler = undefined, |
| ... | ... | @@ -426,9 +426,19 @@ fn parseConfigH(config_h_text: []const u8) Context { |
| 426 | 426 | if (mem.startsWith(u8, line, mapping.prefix)) { |
| 427 | 427 | var it = mem.split(line, "\""); |
| 428 | 428 | _ = it.next().?; // skip the stuff before the quote |
| 429 | | @field(ctx, mapping.field) = it.next().?; // the stuff inside the quote |
| 429 | const quoted = it.next().?; // the stuff inside the quote |
| 430 | @field(ctx, mapping.field) = toNativePathSep(b, quoted); |
| 430 | 431 | } |
| 431 | 432 | } |
| 432 | 433 | } |
| 433 | 434 | return ctx; |
| 434 | 435 | } |
| 436 | |
| 437 | fn toNativePathSep(b: *Builder, s: []const u8) []u8 { |
| 438 | const duplicated = mem.dupe(b.allocator, u8, s) catch unreachable; |
| 439 | for (duplicated) |*byte| switch (byte.*) { |
| 440 | '/' => byte.* = fs.path.sep, |
| 441 | else => {}, |
| 442 | }; |
| 443 | return duplicated; |
| 444 | } |