zig icon indicating copy to clipboard operation
zig copied to clipboard

ConfigHeader does not automatically register a generated FileSource as a step dependency

Open distractedlambda opened this issue 2 years ago • 2 comments

Zig Version

0.11.0-dev.3803+7ad104227

Steps to Reproduce and Observed Behavior

The cmake and autoconf styles of ConfigHeader take a FileSource for the input header, and do indeed work with generated files, but they do not automatically add a dependency on the generation step.

Expected Behavior

I would expect the dependency to be added automatically, as this is almost certainly the user's intention, and is already done elsewhere in the build script API.

distractedlambda avatar Jun 25 '23 17:06 distractedlambda

Polite ping @Jan200101, if you want to poke this and/or #16203. If you prefer not to be pinged, let me know.

matu3ba avatar Jun 25 '23 22:06 matu3ba

I'm fine with being pinged.

Already PR'd a fix for 16203 but am unsure how the requested behavior should look like (plus I think this is a feature request / proposal not a bug report).

Would an example of the requested behavior be passing a header through multiple ConfigHeader's and having the implicit dependencies established?

e.g.

const std = @import("std");

pub fn build(b: *std.Build) void {
    // first we pass it through cmake
    const cmake_config = b.addConfigHeader(.{ .style = .{ .cmake = .{ .path = "config.h.in" } } }, .{});

    // then through autoconf
    const autoconf_confing = b.addConfigHeader(.{ .style = .{ .autoconf = .{ .path = cmake_config.getFileSource() } } }, .{});

    const install_autoconf_config = b.addInstallFile(autoconf_confing.getFileSource(), "config-autoconf.h");
    b.getInstallStep().dependOn(&install_autoconf_config.step);
}

Jan200101 avatar Jun 26 '23 06:06 Jan200101