Uh oh!
There was an error while loading. Please reload this page.
Conversation
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.
It wasn't unnecessary and was required specifically for // foo/build.zigconststd=@import("std");
pubfnbuild(b: *std.Build) void {
constlibfoo=b.addStaticLibrary(.{
.name="foo",
.target=b.resolveTargetQuery(.{}),
.optimize=.Debug,
});
libfoo.addCSourceFile(.{ .file=b.addWriteFiles().add("empty.c", "") });
libfoo.installHeader(.{ .path="header.h" }, "foo/foo.h"); // <------------ Note: .path, not .src_pathb.installArtifact(libfoo);
}// foo/header.h
#defineFOO_FOO"FOO"// build.zigconststd=@import("std");
pubfnbuild(b: *std.Build) void {
constexe=b.addExecutable(.{
.name="main",
.target=b.resolveTargetQuery(.{}),
.link_libc=true,
});
exe.addCSourceFile(.{ .file=b.addWriteFiles().add("main.c",
\\#include <stdio.h>\\#include <foo/foo.h>\\int main(void) {\\ printf(FOO_FOO "\n");\\ return 0;\\}
) });
constfoo_dep=b.dependency("foo", .{});
constlibfoo=foo_dep.artifact("foo");
exe.linkLibrary(libfoo);
exe.installLibraryHeaders(libfoo);
b.getInstallStep().dependOn(&b.addInstallArtifact(exe, .{
.h_dir= .{ .override=.header }, // <---------------- This is the thing that fails
}).step);
construn_exe=b.addRunArtifact(exe);
run_exe.step.dependOn(b.getInstallStep());
construn=b.step("run", "Run the app");
run.dependOn(&run_exe.step);
}// build.zig.zon
.{
.name="main",
.version="0.0.0",
.dependencies= .{
.foo= .{
.path="foo",
},
},
.paths= .{""},
}zig build runNote that 0b7123f made installing headers to the It's probably not worth keeping the workaround; the fix is just to use the new |
| pub fn path(b: *Build, sub_path: []const u8) LazyPath { | ||
| assert(!fs.path.isAbsolute(sub_path)); | ||
| if (fs.path.isAbsolute(sub_path)) { | ||
| std.debug.panic("sub_path is expected to be relative to the build root, but was this absolute path: '{s}'. It is best avoid absolute paths, but if you must, it is supported by LazyPath.cwd_relative", .{ |
andrewrk
commented
Apr 11, 2024
Understood, thank you for the clarification! |
) Ref: ziglang/zig#19623 The changes here are trivial, only a small change required to be up to date with master. Tested with `0.12.0-dev.3639+9cfac4718`
* Fix for issue #4010 Split the code for Zig's master branch and >= 0.12.0 due to changes in ziglang/zig#19623 * Restore the cache_include path which was removed in error Accidently removed a couple lines I didn't mean to 🙈
* LazyPath now stores `Build` owner inside in ziglang/zig#19623 and ziglang/zig#19597 . Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
The first commit deletes the deprecated API and then makes all the upgrades needed to pass the standalone tests.
The second commit reverts the API breakage. The second commit can be reverted once 0.12.0 is tagged.
@castholm re:
The
*Buildargument to LazyPath.dupe was only being used for its allocator, and all instances share the same allocator. So converting a path prematurely to an absolute path was unnecessary and introduced unwanted absolute paths.