diff --git a/test/standalone/build.zig.zon b/test/standalone/build.zig.zon index 0314bc23ef96091c368cdcb20649c5567aedd92c..de1b97d60bdbe995992a69fe4eb9f55d99e7e3c8 100644 --- a/test/standalone/build.zig.zon +++ b/test/standalone/build.zig.zon @@ -141,9 +141,6 @@ .strip_struct_init = .{ .path = "strip_struct_init", }, - .cmakedefine = .{ - .path = "cmakedefine", - }, .zerolength_check = .{ .path = "zerolength_check", }, diff --git a/test/standalone/cmakedefine/build.zig b/test/standalone/cmakedefine/build.zig deleted file mode 100644 index 78fe1f1cbfc9b2ec07dba6dea6fe808190e37c7d..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/build.zig +++ /dev/null @@ -1,104 +0,0 @@ -const std = @import("std"); -const ConfigHeader = std.Build.Step.ConfigHeader; - -pub fn build(b: *std.Build) void { - const config_header = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("config.h.in") }, - .include_path = "config.h", - }, - .{ - .noval = null, - .trueval = true, - .falseval = false, - .zeroval = 0, - .oneval = 1, - .tenval = 10, - .stringval = "test", - - .boolnoval = {}, - .booltrueval = true, - .boolfalseval = false, - .boolzeroval = 0, - .booloneval = 1, - .booltenval = 10, - .boolstringval = "test", - }, - ); - - const pwd_sh = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("pwd.sh.in") }, - .include_path = "pwd.sh", - }, - .{ .DIR = "${PWD}" }, - ); - - const sigil_header = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("sigil.h.in") }, - .include_path = "sigil.h", - }, - .{}, - ); - - const stack_header = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("stack.h.in") }, - .include_path = "stack.h", - }, - .{ - .UNDERSCORE = "_", - .NEST_UNDERSCORE_PROXY = "UNDERSCORE", - .NEST_PROXY = "NEST_UNDERSCORE_PROXY", - }, - ); - - const wrapper_header = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("wrapper.h.in") }, - .include_path = "wrapper.h", - }, - .{ - .DOLLAR = "$", - .TEXT = "TRAP", - - .STRING = "TEXT", - .STRING_AT = "@STRING@", - .STRING_CURLY = "{STRING}", - .STRING_VAR = "${STRING}", - }, - ); - - const check_exe = b.addExecutable(.{ - .name = "check", - .root_module = b.createModule(.{ - .target = b.graph.host, - .root_source_file = b.path("check.zig"), - }), - }); - - const test_step = b.step("test", "Test it"); - b.default_step = test_step; - test_step.dependOn(addCheck(b, check_exe, config_header)); - test_step.dependOn(addCheck(b, check_exe, pwd_sh)); - test_step.dependOn(addCheck(b, check_exe, sigil_header)); - test_step.dependOn(addCheck(b, check_exe, stack_header)); - test_step.dependOn(addCheck(b, check_exe, wrapper_header)); -} - -fn addCheck( - b: *std.Build, - check_exe: *std.Build.Step.Compile, - ch: *ConfigHeader, -) *std.Build.Step { - // We expect `ch.include_path` to only be a basename to infer where the expected output is. - std.debug.assert(std.fs.path.dirname(ch.include_path) == null); - const expected_path = b.fmt("expected_{s}", .{ch.include_path}); - - const run_check = b.addRunArtifact(check_exe); - run_check.addFileArg(ch.getOutputFile()); - run_check.addFileArg(b.path(expected_path)); - - return &run_check.step; -} diff --git a/test/standalone/cmakedefine/check.zig b/test/standalone/cmakedefine/check.zig deleted file mode 100644 index 58a0762d111815637a86e385345adec1c618c81a..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/check.zig +++ /dev/null @@ -1,26 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); - -pub fn main(init: std.process.Init) !void { - const arena = init.arena.allocator(); - const io = init.io; - const args = try init.minimal.args.toSlice(arena); - - if (args.len != 3) return error.BadUsage; - const actual_path = args[1]; - const expected_path = args[2]; - - const actual = try std.Io.Dir.cwd().readFileAlloc(io, actual_path, arena, .limited(1024 * 1024)); - const expected = try std.Io.Dir.cwd().readFileAlloc(io, expected_path, arena, .limited(1024 * 1024)); - - // The actual output starts with a comment which we should strip out before comparing. - const comment_str = "/* This file was generated by ConfigHeader using the Zig Build System. */\n"; - if (!std.mem.startsWith(u8, actual, comment_str)) { - return error.MissingOrMalformedComment; - } - const actual_without_comment = actual[comment_str.len..]; - - if (builtin.os.tag == .windows) return; // https://codeberg.org/ziglang/zig/issues/30138 - - try std.testing.expectEqualStrings(expected, actual_without_comment); -} diff --git a/test/standalone/cmakedefine/config.h.in b/test/standalone/cmakedefine/config.h.in deleted file mode 100644 index 3f9c60c7523362e952c736a1ba69fbdf9abb3fe2..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/config.h.in +++ /dev/null @@ -1,147 +0,0 @@ -// cmakedefine -// undefined -#cmakedefine noval unreachable - -// 1 -#cmakedefine trueval 1 - -// undefined -#cmakedefine falseval unreachable - -// undefined -#cmakedefine zeroval unreachable - -// 1 -#cmakedefine oneval 1 - -// 1 -#cmakedefine tenval 1 - -// 1 -#cmakedefine stringval 1 - -// whitespace test - #cmakedefine stringval 1 - #cmakedefine stringval 1 - - -// cmakedefine01 -// 0 -#cmakedefine01 boolnoval - -// 1 -#cmakedefine01 booltrueval - -// 0 -#cmakedefine01 boolfalseval - -// 0 -#cmakedefine01 boolzeroval - -// 1 -#cmakedefine01 booloneval - -// 1 -#cmakedefine01 booltenval - -// 1 -#cmakedefine01 boolstringval - - -// @ substition - -// no substition -// @noval@ - -// no substition -// @noval@@noval@ - -// no substition -// @noval@.@noval@ - -// 1 -// @trueval@ - -// 0 -// @falseval@ - -// 10 -// @trueval@@falseval@ - -// 0.1 -// @falseval@.@trueval@ - -// 0 -// @zeroval@ - -// 1 -// @oneval@ - -// 10 -// @tenval@ - -// 01 -// @zeroval@@oneval@ - -// 0.10 -// @zeroval@.@tenval@ - -// test -// @stringval@ - -// testtest -// @stringval@@stringval@ - -// test.test -// @stringval@.@stringval@ - -// test10 -// @noval@@stringval@@trueval@@zeroval@ - -// no substition -// ${noval} - -// no substition -// ${noval}${noval} - -// no substition -// ${noval}.${noval} - -// 1 -// ${trueval} - -// 0 -// ${falseval} - -// 10 -// ${trueval}${falseval} - -// 0.1 -// ${falseval}.${trueval} - -// 0 -// ${zeroval} - -// 1 -// ${oneval} - -// 10 -// ${tenval} - -// 01 -// ${zeroval}${oneval} - -// 0.10 -// ${zeroval}.${tenval} - -// test -// ${stringval} - -// testtest -// ${stringval}${stringval} - -// test.test -// ${stringval}.${stringval} - -// test10 -// ${noval}${stringval}${trueval}${zeroval} diff --git a/test/standalone/cmakedefine/expected_config.h b/test/standalone/cmakedefine/expected_config.h deleted file mode 100644 index 9ebe80956e3264d6c33aaa2dbc06f735a30dce33..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/expected_config.h +++ /dev/null @@ -1,147 +0,0 @@ -// cmakedefine -// undefined -/* #undef noval */ - -// 1 -#define trueval 1 - -// undefined -/* #undef falseval */ - -// undefined -/* #undef zeroval */ - -// 1 -#define oneval 1 - -// 1 -#define tenval 1 - -// 1 -#define stringval 1 - -// whitespace test - #define stringval 1 - #define stringval 1 - - -// cmakedefine01 -// 0 -#define boolnoval 0 - -// 1 -#define booltrueval 1 - -// 0 -#define boolfalseval 0 - -// 0 -#define boolzeroval 0 - -// 1 -#define booloneval 1 - -// 1 -#define booltenval 1 - -// 1 -#define boolstringval 1 - - -// @ substition - -// no substition -// - -// no substition -// - -// no substition -// . - -// 1 -// 1 - -// 0 -// 0 - -// 10 -// 10 - -// 0.1 -// 0.1 - -// 0 -// 0 - -// 1 -// 1 - -// 10 -// 10 - -// 01 -// 01 - -// 0.10 -// 0.10 - -// test -// test - -// testtest -// testtest - -// test.test -// test.test - -// test10 -// test10 - -// no substition -// - -// no substition -// - -// no substition -// . - -// 1 -// 1 - -// 0 -// 0 - -// 10 -// 10 - -// 0.1 -// 0.1 - -// 0 -// 0 - -// 1 -// 1 - -// 10 -// 10 - -// 01 -// 01 - -// 0.10 -// 0.10 - -// test -// test - -// testtest -// testtest - -// test.test -// test.test - -// test10 -// test10 diff --git a/test/standalone/cmakedefine/expected_pwd.sh b/test/standalone/cmakedefine/expected_pwd.sh deleted file mode 100644 index 7e1d44c8eb0ee4b373be12c9e652653b6d228587..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/expected_pwd.sh +++ /dev/null @@ -1 +0,0 @@ -echo ${PWD} diff --git a/test/standalone/cmakedefine/expected_sigil.h b/test/standalone/cmakedefine/expected_sigil.h deleted file mode 100644 index 10108f4d1e2fdd3c4a685a8501596a77291b0c1f..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/expected_sigil.h +++ /dev/null @@ -1,4 +0,0 @@ -#define AT @ -#define ATAT @@ -#define ATATAT @@@ -#define ATATATAT @@@@ diff --git a/test/standalone/cmakedefine/expected_stack.h b/test/standalone/cmakedefine/expected_stack.h deleted file mode 100644 index 940d68d13e2f6d98ea518ae031a42c3944d4cf7a..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/expected_stack.h +++ /dev/null @@ -1,3 +0,0 @@ -#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY - -#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY diff --git a/test/standalone/cmakedefine/expected_wrapper.h b/test/standalone/cmakedefine/expected_wrapper.h deleted file mode 100644 index cbd6aabdcae959adef77256dc958999a41f07d0f..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/expected_wrapper.h +++ /dev/null @@ -1,30 +0,0 @@ -// becomes TEXT -#define TEXT -#define TEXT - -// becomes `at`TEXT`at` -#define @TEXT@ -#define @TEXT@ - -// becomes TRAP -#define TRAP - -// becomes `dollar sign`{STRING} -#define ${STRING} -#define ${STRING} - -// becomes `dollar sign`{STRING} -#define ${STRING} -#define ${STRING} - -// becomes `dollar sign`{TEXT} -#define ${TEXT} -#define ${TEXT} - -// becomes `at`STRING`at` -#define @STRING@ -#define @STRING@ - -#define \@STRING_VAR\@ -#define \${STRING} -#define $\{STRING_VAR} diff --git a/test/standalone/cmakedefine/pwd.sh.in b/test/standalone/cmakedefine/pwd.sh.in deleted file mode 100644 index 9e4d91207ee88cfdea37fe21d0d981ae674bdcd3..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/pwd.sh.in +++ /dev/null @@ -1 +0,0 @@ -echo @DIR@ diff --git a/test/standalone/cmakedefine/sigil.h.in b/test/standalone/cmakedefine/sigil.h.in deleted file mode 100644 index 10108f4d1e2fdd3c4a685a8501596a77291b0c1f..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/sigil.h.in +++ /dev/null @@ -1,4 +0,0 @@ -#define AT @ -#define ATAT @@ -#define ATATAT @@@ -#define ATATATAT @@@@ diff --git a/test/standalone/cmakedefine/stack.h.in b/test/standalone/cmakedefine/stack.h.in deleted file mode 100644 index 91fdd8a26516634e7cce1779c276ca5e30a0a2a9..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/stack.h.in +++ /dev/null @@ -1,3 +0,0 @@ -#define NEST_UNDERSCORE_PROXY ${NEST${UNDERSCORE}PROXY} - -#define NEST_UNDERSCORE_PROXY ${NEST${${NEST_UNDERSCORE${UNDERSCORE}PROXY}}PROXY} diff --git a/test/standalone/cmakedefine/wrapper.h.in b/test/standalone/cmakedefine/wrapper.h.in deleted file mode 100644 index d2334fa9b79c624bfb72c4dcae19b38f57e2cc13..0000000000000000000000000000000000000000 --- a/test/standalone/cmakedefine/wrapper.h.in +++ /dev/null @@ -1,30 +0,0 @@ -// becomes TEXT -#define @STRING@ -#define ${STRING} - -// becomes `at`TEXT`at` -#define @${STRING}@ -#define @@STRING@@ - -// becomes TRAP -#define ${@STRING@} - -// becomes `dollar sign`{STRING} -#define $@STRING_CURLY@ -#define $${STRING_CURLY} - -// becomes `dollar sign`{STRING} -#define @STRING_VAR@ -#define ${STRING_VAR} - -// becomes `dollar sign`{TEXT} -#define ${DOLLAR}{${STRING}} -#define @DOLLAR@{${STRING}} - -// becomes `at`STRING`at` -#define ${STRING_AT} -#define @STRING_AT@ - -#define \@STRING_VAR\@ -#define \${STRING_VAR} -#define $\{STRING_VAR} diff --git a/test/standalone/config_header/autoconf_undef/config.h b/test/standalone/config_header/autoconf_undef/config.h new file mode 100644 index 0000000000000000000000000000000000000000..ef5b4abab30499feb5c82019ae8750e82b059512 --- /dev/null +++ b/test/standalone/config_header/autoconf_undef/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 */ +// TODO: unexpected newline is being added here diff --git a/test/standalone/config_header/autoconf_undef/config.h.in b/test/standalone/config_header/autoconf_undef/config.h.in new file mode 100644 index 0000000000000000000000000000000000000000..fafc3587658162eaae0c918320df9752b779086d --- /dev/null +++ b/test/standalone/config_header/autoconf_undef/config.h.in @@ -0,0 +1,22 @@ +/* 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 +// TODO: unexpected newline is being added here \ No newline at end of file diff --git a/test/standalone/config_header/build.zig b/test/standalone/config_header/build.zig index f24f6dbdb85bdd52da968c17c680744f97660615..15ad4112bf91ef74d965b8c44fb469ec86d00bee 100644 --- a/test/standalone/config_header/build.zig +++ b/test/standalone/config_header/build.zig @@ -5,7 +5,9 @@ pub fn build(b: *std.Build) void { b.default_step = test_step; const config_header = b.addConfigHeader( - .{ .style = .{ .autoconf_undef = b.path("config.h.in") } }, + .{ .style = .{ + .autoconf_undef = b.path("autoconf_undef/config.h.in"), + } }, .{ .SOME_NO = null, .SOME_TRUE = true, @@ -23,8 +25,9 @@ pub fn build(b: *std.Build) void { .POSTFIX_TAB = null, }, ); - - const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ .expected_exact = @embedFile("config.h") }); + const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ + .expected_exact = @embedFile("autoconf_undef/config.h"), + }); const config_header_autoconf_at = b.addConfigHeader( .{ .style = .{ @@ -46,4 +49,137 @@ pub fn build(b: *std.Build) void { test_step.dependOn(&check_config_header.step); test_step.dependOn(&check_config_header_autoconf_at.step); + addCmakeChecks(b, test_step); +} + +fn addCmakeChecks(b: *std.Build, test_step: *std.Build.Step) void { + const config_header = b.addConfigHeader( + .{ + .style = .{ .cmake = b.path("cmake/config.h.in") }, + .include_path = "config.h", + }, + .{ + .noval = null, + .trueval = true, + .falseval = false, + .zeroval = 0, + .oneval = 1, + .tenval = 10, + .stringval = "test", + + .boolnoval = {}, + .booltrueval = true, + .boolfalseval = false, + .boolzeroval = 0, + .booloneval = 1, + .booltenval = 10, + .boolstringval = "test", + }, + ); + const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/expected_config.h"), + }); + test_step.dependOn(&check_config_header.step); + + const pwd_sh = b.addConfigHeader( + .{ + .style = .{ .cmake = b.path("cmake/pwd.sh.in") }, + .include_path = "pwd.sh", + }, + .{ .DIR = "${PWD}" }, + ); + const check_pwd_sh = b.addCheckFile(pwd_sh.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/expected_pwd.sh"), + }); + test_step.dependOn(&check_pwd_sh.step); + + const sigil_header = b.addConfigHeader( + .{ + .style = .{ .cmake = b.path("cmake/sigil.h.in") }, + .include_path = "sigil.h", + }, + .{}, + ); + const check_sigil_header = b.addCheckFile(sigil_header.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/expected_sigil.h"), + }); + test_step.dependOn(&check_sigil_header.step); + + const stack_header = b.addConfigHeader( + .{ + .style = .{ .cmake = b.path("cmake/stack.h.in") }, + .include_path = "stack.h", + }, + .{ + .UNDERSCORE = "_", + .NEST_UNDERSCORE_PROXY = "UNDERSCORE", + .NEST_PROXY = "NEST_UNDERSCORE_PROXY", + }, + ); + const check_stack_header = b.addCheckFile(stack_header.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/expected_stack.h"), + }); + test_step.dependOn(&check_stack_header.step); + + const wrapper_header = b.addConfigHeader( + .{ + .style = .{ .cmake = b.path("cmake/wrapper.h.in") }, + .include_path = "wrapper.h", + }, + .{ + .DOLLAR = "$", + .TEXT = "TRAP", + + .STRING = "TEXT", + .STRING_AT = "@STRING@", + .STRING_CURLY = "{STRING}", + .STRING_VAR = "${STRING}", + }, + ); + const check_wrapper_header = b.addCheckFile(wrapper_header.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/expected_wrapper.h"), + }); + test_step.dependOn(&check_wrapper_header.step); + + const config_header_cmake = b.addConfigHeader( + .{ .style = .{ + .cmake = b.path("cmake/cmake.txt.in"), + } }, + .{ + .undef = null, + .defined = {}, + .true = true, + .false = false, + .int = 42, + .ident = "value", + .string = "text", + }, + ); + const check_config_header_cmake = b.addCheckFile(config_header_cmake.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/cmake.txt"), + }); + test_step.dependOn(&check_config_header_cmake.step); + + const config_header_cmake_edge_cases = b.addConfigHeader( + .{ .style = .{ + .cmake = b.path("cmake/cmake_edge_cases.txt.in"), + } }, + .{ + // .at = "@", + // .trueval = true, + .dollar = "$", + .underscore = "_", + .string = "text", + .string_proxy = "string", + .string_at = "@string@", + .string_curly = "{string}", + .string_var = "${string}", + .nest_underscore_proxy = "underscore", + .nest_proxy = "nest_underscore_proxy", + }, + ); + const check_config_header_cmake_edge_cases = b.addCheckFile(config_header_cmake_edge_cases.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/cmake_edge_cases.txt"), + }); + test_step.dependOn(&check_config_header_cmake_edge_cases.step); } diff --git a/test/standalone/config_header/cmake/cmake.txt b/test/standalone/config_header/cmake/cmake.txt new file mode 100644 index 0000000000000000000000000000000000000000..782ab0f6d5e44b8b87547592c498388c04f19931 --- /dev/null +++ b/test/standalone/config_header/cmake/cmake.txt @@ -0,0 +1,66 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +// empty strings are preserved + +// line with misc content is preserved +no substitution + +// empty @ sigils are preserved +@ +@@ +@@@ +@@@@ + +// simple substitution + + + + +1 +1 +0 +0 +42 +42 +value +value +text +text + +// double packed substitution +texttext +texttext + +// triple packed substitution +text42text +text42text +text42text +text42text + +// double separated substitution +42.42 +42.42 + +// triple separated substitution +42.1.42 +42.1.42 +42.1.42 +42.1.42 + +// misc prefix is preserved +false is 0 +false is 0 + +// misc suffix is preserved +1 is true +1 is true + +// surrounding content is preserved +what is 6*7? 42! +what is 6*7? 42! + +// incomplete key is preserved +@undef +${undef +{undef} +undef@ +undef} diff --git a/test/standalone/config_header/cmake/cmake.txt.in b/test/standalone/config_header/cmake/cmake.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..bef9fb7a2b7eb74a3870bb80c3a22256bb6e9fa0 --- /dev/null +++ b/test/standalone/config_header/cmake/cmake.txt.in @@ -0,0 +1,65 @@ +// empty strings are preserved + +// line with misc content is preserved +no substitution + +// empty @ sigils are preserved +@ +@@ +@@@ +@@@@ + +// simple substitution +@undef@ +${undef} +@defined@ +${defined} +@true@ +${true} +@false@ +${false} +@int@ +${int} +@ident@ +${ident} +@string@ +${string} + +// double packed substitution +@string@@string@ +${string}${string} + +// triple packed substitution +@string@@int@@string@ +@string@${int}@string@ +${string}@int@${string} +${string}${int}${string} + +// double separated substitution +@int@.@int@ +${int}.${int} + +// triple separated substitution +@int@.@true@.@int@ +@int@.${true}.@int@ +${int}.@true@.${int} +${int}.${true}.${int} + +// misc prefix is preserved +false is @false@ +false is ${false} + +// misc suffix is preserved +@true@ is true +${true} is true + +// surrounding content is preserved +what is 6*7? @int@! +what is 6*7? ${int}! + +// incomplete key is preserved +@undef +${undef +{undef} +undef@ +undef} diff --git a/test/standalone/config_header/cmake/cmake_edge_cases.txt b/test/standalone/config_header/cmake/cmake_edge_cases.txt new file mode 100644 index 0000000000000000000000000000000000000000..e88fa5faeac3e473bd44062ca17d88522f233240 --- /dev/null +++ b/test/standalone/config_header/cmake/cmake_edge_cases.txt @@ -0,0 +1,38 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +// empty lines are preserved + +// @-substition tests +// @-vars resolved only when they wrap valid characters, otherwise considered literals +@text@ +@text@ + +// at-vars are resolved inside curly-vars +text + +// expanded variables are considered strings after expansion +@string@ +@string@ +${string} +${string} +${string} +${string} +${text} +${text} +${text} + +// nested expanded variables are expanded from the inside out +string +string + +// nested vars are only expanded when curly braces are closed +nest_underscore_proxy +nest_underscore_proxy + +// backslash is an invalid character for @ lookup +\@string\@ + +// backslash is preserved, but doesn't affect $curly-braces variable expansion +\text + +// backslash breaks $curly-braces opening bracket identification +$\{string} diff --git a/test/standalone/config_header/cmake/cmake_edge_cases.txt.in b/test/standalone/config_header/cmake/cmake_edge_cases.txt.in new file mode 100644 index 0000000000000000000000000000000000000000..21ef8d68052c8d0c1bf1fdb0595ebf9eec75e6c1 --- /dev/null +++ b/test/standalone/config_header/cmake/cmake_edge_cases.txt.in @@ -0,0 +1,37 @@ +// empty lines are preserved + +// @-substition tests +// @-vars resolved only when they wrap valid characters, otherwise considered literals +@@string@@ +@${string}@ + +// at-vars are resolved inside curly-vars +${@string_proxy@} + +// expanded variables are considered strings after expansion +@string_at@ +${string_at} +$@string_curly@ +$${string_curly} +${string_var} +@string_var@ +${dollar}{${string}} +@dollar@{${string}} +@dollar@{@string@} + +// nested expanded variables are expanded from the inside out +${string${underscore}proxy} +${string@underscore@proxy} + +// nested vars are only expanded when curly braces are closed +${nest${underscore}proxy} +${nest${${nest_underscore${underscore}proxy}}proxy} + +// backslash is an invalid character for @ lookup +\@string\@ + +// backslash is preserved, but doesn't affect $curly-braces variable expansion +\${string} + +// backslash breaks $curly-braces opening bracket identification +$\{string} diff --git a/test/standalone/config_header/cmake/config.h.in b/test/standalone/config_header/cmake/config.h.in new file mode 100644 index 0000000000000000000000000000000000000000..3f9c60c7523362e952c736a1ba69fbdf9abb3fe2 --- /dev/null +++ b/test/standalone/config_header/cmake/config.h.in @@ -0,0 +1,147 @@ +// cmakedefine +// undefined +#cmakedefine noval unreachable + +// 1 +#cmakedefine trueval 1 + +// undefined +#cmakedefine falseval unreachable + +// undefined +#cmakedefine zeroval unreachable + +// 1 +#cmakedefine oneval 1 + +// 1 +#cmakedefine tenval 1 + +// 1 +#cmakedefine stringval 1 + +// whitespace test + #cmakedefine stringval 1 + #cmakedefine stringval 1 + + +// cmakedefine01 +// 0 +#cmakedefine01 boolnoval + +// 1 +#cmakedefine01 booltrueval + +// 0 +#cmakedefine01 boolfalseval + +// 0 +#cmakedefine01 boolzeroval + +// 1 +#cmakedefine01 booloneval + +// 1 +#cmakedefine01 booltenval + +// 1 +#cmakedefine01 boolstringval + + +// @ substition + +// no substition +// @noval@ + +// no substition +// @noval@@noval@ + +// no substition +// @noval@.@noval@ + +// 1 +// @trueval@ + +// 0 +// @falseval@ + +// 10 +// @trueval@@falseval@ + +// 0.1 +// @falseval@.@trueval@ + +// 0 +// @zeroval@ + +// 1 +// @oneval@ + +// 10 +// @tenval@ + +// 01 +// @zeroval@@oneval@ + +// 0.10 +// @zeroval@.@tenval@ + +// test +// @stringval@ + +// testtest +// @stringval@@stringval@ + +// test.test +// @stringval@.@stringval@ + +// test10 +// @noval@@stringval@@trueval@@zeroval@ + +// no substition +// ${noval} + +// no substition +// ${noval}${noval} + +// no substition +// ${noval}.${noval} + +// 1 +// ${trueval} + +// 0 +// ${falseval} + +// 10 +// ${trueval}${falseval} + +// 0.1 +// ${falseval}.${trueval} + +// 0 +// ${zeroval} + +// 1 +// ${oneval} + +// 10 +// ${tenval} + +// 01 +// ${zeroval}${oneval} + +// 0.10 +// ${zeroval}.${tenval} + +// test +// ${stringval} + +// testtest +// ${stringval}${stringval} + +// test.test +// ${stringval}.${stringval} + +// test10 +// ${noval}${stringval}${trueval}${zeroval} diff --git a/test/standalone/config_header/cmake/expected_config.h b/test/standalone/config_header/cmake/expected_config.h new file mode 100644 index 0000000000000000000000000000000000000000..c38418b6df3021a671c431e071c7caa374bbf5cd --- /dev/null +++ b/test/standalone/config_header/cmake/expected_config.h @@ -0,0 +1,148 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +// cmakedefine +// undefined +/* #undef noval */ + +// 1 +#define trueval 1 + +// undefined +/* #undef falseval */ + +// undefined +/* #undef zeroval */ + +// 1 +#define oneval 1 + +// 1 +#define tenval 1 + +// 1 +#define stringval 1 + +// whitespace test + #define stringval 1 + #define stringval 1 + + +// cmakedefine01 +// 0 +#define boolnoval 0 + +// 1 +#define booltrueval 1 + +// 0 +#define boolfalseval 0 + +// 0 +#define boolzeroval 0 + +// 1 +#define booloneval 1 + +// 1 +#define booltenval 1 + +// 1 +#define boolstringval 1 + + +// @ substition + +// no substition +// + +// no substition +// + +// no substition +// . + +// 1 +// 1 + +// 0 +// 0 + +// 10 +// 10 + +// 0.1 +// 0.1 + +// 0 +// 0 + +// 1 +// 1 + +// 10 +// 10 + +// 01 +// 01 + +// 0.10 +// 0.10 + +// test +// test + +// testtest +// testtest + +// test.test +// test.test + +// test10 +// test10 + +// no substition +// + +// no substition +// + +// no substition +// . + +// 1 +// 1 + +// 0 +// 0 + +// 10 +// 10 + +// 0.1 +// 0.1 + +// 0 +// 0 + +// 1 +// 1 + +// 10 +// 10 + +// 01 +// 01 + +// 0.10 +// 0.10 + +// test +// test + +// testtest +// testtest + +// test.test +// test.test + +// test10 +// test10 diff --git a/test/standalone/config_header/cmake/expected_pwd.sh b/test/standalone/config_header/cmake/expected_pwd.sh new file mode 100644 index 0000000000000000000000000000000000000000..929ee58b393a1173c4d3e2740d034ff6e5d1101f --- /dev/null +++ b/test/standalone/config_header/cmake/expected_pwd.sh @@ -0,0 +1,2 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +echo ${PWD} diff --git a/test/standalone/config_header/cmake/expected_sigil.h b/test/standalone/config_header/cmake/expected_sigil.h new file mode 100644 index 0000000000000000000000000000000000000000..1f0f5c0e329dabbc3d6b8ae245c69a91b18b9eaa --- /dev/null +++ b/test/standalone/config_header/cmake/expected_sigil.h @@ -0,0 +1,5 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +#define AT @ +#define ATAT @@ +#define ATATAT @@@ +#define ATATATAT @@@@ diff --git a/test/standalone/config_header/cmake/expected_stack.h b/test/standalone/config_header/cmake/expected_stack.h new file mode 100644 index 0000000000000000000000000000000000000000..598bc0a310ada8f00d0b8bf64ce0562e4e5681b7 --- /dev/null +++ b/test/standalone/config_header/cmake/expected_stack.h @@ -0,0 +1,4 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY + +#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY diff --git a/test/standalone/config_header/cmake/expected_wrapper.h b/test/standalone/config_header/cmake/expected_wrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..1f78d22ee9ae778e833c98e784f284c04ac47dfb --- /dev/null +++ b/test/standalone/config_header/cmake/expected_wrapper.h @@ -0,0 +1,31 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +// becomes TEXT +#define TEXT +#define TEXT + +// becomes `at`TEXT`at` +#define @TEXT@ +#define @TEXT@ + +// becomes TRAP +#define TRAP + +// becomes `dollar sign`{STRING} +#define ${STRING} +#define ${STRING} + +// becomes `dollar sign`{STRING} +#define ${STRING} +#define ${STRING} + +// becomes `dollar sign`{TEXT} +#define ${TEXT} +#define ${TEXT} + +// becomes `at`STRING`at` +#define @STRING@ +#define @STRING@ + +#define \@STRING_VAR\@ +#define \${STRING} +#define $\{STRING_VAR} diff --git a/test/standalone/config_header/cmake/pwd.sh.in b/test/standalone/config_header/cmake/pwd.sh.in new file mode 100644 index 0000000000000000000000000000000000000000..9e4d91207ee88cfdea37fe21d0d981ae674bdcd3 --- /dev/null +++ b/test/standalone/config_header/cmake/pwd.sh.in @@ -0,0 +1 @@ +echo @DIR@ diff --git a/test/standalone/config_header/cmake/sigil.h.in b/test/standalone/config_header/cmake/sigil.h.in new file mode 100644 index 0000000000000000000000000000000000000000..10108f4d1e2fdd3c4a685a8501596a77291b0c1f --- /dev/null +++ b/test/standalone/config_header/cmake/sigil.h.in @@ -0,0 +1,4 @@ +#define AT @ +#define ATAT @@ +#define ATATAT @@@ +#define ATATATAT @@@@ diff --git a/test/standalone/config_header/cmake/stack.h.in b/test/standalone/config_header/cmake/stack.h.in new file mode 100644 index 0000000000000000000000000000000000000000..91fdd8a26516634e7cce1779c276ca5e30a0a2a9 --- /dev/null +++ b/test/standalone/config_header/cmake/stack.h.in @@ -0,0 +1,3 @@ +#define NEST_UNDERSCORE_PROXY ${NEST${UNDERSCORE}PROXY} + +#define NEST_UNDERSCORE_PROXY ${NEST${${NEST_UNDERSCORE${UNDERSCORE}PROXY}}PROXY} diff --git a/test/standalone/config_header/cmake/wrapper.h.in b/test/standalone/config_header/cmake/wrapper.h.in new file mode 100644 index 0000000000000000000000000000000000000000..d2334fa9b79c624bfb72c4dcae19b38f57e2cc13 --- /dev/null +++ b/test/standalone/config_header/cmake/wrapper.h.in @@ -0,0 +1,30 @@ +// becomes TEXT +#define @STRING@ +#define ${STRING} + +// becomes `at`TEXT`at` +#define @${STRING}@ +#define @@STRING@@ + +// becomes TRAP +#define ${@STRING@} + +// becomes `dollar sign`{STRING} +#define $@STRING_CURLY@ +#define $${STRING_CURLY} + +// becomes `dollar sign`{STRING} +#define @STRING_VAR@ +#define ${STRING_VAR} + +// becomes `dollar sign`{TEXT} +#define ${DOLLAR}{${STRING}} +#define @DOLLAR@{${STRING}} + +// becomes `at`STRING`at` +#define ${STRING_AT} +#define @STRING_AT@ + +#define \@STRING_VAR\@ +#define \${STRING_VAR} +#define $\{STRING_VAR} diff --git a/test/standalone/config_header/config.h b/test/standalone/config_header/config.h deleted file mode 100644 index 22b5fb5697d5fa47ee4bc6a4b7d00d6360aac9f8..0000000000000000000000000000000000000000 --- a/test/standalone/config_header/config.h +++ /dev/null @@ -1,23 +0,0 @@ -/* 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 deleted file mode 100644 index c1b8fe7236fb57384347fbeb972db2850d44edf3..0000000000000000000000000000000000000000 --- a/test/standalone/config_header/config.h.in +++ /dev/null @@ -1,21 +0,0 @@ -/* 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