Complicated pre-build and post-build steps in build.zig

Possibly I don’t understand this magic

    const tool = b.addExecutable(.{
        .name = "generate_struct",
        .root_source_file = b.path("tools/generate_struct.zig"),
        .target = b.graph.host,
    });

In this example file tools/generate_struct.zig exists in the local repo

For my case all source code of generator saved in remote repo

Looks like I need to do something similar to Fetching dependencies without build.zig.zon?