zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit c390f55e727c8f4ace2eb7992403bf8332a22126 (tree)
parent 0cf6ae290b97e7fee7e37b5c487fd3e6b35248b3
Author: Techatrix <techatrix@mailbox.org>
Date:   Wed, 19 Feb 2025 09:34:25 +0100

add a standalone test for autoconf style addConfigHeader

Diffstat:
Mtest/standalone/build.zig.zon | 3+++
Atest/standalone/config_header/build.zig | 22++++++++++++++++++++++
Atest/standalone/config_header/config.h | 14++++++++++++++
Atest/standalone/config_header/config.h.in | 12++++++++++++
4 files changed, 51 insertions(+), 0 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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