diff options
| author | ruki <[email protected]> | 2025-01-07 00:40:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-07 00:40:57 +0800 |
| commit | ae8a596c609e01b21caa5825f3fd2eec0bdb7507 (patch) | |
| tree | 20ab76b862913222a52c932d5688eb9c0dc176b3 /tests | |
| parent | f6904d729ce7ca99fad237e5e0641ee015b97faf (diff) | |
support for inner namespace access
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/apis/namespace/inner/.gitignore | 8 | ||||
| -rw-r--r-- | tests/apis/namespace/inner/src/bar.cpp | 5 | ||||
| -rw-r--r-- | tests/apis/namespace/inner/src/bar.h | 9 | ||||
| -rw-r--r-- | tests/apis/namespace/inner/src/foo.cpp | 5 | ||||
| -rw-r--r-- | tests/apis/namespace/inner/src/foo.h | 9 | ||||
| -rw-r--r-- | tests/apis/namespace/inner/src/main.cpp | 9 | ||||
| -rw-r--r-- | tests/apis/namespace/inner/test.lua | 3 | ||||
| -rw-r--r-- | tests/apis/namespace/inner/xmake.lua | 19 |
8 files changed, 67 insertions, 0 deletions
diff --git a/tests/apis/namespace/inner/.gitignore b/tests/apis/namespace/inner/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/apis/namespace/inner/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/apis/namespace/inner/src/bar.cpp b/tests/apis/namespace/inner/src/bar.cpp new file mode 100644 index 000000000..2c00cc6b6 --- /dev/null +++ b/tests/apis/namespace/inner/src/bar.cpp @@ -0,0 +1,5 @@ +#include "bar.h" + +int sub(int a, int b) { + return a - b; +} diff --git a/tests/apis/namespace/inner/src/bar.h b/tests/apis/namespace/inner/src/bar.h new file mode 100644 index 000000000..47d8a7251 --- /dev/null +++ b/tests/apis/namespace/inner/src/bar.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif + +int sub(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/apis/namespace/inner/src/foo.cpp b/tests/apis/namespace/inner/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/tests/apis/namespace/inner/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/tests/apis/namespace/inner/src/foo.h b/tests/apis/namespace/inner/src/foo.h new file mode 100644 index 000000000..d2506bca9 --- /dev/null +++ b/tests/apis/namespace/inner/src/foo.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif + +int add(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/tests/apis/namespace/inner/src/main.cpp b/tests/apis/namespace/inner/src/main.cpp new file mode 100644 index 000000000..4cf7b5e62 --- /dev/null +++ b/tests/apis/namespace/inner/src/main.cpp @@ -0,0 +1,9 @@ +#include "foo.h" +#include "bar.h" +#include <iostream> + +int main(int argc, char** argv) { + std::cout << "add(1, 2) = " << add(1, 2) << std::endl; + std::cout << "sub(2, 1) = " << sub(2, 1) << std::endl; + return 0; +} diff --git a/tests/apis/namespace/inner/test.lua b/tests/apis/namespace/inner/test.lua new file mode 100644 index 000000000..83c0a9546 --- /dev/null +++ b/tests/apis/namespace/inner/test.lua @@ -0,0 +1,3 @@ +function main() + os.exec("xmake -vD") +end diff --git a/tests/apis/namespace/inner/xmake.lua b/tests/apis/namespace/inner/xmake.lua new file mode 100644 index 000000000..c18203f29 --- /dev/null +++ b/tests/apis/namespace/inner/xmake.lua @@ -0,0 +1,19 @@ +add_rules("mode.debug", "mode.release") + +namespace("ns1", function () + target("foo") + set_kind("static") + add_files("src/foo.cpp") + + namespace("ns2", function() + target("bar") + set_kind("static") + add_files("src/bar.cpp") + end) + + target("test") + set_kind("binary") + add_deps("foo", "ns2::bar") + add_files("src/main.cpp") +end) + |
