Commit c390f55e72

Techatrix <techatrix@mailbox.org>
2025-02-19 09:34:25
add a standalone test for autoconf style addConfigHeader
1 parent 0cf6ae2
Changed files (4)
test
test/standalone/config_header/build.zig
@@ -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);
+}
test/standalone/config_header/config.h
@@ -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"
+
test/standalone/config_header/config.h.in
@@ -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
test/standalone/build.zig.zon
@@ -186,6 +186,9 @@
         .omit_cfi = .{
             .path = "omit_cfi",
         },
+        .config_header = .{
+            .path = "config_header",
+        },
     },
     .paths = .{
         "build.zig",