From 0914303fc89e25e51e71a7a628e41578993dcb6d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 1 Dec 2022 22:39:39 +0800 Subject: improve templates --- xmake/templates/c++/shared/project/src/foo.cpp | 5 +++++ xmake/templates/c++/shared/project/src/foo.h | 17 +++++++++++++++ .../templates/c++/shared/project/src/interface.cpp | 6 ------ xmake/templates/c++/shared/project/src/interface.h | 24 ---------------------- xmake/templates/c++/shared/project/src/main.cpp | 5 ++--- xmake/templates/c++/shared/project/xmake.lua | 8 ++++---- xmake/templates/c++/static/project/src/foo.cpp | 5 +++++ xmake/templates/c++/static/project/src/foo.h | 9 ++++++++ .../templates/c++/static/project/src/interface.cpp | 6 ------ xmake/templates/c++/static/project/src/interface.h | 16 --------------- xmake/templates/c++/static/project/src/main.cpp | 5 ++--- xmake/templates/c++/static/project/xmake.lua | 8 ++++---- xmake/templates/c/shared/project/src/foo.c | 5 +++++ xmake/templates/c/shared/project/src/foo.h | 11 ++++++++++ xmake/templates/c/shared/project/src/interface.c | 6 ------ xmake/templates/c/shared/project/src/interface.h | 18 ---------------- xmake/templates/c/shared/project/src/main.c | 5 ++--- xmake/templates/c/shared/project/xmake.lua | 8 ++++---- xmake/templates/c/static/project/src/foo.c | 5 +++++ xmake/templates/c/static/project/src/foo.h | 1 + xmake/templates/c/static/project/src/interface.c | 6 ------ xmake/templates/c/static/project/src/interface.h | 8 -------- xmake/templates/c/static/project/src/main.c | 5 ++--- xmake/templates/c/static/project/xmake.lua | 8 ++++---- 24 files changed, 82 insertions(+), 118 deletions(-) create mode 100644 xmake/templates/c++/shared/project/src/foo.cpp create mode 100644 xmake/templates/c++/shared/project/src/foo.h delete mode 100644 xmake/templates/c++/shared/project/src/interface.cpp delete mode 100644 xmake/templates/c++/shared/project/src/interface.h create mode 100644 xmake/templates/c++/static/project/src/foo.cpp create mode 100644 xmake/templates/c++/static/project/src/foo.h delete mode 100644 xmake/templates/c++/static/project/src/interface.cpp delete mode 100644 xmake/templates/c++/static/project/src/interface.h create mode 100644 xmake/templates/c/shared/project/src/foo.c create mode 100644 xmake/templates/c/shared/project/src/foo.h delete mode 100644 xmake/templates/c/shared/project/src/interface.c delete mode 100644 xmake/templates/c/shared/project/src/interface.h create mode 100644 xmake/templates/c/static/project/src/foo.c create mode 100644 xmake/templates/c/static/project/src/foo.h delete mode 100644 xmake/templates/c/static/project/src/interface.c delete mode 100644 xmake/templates/c/static/project/src/interface.h 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/foo.h b/xmake/templates/c++/shared/project/src/foo.h new file mode 100644 index 000000000..20df0baa4 --- /dev/null +++ b/xmake/templates/c++/shared/project/src/foo.h @@ -0,0 +1,17 @@ +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_WIN32) +# define __export __declspec(dllexport) +#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +# define __export __attribute__((visibility("default"))) +#else +# define __export +#endif + +__export int add(int a, int b); + +#ifdef __cplusplus +} +#endif 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/interface.h b/xmake/templates/c++/shared/project/src/interface.h deleted file mode 100644 index 57b6194de..000000000 --- a/xmake/templates/c++/shared/project/src/interface.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_WIN32) -# define __export __declspec(dllexport) -#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) -# define __export __attribute__((visibility("default"))) -#else -# 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); - -#ifdef __cplusplus -} -#endif 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 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 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/foo.h b/xmake/templates/c/shared/project/src/foo.h new file mode 100644 index 000000000..b014f28e3 --- /dev/null +++ b/xmake/templates/c/shared/project/src/foo.h @@ -0,0 +1,11 @@ +#if defined(_WIN32) +# define __export __declspec(dllexport) +#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +# define __export __attribute__((visibility("default"))) +#else +# define __export +#endif + +__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/interface.h b/xmake/templates/c/shared/project/src/interface.h deleted file mode 100644 index 23ee3117e..000000000 --- a/xmake/templates/c/shared/project/src/interface.h +++ /dev/null @@ -1,18 +0,0 @@ -#if defined(_WIN32) -# define __export __declspec(dllexport) -#elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) -# define __export __attribute__((visibility("default"))) -#else -# 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); - - 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 -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 -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} -- cgit v1.3.1