authorgravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-02-24 13:12:04-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-02-24 16:12:04-05:00
log3eacd1b2e56728a291b4e5dc443a56fa0b4cab14
treed66bdb000053f3bcd14844b21e08719d0ad87c40
parent70fbafacf2811a9d6db5637e91d3a165d2af84a8
signaturebadge-check Signed by PGP key B5690EEEBB952194

change `addCSourceFiles` to use `LazyPath` instead `Dependency` (#19017)

Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>

2 files changed, 10 insertions(+), 14 deletions(-)

lib/std/Build/Module.zig+6-6
......@@ -79,9 +79,9 @@ pub const SystemLib = struct {
7979};
8080
8181pub const CSourceFiles = struct {
82 dependency: ?*std.Build.Dependency,
83 /// If `dependency` is not null relative to it,
84 /// else relative to the build root.
82 root: LazyPath,
83 /// `files` is relative to `root`, which is
84 /// the build root by default
8585 files: []const []const u8,
8686 flags: []const []const u8,
8787};
......@@ -453,9 +453,9 @@ pub fn linkFramework(m: *Module, name: []const u8, options: LinkFrameworkOptions
453453}
454454
455455pub const AddCSourceFilesOptions = struct {
456 /// When provided, `files` are relative to `dependency` rather than the
456 /// When provided, `files` are relative to `root` rather than the
457457 /// package that owns the `Compile` step.
458 dependency: ?*std.Build.Dependency = null,
458 root: LazyPath = .{ .path = "" },
459459 files: []const []const u8,
460460 flags: []const []const u8 = &.{},
461461};
......@@ -466,7 +466,7 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
466466 const allocator = b.allocator;
467467 const c_source_files = allocator.create(CSourceFiles) catch @panic("OOM");
468468 c_source_files.* = .{
469 .dependency = options.dependency,
469 .root = options.root,
470470 .files = b.dupeStrings(options.files),
471471 .flags = b.dupeStrings(options.flags),
472472 };
lib/std/Build/Step/Compile.zig+4-8
......@@ -1197,15 +1197,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
11971197 prev_has_cflags = true;
11981198 }
11991199
1200 if (c_source_files.dependency) |dep| {
1201 for (c_source_files.files) |file| {
1202 try zig_args.append(dep.builder.pathFromRoot(file));
1203 }
1204 } else {
1205 for (c_source_files.files) |file| {
1206 try zig_args.append(b.pathFromRoot(file));
1207 }
1200 const root_path = c_source_files.root.getPath2(module.owner, step);
1201 for (c_source_files.files) |file| {
1202 try zig_args.append(b.pathJoin(&.{ root_path, file }));
12081203 }
1204
12091205 total_linker_objects += c_source_files.files.len;
12101206 },
12111207