Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake-style ConfigHeader deletes last line of input file #16203

Closed
distractedlambda opened this issue Jun 25, 2023 · 1 comment · Fixed by #16220
Closed

CMake-style ConfigHeader deletes last line of input file #16203

distractedlambda opened this issue Jun 25, 2023 · 1 comment · Fixed by #16220
Labels
bug Observed behavior contradicts documented or intended behavior zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@distractedlambda
Copy link

Zig Version

0.11.0-dev.3803+7ad104227

Steps to Reproduce and Observed Behavior

Create a project with a build.zig and config.h.in:

  • build.zig:
const std = @import("std");

pub fn build(b: *std.Build) void {
    const cmake_config = b.addConfigHeader(.{ .style = .{ .cmake = .{ .path = "config.h.in" } } }, .{});
    const install_cmake_config = b.addInstallFile(cmake_config.getFileSource(), "config-cmake.h");
    b.getInstallStep().dependOn(&install_cmake_config.step);

    const autoconf_confing = b.addConfigHeader(.{ .style = .{ .autoconf = .{ .path = "config.h.in" } } }, .{});
    const install_autoconf_config = b.addInstallFile(autoconf_confing.getFileSource(), "config-autoconf.h");
    b.getInstallStep().dependOn(&install_autoconf_config.step);
}
  • config.h.in:
#define FOO
#define BAR

Then run zig build, yielding these outputs:

  • zig-out/config-cmake.h:
/* This file was generated by ConfigHeader using the Zig Build System. */
#define FOO
  • zig-out/config-autoconf.h:
/* This file was generated by ConfigHeader using the Zig Build System. */
#define FOO
#define BAR

Expected Behavior

I would expect both generated config files to have the same effective contents.

@distractedlambda distractedlambda added the bug Observed behavior contradicts documented or intended behavior label Jun 25, 2023
@Jan200101
Copy link
Contributor

introduced by #16037, simple fix will be PR'd soon

@andrewrk andrewrk added the zig build system std.Build, the build runner, `zig build` subcommand, package management label Jun 26, 2023
@andrewrk andrewrk added this to the 0.11.0 milestone Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants