Skip to content

Commit d1d93f6

Browse files
author
Felix (xq) Queißner
committed
Introduces Compile.getEmittedX() functions, drops Compile.emit_X. Resolves ziglang#14971
1 parent ed5031f commit d1d93f6

File tree

20 files changed

+284
-161
lines changed

20 files changed

+284
-161
lines changed

build.zig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub fn build(b: *std.Build) !void {
5959
.target = target,
6060
});
6161
autodoc_test.overrideZigLibDir(.{ .path = "lib" });
62-
autodoc_test.emit_bin = .no_emit; // https://github.com/ziglang/zig/issues/16351
6362
const install_std_docs = b.addInstallDirectory(.{
6463
.source_dir = autodoc_test.getEmittedDocs(),
6564
.install_dir = .prefix,
@@ -196,10 +195,6 @@ pub fn build(b: *std.Build) !void {
196195
exe.pie = pie;
197196
exe.sanitize_thread = sanitize_thread;
198197
exe.entitlements = entitlements;
199-
// TODO -femit-bin/-fno-emit-bin should be inferred by the build system
200-
// based on whether or not the exe is run or installed.
201-
// https://github.com/ziglang/zig/issues/16351
202-
if (no_bin) exe.emit_bin = .no_emit;
203198

204199
exe.build_id = b.option(
205200
std.Build.Step.Compile.BuildId,

lib/std/Build.zig

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const NativeTargetInfo = std.zig.system.NativeTargetInfo;
1919
const Sha256 = std.crypto.hash.sha2.Sha256;
2020
const Build = @This();
2121

22+
const build_util = @import("Build/util.zig");
23+
2224
pub const Cache = @import("Build/Cache.zig");
2325

2426
/// deprecated: use `Step.Compile`.
@@ -1679,7 +1681,7 @@ pub const LazyPath = union(enum) {
16791681
.generated => |gen| return gen.path orelse {
16801682
std.debug.getStderrMutex().lock();
16811683
const stderr = std.io.getStdErr();
1682-
dumpBadGetPathHelp(gen.step, stderr, src_builder, asking_step) catch {};
1684+
build_util.dumpBadGetPathHelp(gen.step, stderr, src_builder, asking_step) catch {};
16831685
@panic("misconfigured build script");
16841686
},
16851687
}
@@ -1694,54 +1696,6 @@ pub const LazyPath = union(enum) {
16941696
}
16951697
};
16961698

1697-
/// In this function the stderr mutex has already been locked.
1698-
fn dumpBadGetPathHelp(
1699-
s: *Step,
1700-
stderr: fs.File,
1701-
src_builder: *Build,
1702-
asking_step: ?*Step,
1703-
) anyerror!void {
1704-
const w = stderr.writer();
1705-
try w.print(
1706-
\\getPath() was called on a GeneratedFile that wasn't built yet.
1707-
\\ source package path: {s}
1708-
\\ Is there a missing Step dependency on step '{s}'?
1709-
\\
1710-
, .{
1711-
src_builder.build_root.path orelse ".",
1712-
s.name,
1713-
});
1714-
1715-
const tty_config = std.io.tty.detectConfig(stderr);
1716-
tty_config.setColor(w, .red) catch {};
1717-
try stderr.writeAll(" The step was created by this stack trace:\n");
1718-
tty_config.setColor(w, .reset) catch {};
1719-
1720-
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
1721-
try w.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)});
1722-
return;
1723-
};
1724-
const ally = debug_info.allocator;
1725-
std.debug.writeStackTrace(s.getStackTrace(), w, ally, debug_info, tty_config) catch |err| {
1726-
try stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)});
1727-
return;
1728-
};
1729-
if (asking_step) |as| {
1730-
tty_config.setColor(w, .red) catch {};
1731-
try stderr.writeAll(" The step that is missing a dependency on the above step was created by this stack trace:\n");
1732-
tty_config.setColor(w, .reset) catch {};
1733-
1734-
std.debug.writeStackTrace(as.getStackTrace(), w, ally, debug_info, tty_config) catch |err| {
1735-
try stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)});
1736-
return;
1737-
};
1738-
}
1739-
1740-
tty_config.setColor(w, .red) catch {};
1741-
try stderr.writeAll(" Hope that helps. Proceeding to panic.\n");
1742-
tty_config.setColor(w, .reset) catch {};
1743-
}
1744-
17451699
/// Allocates a new string for assigning a value to a named macro.
17461700
/// If the value is omitted, it is set to 1.
17471701
/// `name` and `value` need not live longer than the function call.

lib/std/Build/Step.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,10 @@ pub fn evalZigProcess(
423423
});
424424
}
425425

426-
if (s.cast(Compile)) |compile| if (compile.emit_bin == .no_emit) return result;
426+
if (s.cast(Compile)) |compile| {
427+
if (compile.generated_bin == null) // TODO(xq): How to handle this properly?!
428+
return result;
429+
}
427430

428431
return result orelse return s.fail(
429432
"the following command failed to communicate the compilation result:\n{s}",

0 commit comments

Comments
 (0)