diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-02-22 00:25:09 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-22 00:25:09 -0500 |
| commit | a7467b9bb2aa667a8d34bc8b678ce35fcb19ebd4 (patch) | |
| tree | ddfd13e95e409cb787aba1fb875596912312d59a /test | |
| parent | 300cb4881f675140d89a8bbd889d51490701fbac (diff) | |
| parent | c1c6f082961a2735ff3c91167f0e1bcfcfcc2010 (diff) | |
| download | zig-a7467b9bb2aa667a8d34bc8b678ce35fcb19ebd4.tar.gz zig-a7467b9bb2aa667a8d34bc8b678ce35fcb19ebd4.zip | |
Merge pull request #22941 from Techatrix/config-header
std.Build.Step.ConfigHeader: improve handling of autoconf style headers
Diffstat (limited to 'test')
| -rw-r--r-- | test/standalone/build.zig.zon | 3 | ||||
| -rw-r--r-- | test/standalone/config_header/build.zig | 28 | ||||
| -rw-r--r-- | test/standalone/config_header/config.h | 23 | ||||
| -rw-r--r-- | test/standalone/config_header/config.h.in | 21 |
4 files changed, 75 insertions, 0 deletions
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..423e9d3823 --- /dev/null +++ b/test/standalone/config_header/build.zig @@ -0,0 +1,28 @@ +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 = @as(enum { foo, bar }, .foo), + .SOME_ENUM_LITERAL = .@"test", + .SOME_STRING = "test", + + .PREFIX_SPACE = null, + .PREFIX_TAB = null, + .POSTFIX_SPACE = null, + .POSTFIX_TAB = null, + }, + ); + + 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..22b5fb5697 --- /dev/null +++ b/test/standalone/config_header/config.h @@ -0,0 +1,23 @@ +/* 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 foo +#define SOME_ENUM_LITERAL test +#define SOME_STRING "test" + +// Used twice +#define SOME_TRUE 1 + +/* #undef PREFIX_SPACE */ +/* #undef PREFIX_TAB */ +/* #undef POSTFIX_SPACE */ +/* #undef POSTFIX_TAB */ + diff --git a/test/standalone/config_header/config.h.in b/test/standalone/config_header/config.h.in new file mode 100644 index 0000000000..c1b8fe7236 --- /dev/null +++ b/test/standalone/config_header/config.h.in @@ -0,0 +1,21 @@ +/* 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 +#undef SOME_ENUM_LITERAL +#undef SOME_STRING + +// Used twice +#undef SOME_TRUE + +#undef PREFIX_SPACE +#undef PREFIX_TAB +#undef POSTFIX_SPACE +#undef POSTFIX_TAB |
