summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-03 22:53:00 +0800
committerruki <[email protected]>2024-04-03 22:53:00 +0800
commitdb4196b069499e6fcf0d66c66a97665414c0011d (patch)
tree8a564a22faf0bdabf81465c4e135692b98ba590a
parentd2b45f4d485d2778c5b08500365d6f0068c40b3b (diff)
add module.binary template
-rw-r--r--xmake/templates/c++/module.binary/.gitignore8
-rw-r--r--xmake/templates/c++/module.binary/project/modules/binary/bar/.gitignore8
-rw-r--r--xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp9
-rw-r--r--xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp10
-rw-r--r--xmake/templates/c++/module.binary/project/modules/binary/bar/xmake.lua10
-rw-r--r--xmake/templates/c++/module.binary/project/src/main.cpp6
-rw-r--r--xmake/templates/c++/module.binary/project/xmake.lua15
-rw-r--r--xmake/templates/c++/module.binary/template.lua2
-rw-r--r--xmake/templates/c/module.binary/.gitignore8
-rw-r--r--xmake/templates/c/module.binary/project/modules/binary/bar/.gitignore8
-rw-r--r--xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c9
-rw-r--r--xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c10
-rw-r--r--xmake/templates/c/module.binary/project/modules/binary/bar/xmake.lua10
-rw-r--r--xmake/templates/c/module.binary/project/src/main.c6
-rw-r--r--xmake/templates/c/module.binary/project/xmake.lua15
-rw-r--r--xmake/templates/c/module.binary/template.lua2
16 files changed, 136 insertions, 0 deletions
diff --git a/xmake/templates/c++/module.binary/.gitignore b/xmake/templates/c++/module.binary/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/xmake/templates/c++/module.binary/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/xmake/templates/c++/module.binary/project/modules/binary/bar/.gitignore b/xmake/templates/c++/module.binary/project/modules/binary/bar/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/xmake/templates/c++/module.binary/project/modules/binary/bar/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp
new file mode 100644
index 000000000..e19d07e12
--- /dev/null
+++ b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ int a = atoi(argv[1]);
+ int b = atoi(argv[2]);
+ printf("%d", a + b);
+ return 0;
+}
diff --git a/xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp
new file mode 100644
index 000000000..980289d1a
--- /dev/null
+++ b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ int a = atoi(argv[1]);
+ int b = atoi(argv[2]);
+ printf("%d", a - b);
+ return 0;
+}
+
diff --git a/xmake/templates/c++/module.binary/project/modules/binary/bar/xmake.lua b/xmake/templates/c++/module.binary/project/modules/binary/bar/xmake.lua
new file mode 100644
index 000000000..add3c6e97
--- /dev/null
+++ b/xmake/templates/c++/module.binary/project/modules/binary/bar/xmake.lua
@@ -0,0 +1,10 @@
+add_rules("mode.debug", "mode.release")
+
+target("add")
+ add_rules("module.binary")
+ add_files("src/add.cpp")
+
+target("sub")
+ add_rules("module.binary")
+ add_files("src/sub.cpp")
+
diff --git a/xmake/templates/c++/module.binary/project/src/main.cpp b/xmake/templates/c++/module.binary/project/src/main.cpp
new file mode 100644
index 000000000..7c775d288
--- /dev/null
+++ b/xmake/templates/c++/module.binary/project/src/main.cpp
@@ -0,0 +1,6 @@
+#include <iostream>
+
+int main(int argc, char** argv) {
+ std::cout << "hello world!" << std::endl;
+ return 0;
+}
diff --git a/xmake/templates/c++/module.binary/project/xmake.lua b/xmake/templates/c++/module.binary/project/xmake.lua
new file mode 100644
index 000000000..47fed5bc6
--- /dev/null
+++ b/xmake/templates/c++/module.binary/project/xmake.lua
@@ -0,0 +1,15 @@
+add_rules("mode.debug", "mode.release")
+
+add_moduledirs("modules")
+
+target("${TARGETNAME}")
+ set_kind("binary")
+ add_files("src/*.cpp")
+ on_config(function (target)
+ import("binary.bar")
+ print("binary: 1 + 1 = %s", bar.add(1, 1))
+ print("binary: 1 - 1 = %s", bar.sub(1, 1))
+ end)
+
+${FAQ}
+
diff --git a/xmake/templates/c++/module.binary/template.lua b/xmake/templates/c++/module.binary/template.lua
new file mode 100644
index 000000000..917f4eb23
--- /dev/null
+++ b/xmake/templates/c++/module.binary/template.lua
@@ -0,0 +1,2 @@
+template("module.binary")
+ add_configfiles("xmake.lua")
diff --git a/xmake/templates/c/module.binary/.gitignore b/xmake/templates/c/module.binary/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/xmake/templates/c/module.binary/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/xmake/templates/c/module.binary/project/modules/binary/bar/.gitignore b/xmake/templates/c/module.binary/project/modules/binary/bar/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/xmake/templates/c/module.binary/project/modules/binary/bar/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c b/xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c
new file mode 100644
index 000000000..e19d07e12
--- /dev/null
+++ b/xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ int a = atoi(argv[1]);
+ int b = atoi(argv[2]);
+ printf("%d", a + b);
+ return 0;
+}
diff --git a/xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c b/xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c
new file mode 100644
index 000000000..980289d1a
--- /dev/null
+++ b/xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ int a = atoi(argv[1]);
+ int b = atoi(argv[2]);
+ printf("%d", a - b);
+ return 0;
+}
+
diff --git a/xmake/templates/c/module.binary/project/modules/binary/bar/xmake.lua b/xmake/templates/c/module.binary/project/modules/binary/bar/xmake.lua
new file mode 100644
index 000000000..d4983d741
--- /dev/null
+++ b/xmake/templates/c/module.binary/project/modules/binary/bar/xmake.lua
@@ -0,0 +1,10 @@
+add_rules("mode.debug", "mode.release")
+
+target("add")
+ add_rules("module.binary")
+ add_files("src/add.c")
+
+target("sub")
+ add_rules("module.binary")
+ add_files("src/sub.c")
+
diff --git a/xmake/templates/c/module.binary/project/src/main.c b/xmake/templates/c/module.binary/project/src/main.c
new file mode 100644
index 000000000..113930e1a
--- /dev/null
+++ b/xmake/templates/c/module.binary/project/src/main.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+ printf("hello world!\n");
+ return 0;
+}
diff --git a/xmake/templates/c/module.binary/project/xmake.lua b/xmake/templates/c/module.binary/project/xmake.lua
new file mode 100644
index 000000000..fdd8bb1e5
--- /dev/null
+++ b/xmake/templates/c/module.binary/project/xmake.lua
@@ -0,0 +1,15 @@
+add_rules("mode.debug", "mode.release")
+
+add_moduledirs("modules")
+
+target("${TARGETNAME}")
+ set_kind("binary")
+ add_files("src/*.c")
+ on_config(function (target)
+ import("binary.bar")
+ print("binary: 1 + 1 = %s", bar.add(1, 1))
+ print("binary: 1 - 1 = %s", bar.sub(1, 1))
+ end)
+
+${FAQ}
+
diff --git a/xmake/templates/c/module.binary/template.lua b/xmake/templates/c/module.binary/template.lua
new file mode 100644
index 000000000..917f4eb23
--- /dev/null
+++ b/xmake/templates/c/module.binary/template.lua
@@ -0,0 +1,2 @@
+template("module.binary")
+ add_configfiles("xmake.lua")