add a standalone test for autoconf style addConfigHeader

This commit is contained in:
Techatrix 2025-02-19 09:34:25 +01:00
parent 0cf6ae290b
commit c390f55e72
No known key found for this signature in database
4 changed files with 51 additions and 0 deletions

View File

@ -186,6 +186,9 @@
.omit_cfi = .{
.path = "omit_cfi",
},
.config_header = .{
.path = "config_header",
},
},
.paths = .{
"build.zig",

View File

@ -0,0 +1,22 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const config_header = b.addConfigHeader(
.{ .style = .{ .autoconf = b.path("config.h.in") } },
.{
.SOME_NO = null,
.SOME_TRUE = true,
.SOME_FALSE = false,
.SOME_ZERO = 0,
.SOME_ONE = 1,
.SOME_TEN = 10,
.SOME_ENUM_LITERAL = .@"test",
.SOME_STRING = "test",
},
);
const check_config_header = b.addCheckFile(config_header.getOutput(), .{ .expected_exact = @embedFile("config.h") });
const test_step = b.step("test", "Test it");
test_step.dependOn(&check_config_header.step);
}

View File

@ -0,0 +1,14 @@
/* This file was generated by ConfigHeader using the Zig Build System. */
/* Some Comment */
int foo();
/* #undef SOME_NO */
#define SOME_TRUE 1
#define SOME_FALSE 0
#define SOME_ZERO 0
#define SOME_ONE 1
#define SOME_TEN 10
#define SOME_ENUM_LITERAL test
#define SOME_STRING "test"

View File

@ -0,0 +1,12 @@
/* Some Comment */
int foo();
#undef SOME_NO
#undef SOME_TRUE
#undef SOME_FALSE
#undef SOME_ZERO
#undef SOME_ONE
#undef SOME_TEN
#undef SOME_ENUM_LITERAL
#undef SOME_STRING