diff options
| author | ruki <[email protected]> | 2022-12-01 22:39:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-12-01 22:39:39 +0800 |
| commit | 0914303fc89e25e51e71a7a628e41578993dcb6d (patch) | |
| tree | 57af39617ca2d0816fc3f9ffc8f8830bab9c1f42 | |
| parent | 90613a344570916a4a7d197dc20d3af31a38be51 (diff) | |
improve templates
22 files changed, 56 insertions, 92 deletions
diff --git a/xmake/templates/c++/shared/project/src/foo.cpp b/xmake/templates/c++/shared/project/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/xmake/templates/c++/shared/project/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/xmake/templates/c++/shared/project/src/interface.h b/xmake/templates/c++/shared/project/src/foo.h index 57b6194de..20df0baa4 100644 --- a/xmake/templates/c++/shared/project/src/interface.h +++ b/xmake/templates/c++/shared/project/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/xmake/templates/c++/shared/project/src/interface.cpp b/xmake/templates/c++/shared/project/src/interface.cpp deleted file mode 100644 index 598d07560..000000000 --- a/xmake/templates/c++/shared/project/src/interface.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/xmake/templates/c++/shared/project/src/main.cpp b/xmake/templates/c++/shared/project/src/main.cpp index 1bee1b2ad..ed1924789 100644 --- a/xmake/templates/c++/shared/project/src/main.cpp +++ b/xmake/templates/c++/shared/project/src/main.cpp @@ -1,10 +1,9 @@ -#include "interface.h" +#include "foo.h" #include <iostream> using namespace std; -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { cout << "add(1, 2) = " << add(1, 2) << endl; return 0; } diff --git a/xmake/templates/c++/shared/project/xmake.lua b/xmake/templates/c++/shared/project/xmake.lua index 660816dd1..43510f03e 100644 --- a/xmake/templates/c++/shared/project/xmake.lua +++ b/xmake/templates/c++/shared/project/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("${TARGETNAME}") +target("foo") set_kind("shared") - add_files("src/interface.cpp") + add_files("src/foo.cpp") -target("${TARGETNAME}_demo") +target("${TARGETNAME}") set_kind("binary") - add_deps("${TARGETNAME}") + add_deps("foo") add_files("src/main.cpp") ${FAQ} diff --git a/xmake/templates/c++/static/project/src/foo.cpp b/xmake/templates/c++/static/project/src/foo.cpp new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/xmake/templates/c++/static/project/src/foo.cpp @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/xmake/templates/c++/static/project/src/foo.h b/xmake/templates/c++/static/project/src/foo.h new file mode 100644 index 000000000..d2506bca9 --- /dev/null +++ b/xmake/templates/c++/static/project/src/foo.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif + +int add(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/xmake/templates/c++/static/project/src/interface.cpp b/xmake/templates/c++/static/project/src/interface.cpp deleted file mode 100644 index 598d07560..000000000 --- a/xmake/templates/c++/static/project/src/interface.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/xmake/templates/c++/static/project/src/interface.h b/xmake/templates/c++/static/project/src/interface.h deleted file mode 100644 index 62a39427c..000000000 --- a/xmake/templates/c++/static/project/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/xmake/templates/c++/static/project/src/main.cpp b/xmake/templates/c++/static/project/src/main.cpp index 1bee1b2ad..ed1924789 100644 --- a/xmake/templates/c++/static/project/src/main.cpp +++ b/xmake/templates/c++/static/project/src/main.cpp @@ -1,10 +1,9 @@ -#include "interface.h" +#include "foo.h" #include <iostream> using namespace std; -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { cout << "add(1, 2) = " << add(1, 2) << endl; return 0; } diff --git a/xmake/templates/c++/static/project/xmake.lua b/xmake/templates/c++/static/project/xmake.lua index 6e9fcf6e9..45d81c393 100644 --- a/xmake/templates/c++/static/project/xmake.lua +++ b/xmake/templates/c++/static/project/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("${TARGETNAME}") +target("foo") set_kind("static") - add_files("src/interface.cpp") + add_files("src/foo.cpp") -target("${TARGETNAME}_demo") +target("${TARGETNAME}") set_kind("binary") - add_deps("${TARGETNAME}") + add_deps("foo") add_files("src/main.cpp") ${FAQ} diff --git a/xmake/templates/c/shared/project/src/foo.c b/xmake/templates/c/shared/project/src/foo.c new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/xmake/templates/c/shared/project/src/foo.c @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/xmake/templates/c/shared/project/src/interface.h b/xmake/templates/c/shared/project/src/foo.h index 23ee3117e..b014f28e3 100644 --- a/xmake/templates/c/shared/project/src/interface.h +++ b/xmake/templates/c/shared/project/src/foo.h @@ -6,13 +6,6 @@ # 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); diff --git a/xmake/templates/c/shared/project/src/interface.c b/xmake/templates/c/shared/project/src/interface.c deleted file mode 100644 index 598d07560..000000000 --- a/xmake/templates/c/shared/project/src/interface.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/xmake/templates/c/shared/project/src/main.c b/xmake/templates/c/shared/project/src/main.c index 9505a2f75..a4c769408 100644 --- a/xmake/templates/c/shared/project/src/main.c +++ b/xmake/templates/c/shared/project/src/main.c @@ -1,8 +1,7 @@ -#include "interface.h" +#include "foo.h" #include <stdio.h> -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { printf("add(1, 2) = %d\n", add(1, 2)); return 0; } diff --git a/xmake/templates/c/shared/project/xmake.lua b/xmake/templates/c/shared/project/xmake.lua index 14931a60c..91dac7c63 100644 --- a/xmake/templates/c/shared/project/xmake.lua +++ b/xmake/templates/c/shared/project/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("${TARGETNAME}") +target("foo") set_kind("shared") - add_files("src/interface.c") + add_files("src/foo.c") -target("${TARGETNAME}_demo") +target("${TARGETNAME}") set_kind("binary") - add_deps("${TARGETNAME}") + add_deps("foo") add_files("src/main.c") ${FAQ} diff --git a/xmake/templates/c/static/project/src/foo.c b/xmake/templates/c/static/project/src/foo.c new file mode 100644 index 000000000..1a1fb3425 --- /dev/null +++ b/xmake/templates/c/static/project/src/foo.c @@ -0,0 +1,5 @@ +#include "foo.h" + +int add(int a, int b) { + return a + b; +} diff --git a/xmake/templates/c/static/project/src/foo.h b/xmake/templates/c/static/project/src/foo.h new file mode 100644 index 000000000..6295ab95c --- /dev/null +++ b/xmake/templates/c/static/project/src/foo.h @@ -0,0 +1 @@ +int add(int a, int b); diff --git a/xmake/templates/c/static/project/src/interface.c b/xmake/templates/c/static/project/src/interface.c deleted file mode 100644 index 598d07560..000000000 --- a/xmake/templates/c/static/project/src/interface.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "interface.h" - -int add(int a, int b) -{ - return a + b; -} diff --git a/xmake/templates/c/static/project/src/interface.h b/xmake/templates/c/static/project/src/interface.h deleted file mode 100644 index 6c2aa9c2a..000000000 --- a/xmake/templates/c/static/project/src/interface.h +++ /dev/null @@ -1,8 +0,0 @@ -/*! calculate add(a, b) - * - * @param a the first argument - * @param b the second argument - * - * @return the result - */ -int add(int a, int b); diff --git a/xmake/templates/c/static/project/src/main.c b/xmake/templates/c/static/project/src/main.c index 9505a2f75..a4c769408 100644 --- a/xmake/templates/c/static/project/src/main.c +++ b/xmake/templates/c/static/project/src/main.c @@ -1,8 +1,7 @@ -#include "interface.h" +#include "foo.h" #include <stdio.h> -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { printf("add(1, 2) = %d\n", add(1, 2)); return 0; } diff --git a/xmake/templates/c/static/project/xmake.lua b/xmake/templates/c/static/project/xmake.lua index 5281023ec..fd0b0592a 100644 --- a/xmake/templates/c/static/project/xmake.lua +++ b/xmake/templates/c/static/project/xmake.lua @@ -1,12 +1,12 @@ add_rules("mode.debug", "mode.release") -target("${TARGETNAME}") +target("foo") set_kind("static") - add_files("src/interface.c") + add_files("src/foo.c") -target("${TARGETNAME}_demo") +target("${TARGETNAME}") set_kind("binary") - add_deps("${TARGETNAME}") + add_deps("foo") add_files("src/main.c") ${FAQ} |
