authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-11 14:08:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-11 14:09:58-07:00
log499a202a13c2a61f3cb2535c1bd63a9b6b30bfb7
treef3f1d49043e97e7828f681b012cde639ff62ddc8
parentb30ad7490891ca3522abdd0a1ffaf809df497f3d

std.Build: revert the breaking changes only

The previous commit deleted the deprecated API and then made all the follow-up changes; this commit reverts only the breaking API changes. This commit can be reverted once 0.12.0 is tagged.

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

lib/std/Build.zig+19-2
......@@ -2131,6 +2131,9 @@ test dirnameAllowEmpty {
21312131
21322132/// A reference to an existing or future path.
21332133pub const LazyPath = union(enum) {
2134 /// Deprecated; use the `path` function instead.
2135 path: []const u8,
2136
21342137 /// A source file path relative to build root.
21352138 src_path: struct {
21362139 owner: *std.Build,
......@@ -2165,6 +2168,12 @@ pub const LazyPath = union(enum) {
21652168 sub_path: []const u8,
21662169 },
21672170
2171 /// Deprecated. Call `path` instead.
2172 pub fn relative(p: []const u8) LazyPath {
2173 std.log.warn("deprecated. call std.Build.path instead", .{});
2174 return .{ .path = p };
2175 }
2176
21682177 /// Returns a lazy path referring to the directory containing this path.
21692178 ///
21702179 /// The dirname is not allowed to escape the logical root for underlying path.
......@@ -2183,6 +2192,12 @@ pub const LazyPath = union(enum) {
21832192 @panic("misconfigured build script");
21842193 },
21852194 } },
2195 .path => |p| .{
2196 .path = dirnameAllowEmpty(p) orelse {
2197 dumpBadDirnameHelp(null, null, "dirname() attempted to traverse outside the build root\n", .{}) catch {};
2198 @panic("misconfigured build script");
2199 },
2200 },
21862201 .cwd_relative => |p| .{
21872202 .cwd_relative = dirnameAllowEmpty(p) orelse {
21882203 // If we get null, it means one of two things:
......@@ -2224,7 +2239,7 @@ pub const LazyPath = union(enum) {
22242239 pub fn getDisplayName(self: LazyPath) []const u8 {
22252240 return switch (self) {
22262241 .src_path => |sp| sp.sub_path,
2227 .cwd_relative => |p| p,
2242 .path, .cwd_relative => |p| p,
22282243 .generated => "generated",
22292244 .generated_dirname => "generated",
22302245 .dependency => "dependency",
......@@ -2234,7 +2249,7 @@ pub const LazyPath = union(enum) {
22342249 /// Adds dependencies this file source implies to the given step.
22352250 pub fn addStepDependencies(self: LazyPath, other_step: *Step) void {
22362251 switch (self) {
2237 .src_path, .cwd_relative, .dependency => {},
2252 .src_path, .path, .cwd_relative, .dependency => {},
22382253 .generated => |gen| other_step.dependOn(gen.step),
22392254 .generated_dirname => |gen| other_step.dependOn(gen.generated.step),
22402255 }
......@@ -2253,6 +2268,7 @@ pub const LazyPath = union(enum) {
22532268 /// run that is asking for the path.
22542269 pub fn getPath2(self: LazyPath, src_builder: *Build, asking_step: ?*Step) []const u8 {
22552270 switch (self) {
2271 .path => |p| return src_builder.pathFromRoot(p),
22562272 .src_path => |sp| return sp.owner.pathFromRoot(sp.sub_path),
22572273 .cwd_relative => |p| return src_builder.pathFromCwd(p),
22582274 .generated => |gen| return gen.path orelse {
......@@ -2313,6 +2329,7 @@ pub const LazyPath = union(enum) {
23132329 .owner = sp.owner,
23142330 .sub_path = sp.owner.dupePath(sp.sub_path),
23152331 } },
2332 .path => |p| .{ .path = b.dupePath(p) },
23162333 .cwd_relative => |p| .{ .cwd_relative = b.dupePath(p) },
23172334 .generated => |gen| .{ .generated = gen },
23182335 .generated_dirname => |gen| .{
lib/std/Build/Step/ConfigHeader.zig+1
......@@ -59,6 +59,7 @@ pub fn create(owner: *std.Build, options: Options) *ConfigHeader {
5959 if (options.style.getPath()) |s| default_include_path: {
6060 const sub_path = switch (s) {
6161 .src_path => |sp| sp.sub_path,
62 .path => |path| path,
6263 .generated, .generated_dirname => break :default_include_path,
6364 .cwd_relative => |sub_path| sub_path,
6465 .dependency => |dependency| dependency.sub_path,