diff options
Diffstat (limited to 'lib/std/Build/Module.zig')
| -rw-r--r-- | lib/std/Build/Module.zig | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig index 757f51f933..12b55a8c29 100644 --- a/lib/std/Build/Module.zig +++ b/lib/std/Build/Module.zig @@ -173,39 +173,25 @@ pub const IncludeDir = union(enum) { zig_args: *std.ArrayList([]const u8), asking_step: ?*Step, ) !void { - switch (include_dir) { - .path => |include_path| { - try zig_args.appendSlice(&.{ "-I", include_path.getPath2(b, asking_step) }); + const flag: []const u8, const lazy_path: LazyPath = switch (include_dir) { + // zig fmt: off + .path => |lp| .{ "-I", lp }, + .path_system => |lp| .{ "-isystem", lp }, + .path_after => |lp| .{ "-idirafter", lp }, + .framework_path => |lp| .{ "-F", lp }, + .framework_path_system => |lp| .{ "-iframework", lp }, + .config_header_step => |ch| .{ "-I", ch.getOutputDir() }, + .other_step => |comp| .{ "-I", comp.installed_headers_include_tree.?.getDirectory() }, + // zig fmt: on + .embed_path => |lazy_path| { + // Special case: this is a single arg. + const resolved = lazy_path.getPath3(b, asking_step); + const arg = b.fmt("--embed-dir={}", .{resolved}); + return zig_args.append(arg); }, - .path_system => |include_path| { - try zig_args.appendSlice(&.{ "-isystem", include_path.getPath2(b, asking_step) }); - }, - .path_after => |include_path| { - try zig_args.appendSlice(&.{ "-idirafter", include_path.getPath2(b, asking_step) }); - }, - .framework_path => |include_path| { - try zig_args.appendSlice(&.{ "-F", include_path.getPath2(b, asking_step) }); - }, - .framework_path_system => |include_path| { - try zig_args.appendSlice(&.{ "-iframework", include_path.getPath2(b, asking_step) }); - }, - .other_step => |other| { - if (other.generated_h) |header| { - try zig_args.appendSlice(&.{ "-isystem", std.fs.path.dirname(header.getPath()).? }); - } - if (other.installed_headers_include_tree) |include_tree| { - try zig_args.appendSlice(&.{ "-I", include_tree.generated_directory.getPath() }); - } - }, - .config_header_step => |config_header| { - const full_file_path = config_header.output_file.getPath(); - const header_dir_path = full_file_path[0 .. full_file_path.len - config_header.include_path.len]; - try zig_args.appendSlice(&.{ "-I", header_dir_path }); - }, - .embed_path => |embed_path| { - try zig_args.append(try std.mem.concat(b.allocator, u8, &.{ "--embed-dir=", embed_path.getPath2(b, asking_step) })); - }, - } + }; + const resolved_str = try lazy_path.getPath3(b, asking_step).toString(b.graph.arena); + return zig_args.appendSlice(&.{ flag, resolved_str }); } }; |
