zig icon indicating copy to clipboard operation
zig copied to clipboard

Remove comment header from generated output of Build.ConfigHeader

Open g012 opened this issue 1 year ago • 3 comments

Zig Version

0.12.0-dev.3161+377ecc6af

Steps to Reproduce and Observed Behavior

When using b.addConfigHeader() in build.zig, a C or ASM comment is forcefully prepended in the generated output file ; from ConfigHeader.zig:

    const header_text = "This file was generated by ConfigHeader using the Zig Build System.";
    const c_generated_line = "/* " ++ header_text ++ " */\n";
    const asm_generated_line = "; " ++ header_text ++ "\n";
...
            try output.appendSlice(c_generated_line);

I use ConfigHeader with an existing lua.in file to generate a Lua file, as I'm migrating from CMake to build.zig, and in Lua /* */ or ; comments are invalid. Can you add an option to customize and remove this automatically added comment ?

Expected Behavior

I would like no extra text added to the generated file of ConfigHeader.

g012 avatar Mar 12 '24 14:03 g012

Real-world example here: https://github.com/g012/l65/blob/master/build.zig

g012 avatar Mar 12 '24 15:03 g012

Sure, go ahead and add the option. This is a contributor-friendly enhancement.

andrewrk avatar Apr 06 '24 21:04 andrewrk

@andrewrk #20018 This should solve the issue. It implements some suggestions from https://github.com/ziglang/zig/pull/19277#pullrequestreview-2032869151

Lking03x avatar May 05 '24 08:05 Lking03x