diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/apis/add_files_replace/src/config.h | 2 | ||||
| -rw-r--r-- | tests/apis/add_files_replace/src/main.c | 9 | ||||
| -rw-r--r-- | tests/apis/add_files_replace/test.lua | 3 | ||||
| -rw-r--r-- | tests/apis/add_files_replace/xmake.lua | 16 |
4 files changed, 30 insertions, 0 deletions
diff --git a/tests/apis/add_files_replace/src/config.h b/tests/apis/add_files_replace/src/config.h new file mode 100644 index 000000000..96d83f651 --- /dev/null +++ b/tests/apis/add_files_replace/src/config.h @@ -0,0 +1,2 @@ +#pragma once +#define VERSION "1.0" diff --git a/tests/apis/add_files_replace/src/main.c b/tests/apis/add_files_replace/src/main.c new file mode 100644 index 000000000..d2ac8f8ae --- /dev/null +++ b/tests/apis/add_files_replace/src/main.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include "config.h" + +#define HELLO "original" + +int main(int argc, char** argv) { + printf("hello %s, %s!\n", HELLO, VERSION); + return 0; +} diff --git a/tests/apis/add_files_replace/test.lua b/tests/apis/add_files_replace/test.lua new file mode 100644 index 000000000..b57362078 --- /dev/null +++ b/tests/apis/add_files_replace/test.lua @@ -0,0 +1,3 @@ +function main(t) + t:build() +end diff --git a/tests/apis/add_files_replace/xmake.lua b/tests/apis/add_files_replace/xmake.lua new file mode 100644 index 000000000..ee890c9f8 --- /dev/null +++ b/tests/apis/add_files_replace/xmake.lua @@ -0,0 +1,16 @@ +add_rules("mode.debug", "mode.release") + +-- test table replaces +target("test") + set_kind("binary") + add_files("src/main.c", {rules = "utils.replace", replaces = { + {'"original"', '"replaced"'}, + }}) + +-- test function replaces +target("test2") + set_kind("binary") + add_files("src/main.c", {rules = "utils.replace", replaces = function (content) + content = content:gsub('"original"', '"func_replaced"') + return content + end}) |
