authorgravatar for xhxnna@proton.meHanna <xhxnna@proton.me> 2022-05-26 19:32:28-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-05-26 19:32:28-04:00
log4e918873e7667e8d74b009cb34cbdd4df3305462
treefc55f8d0c6327e680eb2ced740ec89789d3c26ec
parent67d5bfefba48d28c02e2841f1a47a213d28d4693
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Rename `std.build.Pkg.path` to `std.build.Pkg.source` (#11557)


2 files changed, 12 insertions(+), 12 deletions(-)

lib/std/build.zig+11-11
......@@ -385,7 +385,7 @@ pub const Builder = struct {
385385 pub fn dupePkg(self: *Builder, package: Pkg) Pkg {
386386 var the_copy = Pkg{
387387 .name = self.dupe(package.name),
388 .path = package.path.dupe(self),
388 .source = package.source.dupe(self),
389389 };
390390
391391 if (package.dependencies) |dependencies| {
......@@ -1353,7 +1353,7 @@ pub const Target = @compileError("deprecated; Use `std.zig.CrossTarget`");
13531353
13541354pub const Pkg = struct {
13551355 name: []const u8,
1356 path: FileSource,
1356 source: FileSource,
13571357 dependencies: ?[]const Pkg = null,
13581358};
13591359
......@@ -2228,7 +2228,7 @@ pub const LibExeObjStep = struct {
22282228 }
22292229
22302230 fn addRecursiveBuildDeps(self: *LibExeObjStep, package: Pkg) void {
2231 package.path.addStepDependencies(&self.step);
2231 package.source.addStepDependencies(&self.step);
22322232 if (package.dependencies) |deps| {
22332233 for (deps) |dep| {
22342234 self.addRecursiveBuildDeps(dep);
......@@ -2239,7 +2239,7 @@ pub const LibExeObjStep = struct {
22392239 pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
22402240 self.addPackage(Pkg{
22412241 .name = self.builder.dupe(name),
2242 .path = .{ .path = self.builder.dupe(pkg_index_path) },
2242 .source = .{ .path = self.builder.dupe(pkg_index_path) },
22432243 });
22442244 }
22452245
......@@ -2300,7 +2300,7 @@ pub const LibExeObjStep = struct {
23002300
23012301 try zig_args.append("--pkg-begin");
23022302 try zig_args.append(pkg.name);
2303 try zig_args.append(builder.pathFromRoot(pkg.path.getPath(self.builder)));
2303 try zig_args.append(builder.pathFromRoot(pkg.source.getPath(self.builder)));
23042304
23052305 if (pkg.dependencies) |dependencies| {
23062306 for (dependencies) |sub_pkg| {
......@@ -3560,11 +3560,11 @@ test "Builder.dupePkg()" {
35603560
35613561 var pkg_dep = Pkg{
35623562 .name = "pkg_dep",
3563 .path = .{ .path = "/not/a/pkg_dep.zig" },
3563 .source = .{ .path = "/not/a/pkg_dep.zig" },
35643564 };
35653565 var pkg_top = Pkg{
35663566 .name = "pkg_top",
3567 .path = .{ .path = "/not/a/pkg_top.zig" },
3567 .source = .{ .path = "/not/a/pkg_top.zig" },
35683568 .dependencies = &[_]Pkg{pkg_dep},
35693569 };
35703570 const dupe = builder.dupePkg(pkg_top);
......@@ -3583,9 +3583,9 @@ test "Builder.dupePkg()" {
35833583 // the same as those in stack allocated package's fields
35843584 try std.testing.expect(dupe_deps.ptr != original_deps.ptr);
35853585 try std.testing.expect(dupe.name.ptr != pkg_top.name.ptr);
3586 try std.testing.expect(dupe.path.path.ptr != pkg_top.path.path.ptr);
3586 try std.testing.expect(dupe.source.path.ptr != pkg_top.source.path.ptr);
35873587 try std.testing.expect(dupe_deps[0].name.ptr != pkg_dep.name.ptr);
3588 try std.testing.expect(dupe_deps[0].path.path.ptr != pkg_dep.path.path.ptr);
3588 try std.testing.expect(dupe_deps[0].source.path.ptr != pkg_dep.source.path.ptr);
35893589}
35903590
35913591test "LibExeObjStep.addPackage" {
......@@ -3605,11 +3605,11 @@ test "LibExeObjStep.addPackage" {
36053605
36063606 const pkg_dep = Pkg{
36073607 .name = "pkg_dep",
3608 .path = .{ .path = "/not/a/pkg_dep.zig" },
3608 .source = .{ .path = "/not/a/pkg_dep.zig" },
36093609 };
36103610 const pkg_top = Pkg{
36113611 .name = "pkg_dep",
3612 .path = .{ .path = "/not/a/pkg_top.zig" },
3612 .source = .{ .path = "/not/a/pkg_top.zig" },
36133613 .dependencies = &[_]Pkg{pkg_dep},
36143614 };
36153615
lib/std/build/OptionsStep.zig+1-1
......@@ -200,7 +200,7 @@ pub fn addOptionArtifact(self: *OptionsStep, name: []const u8, artifact: *LibExe
200200}
201201
202202pub fn getPackage(self: *OptionsStep, package_name: []const u8) build.Pkg {
203 return .{ .name = package_name, .path = self.getSource() };
203 return .{ .name = package_name, .source = self.getSource() };
204204}
205205
206206pub fn getSource(self: *OptionsStep) FileSource {