diff options
| author | Arthur Laurent <[email protected]> | 2022-12-01 12:02:31 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-01 12:02:31 +0100 |
| commit | 9b21e149d3c4966b0e0a79555935a7d4560afed7 (patch) | |
| tree | 0007e9fc274ddcfd905189d7c82521a9b5b0d73a /tests/projects/c++ | |
| parent | 944c55ad89e0ee78d70451097f37ae11651e82b8 (diff) | |
| parent | 05d9e82172739b36900b6cbc9a4c72625d003f3b (diff) | |
Merge branch 'dev' into process_modules
Diffstat (limited to 'tests/projects/c++')
18 files changed, 88 insertions, 52 deletions
diff --git a/tests/projects/c++/modules/stdmodules/.gitignore b/tests/projects/c++/modules/stdmodules/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/projects/c++/modules/stdmodules/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/projects/c++/modules/stdmodules/src/my_module.cpp b/tests/projects/c++/modules/stdmodules/src/my_module.cpp new file mode 100644 index 000000000..5264da821 --- /dev/null +++ b/tests/projects/c++/modules/stdmodules/src/my_module.cpp @@ -0,0 +1,9 @@ +module my_module; + +#ifdef _MSC_VER +import std.core; +#else +import std; +#endif + +auto my_sum(size_t a, size_t b) -> size_t { return a + b; } diff --git a/tests/projects/c++/modules/stdmodules/src/my_module.mpp b/tests/projects/c++/modules/stdmodules/src/my_module.mpp new file mode 100644 index 000000000..5c0e44bc9 --- /dev/null +++ b/tests/projects/c++/modules/stdmodules/src/my_module.mpp @@ -0,0 +1,9 @@ +export module my_module; + +#ifdef _MSC_VER +import std.core; +#else +import std; +#endif + +export auto my_sum(size_t a, size_t b) -> size_t; diff --git a/tests/projects/c++/modules/stdmodules/test/test.cpp b/tests/projects/c++/modules/stdmodules/test/test.cpp new file mode 100644 index 000000000..a12813c24 --- /dev/null +++ b/tests/projects/c++/modules/stdmodules/test/test.cpp @@ -0,0 +1,13 @@ +#ifdef _MSC_VER +import std.core; +#else +import std; +#endif + +import my_module; + +using namespace std; + +int main(int argc, char** argv) { + cout << my_sum(1, 1) << endl; +} diff --git a/tests/projects/c++/modules/stdmodules/xmake.lua b/tests/projects/c++/modules/stdmodules/xmake.lua new file mode 100644 index 000000000..ffe2d015b --- /dev/null +++ b/tests/projects/c++/modules/stdmodules/xmake.lua @@ -0,0 +1,13 @@ +add_rules("mode.debug", "mode.release") +set_languages("c++20") + +add_cxxflags("clang::-stdlib=libc++") + +target("mod") + set_kind("shared") + add_files("src/*.cpp", "src/*.mpp") + +target("test") + set_kind("binary") + add_files("test/*.cpp") + add_deps("mod") diff --git a/tests/projects/c++/modules/user_headerunit/src/hello.mpp b/tests/projects/c++/modules/user_headerunit/src/hello.mpp index 5b2f434ad..f2e4022f7 100644 --- a/tests/projects/c++/modules/user_headerunit/src/hello.mpp +++ b/tests/projects/c++/modules/user_headerunit/src/hello.mpp @@ -1,10 +1,11 @@ module; #include <cstdio> +import "header.hpp"; export module hello; export namespace hello { void say(const char *arg) { - printf("%s\n", arg); + printf("%s: %s\n", FOO, arg); } } diff --git a/tests/projects/c++/protobuf/xmake.lua b/tests/projects/c++/protobuf/xmake.lua index 04bed4fb0..1468cc5e3 100644 --- a/tests/projects/c++/protobuf/xmake.lua +++ b/tests/projects/c++/protobuf/xmake.lua @@ -5,6 +5,7 @@ target("test") set_kind("binary") set_languages("c++11") add_packages("protobuf-cpp") + add_rules("protobuf.cpp") add_files("src/*.cpp") - add_files("src/**.proto", {rules = "protobuf.cpp", proto_rootdir = "src"}) + add_files("src/**.proto", {proto_rootdir = "src"}) diff --git a/tests/projects/c++/shared_library/src/foo.cpp b/tests/projects/c++/shared_library/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/tests/projects/c++/shared_library/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/tests/projects/c++/shared_library/src/interface.h b/tests/projects/c++/shared_library/src/foo.h index 57b6194de..20df0baa4 100644 --- a/tests/projects/c++/shared_library/src/interface.h +++ b/tests/projects/c++/shared_library/src/foo.h @@ -10,14 +10,7 @@ extern "C" { # define __export #endif -/*! calculate add(a, b) - * - * @param a the first argument - * @param b the second argument - * - * @return the result - */ -__export int add(int a, int b); +__export int add(int a, int b); #ifdef __cplusplus } diff --git a/tests/projects/c++/shared_library/src/interface.cpp b/tests/projects/c++/shared_library/src/interface.cpp deleted file mode 100644 index 598d07560..000000000 --- a/tests/projects/c++/shared_library/src/interface.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/tests/projects/c++/shared_library/src/main.cpp b/tests/projects/c++/shared_library/src/main.cpp index 72e03272b..ed1924789 100644 --- a/tests/projects/c++/shared_library/src/main.cpp +++ b/tests/projects/c++/shared_library/src/main.cpp @@ -1,10 +1,9 @@ -#include "interface.h" +#include "foo.h" #include <iostream> using namespace std; -int main(int argc, char** argv) -{ - cout << "add(1, 2) = " << add(1, 2) << endl; +int main(int argc, char** argv) { + cout << "add(1, 2) = " << add(1, 2) << endl; return 0; } diff --git a/tests/projects/c++/shared_library/xmake.lua b/tests/projects/c++/shared_library/xmake.lua index 49641ced1..f2e0a1d3d 100644 --- a/tests/projects/c++/shared_library/xmake.lua +++ b/tests/projects/c++/shared_library/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("test") +target("foo") set_kind("shared") - add_files("src/interface.cpp") + add_files("src/foo.cpp") target("demo") set_kind("binary") - add_deps("test") + add_deps("foo") add_files("src/main.cpp") diff --git a/tests/projects/c++/static_library/src/foo.cpp b/tests/projects/c++/static_library/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/tests/projects/c++/static_library/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/tests/projects/c++/static_library/src/foo.h b/tests/projects/c++/static_library/src/foo.h new file mode 100644 index 000000000..d2506bca9 --- /dev/null +++ b/tests/projects/c++/static_library/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/projects/c++/static_library/src/interface.cpp b/tests/projects/c++/static_library/src/interface.cpp deleted file mode 100644 index 598d07560..000000000 --- a/tests/projects/c++/static_library/src/interface.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/tests/projects/c++/static_library/src/interface.h b/tests/projects/c++/static_library/src/interface.h deleted file mode 100644 index 4a41e9597..000000000 --- a/tests/projects/c++/static_library/src/interface.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -/*! calculate add(a, b) - * - * @param a the first argument - * @param b the second argument - * - * @return the result - */ -int add(int a, int b); - -#ifdef __cplusplus -} -#endif diff --git a/tests/projects/c++/static_library/src/main.cpp b/tests/projects/c++/static_library/src/main.cpp index 72e03272b..ed1924789 100644 --- a/tests/projects/c++/static_library/src/main.cpp +++ b/tests/projects/c++/static_library/src/main.cpp @@ -1,10 +1,9 @@ -#include "interface.h" +#include "foo.h" #include <iostream> using namespace std; -int main(int argc, char** argv) -{ - cout << "add(1, 2) = " << add(1, 2) << endl; +int main(int argc, char** argv) { + cout << "add(1, 2) = " << add(1, 2) << endl; return 0; } diff --git a/tests/projects/c++/static_library/xmake.lua b/tests/projects/c++/static_library/xmake.lua index 184a33d51..f31e08530 100644 --- a/tests/projects/c++/static_library/xmake.lua +++ b/tests/projects/c++/static_library/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("test") +target("foo") set_kind("static") - add_files("src/interface.cpp") + add_files("src/foo.cpp") target("demo") set_kind("binary") - add_deps("test") + add_deps("foo") add_files("src/main.cpp") |
