From c390f55e727c8f4ace2eb7992403bf8332a22126 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Wed, 19 Feb 2025 09:34:25 +0100 Subject: [PATCH] add a standalone test for autoconf style addConfigHeader --- test/standalone/build.zig.zon | 3 +++ test/standalone/config_header/build.zig | 22 ++++++++++++++++++++++ test/standalone/config_header/config.h | 14 ++++++++++++++ test/standalone/config_header/config.h.in | 12 ++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 test/standalone/config_header/build.zig create mode 100644 test/standalone/config_header/config.h create mode 100644 test/standalone/config_header/config.h.in diff --git a/test/standalone/build.zig.zon b/test/standalone/build.zig.zon index 9863e7cc6d..db1c7125a7 100644 --- a/test/standalone/build.zig.zon +++ b/test/standalone/build.zig.zon @@ -186,6 +186,9 @@ .omit_cfi = .{ .path = "omit_cfi", }, + .config_header = .{ + .path = "config_header", + }, }, .paths = .{ "build.zig", diff --git a/test/standalone/config_header/build.zig b/test/standalone/config_header/build.zig new file mode 100644 index 0000000000..0268b642a7 --- /dev/null +++ b/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); +} diff --git a/test/standalone/config_header/config.h b/test/standalone/config_header/config.h new file mode 100644 index 0000000000..961fdc564f --- /dev/null +++ b/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" + diff --git a/test/standalone/config_header/config.h.in b/test/standalone/config_header/config.h.in new file mode 100644 index 0000000000..0bb37a419c --- /dev/null +++ b/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