Build: cleanup

* `doc/langref` formatting
 * upgrade `.{ .path = "..." }` to `b.path("...")`
 * avoid using arguments named `self`
 * make `Build.Step.Id` usage more consistent
 * add `Build.pathResolve`
 * use `pathJoin` and `pathResolve` everywhere
 * make sure `Build.LazyPath.getPath2` returns an absolute path
This commit is contained in:
Jacob Young
2024-05-04 14:29:17 -04:00
parent d582575aba
commit e3424332d3
59 changed files with 1306 additions and 1311 deletions

View File

@@ -89,10 +89,10 @@ pub const CSourceFile = struct {
file: LazyPath,
flags: []const []const u8 = &.{},
pub fn dupe(self: CSourceFile, b: *std.Build) CSourceFile {
pub fn dupe(file: CSourceFile, b: *std.Build) CSourceFile {
return .{
.file = self.file.dupe(b),
.flags = b.dupeStrings(self.flags),
.file = file.file.dupe(b),
.flags = b.dupeStrings(file.flags),
};
}
};
@@ -115,12 +115,12 @@ pub const RcSourceFile = struct {
/// as `/I <resolved path>`.
include_paths: []const LazyPath = &.{},
pub fn dupe(self: RcSourceFile, b: *std.Build) RcSourceFile {
const include_paths = b.allocator.alloc(LazyPath, self.include_paths.len) catch @panic("OOM");
for (include_paths, self.include_paths) |*dest, lazy_path| dest.* = lazy_path.dupe(b);
pub fn dupe(file: RcSourceFile, b: *std.Build) RcSourceFile {
const include_paths = b.allocator.alloc(LazyPath, file.include_paths.len) catch @panic("OOM");
for (include_paths, file.include_paths) |*dest, lazy_path| dest.* = lazy_path.dupe(b);
return .{
.file = self.file.dupe(b),
.flags = b.dupeStrings(self.flags),
.file = file.file.dupe(b),
.flags = b.dupeStrings(file.flags),
.include_paths = include_paths,
};
}
@@ -665,24 +665,19 @@ pub fn appendZigProcessFlags(
for (m.include_dirs.items) |include_dir| {
switch (include_dir) {
.path => |include_path| {
try zig_args.append("-I");
try zig_args.append(include_path.getPath(b));
try zig_args.appendSlice(&.{ "-I", include_path.getPath2(b, asking_step) });
},
.path_system => |include_path| {
try zig_args.append("-isystem");
try zig_args.append(include_path.getPath(b));
try zig_args.appendSlice(&.{ "-isystem", include_path.getPath2(b, asking_step) });
},
.path_after => |include_path| {
try zig_args.append("-idirafter");
try zig_args.append(include_path.getPath(b));
try zig_args.appendSlice(&.{ "-idirafter", include_path.getPath2(b, asking_step) });
},
.framework_path => |include_path| {
try zig_args.append("-F");
try zig_args.append(include_path.getPath2(b, asking_step));
try zig_args.appendSlice(&.{ "-F", include_path.getPath2(b, asking_step) });
},
.framework_path_system => |include_path| {
try zig_args.append("-iframework");
try zig_args.append(include_path.getPath2(b, asking_step));
try zig_args.appendSlice(&.{ "-iframework", include_path.getPath2(b, asking_step) });
},
.other_step => |other| {
if (other.generated_h) |header| {