summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-28 10:18:42 +0800
committerruki <[email protected]>2017-02-28 10:18:42 +0800
commitd5145e76c8ef2480dbf43ece33925bcd97fe598c (patch)
tree36aacc4636e645209ed52dd2d8638e4c24ff9a09
parentfc68d8521d388daa8c6e3a21919feca864f7b741 (diff)
add golang and rust templates
-rw-r--r--xmake/templates/go/console/project/src/main.go14
-rwxr-xr-xxmake/templates/go/console/project/xmake.lua32
-rw-r--r--xmake/templates/go/console/template.lua11
-rwxr-xr-xxmake/templates/go/static_library/project/src/main.go7
-rwxr-xr-xxmake/templates/go/static_library/project/src/test.go12
-rwxr-xr-xxmake/templates/go/static_library/project/src/test/add.go6
-rwxr-xr-xxmake/templates/go/static_library/project/src/test/sub.go6
-rwxr-xr-xxmake/templates/go/static_library/project/xmake.lua50
-rw-r--r--xmake/templates/go/static_library/template.lua11
-rw-r--r--xmake/templates/rust/console/project/src/main.rs4
-rwxr-xr-xxmake/templates/rust/console/project/xmake.lua32
-rw-r--r--xmake/templates/rust/console/template.lua11
-rw-r--r--xmake/templates/rust/static_library/project/src/interfaces.rs5
-rw-r--r--xmake/templates/rust/static_library/project/src/main.rs7
-rwxr-xr-xxmake/templates/rust/static_library/project/xmake.lua48
-rw-r--r--xmake/templates/rust/static_library/template.lua11
16 files changed, 267 insertions, 0 deletions
diff --git a/xmake/templates/go/console/project/src/main.go b/xmake/templates/go/console/project/src/main.go
new file mode 100644
index 000000000..8ea127243
--- /dev/null
+++ b/xmake/templates/go/console/project/src/main.go
@@ -0,0 +1,14 @@
+package main
+
+/* /////////////////////////////////////////////////////////////////////////////////////////////////
+ * imports
+ */
+import "fmt"
+
+/* /////////////////////////////////////////////////////////////////////////////////////////////////
+ * main
+ */
+func main() {
+
+ fmt.Println("hello xmake for go!")
+}
diff --git a/xmake/templates/go/console/project/xmake.lua b/xmake/templates/go/console/project/xmake.lua
new file mode 100755
index 000000000..bf7f3e04b
--- /dev/null
+++ b/xmake/templates/go/console/project/xmake.lua
@@ -0,0 +1,32 @@
+-- the debug mode
+if is_mode("debug") then
+
+ -- enable the debug symbols
+ set_symbols("debug")
+
+ -- disable optimization
+ set_optimize("none")
+end
+
+-- the release mode
+if is_mode("release") then
+
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
+
+ -- enable fastest optimization
+ set_optimize("fastest")
+
+ -- strip all symbols
+ set_strip("all")
+end
+
+-- add target
+target("[targetname]")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add files
+ add_files("src/*.go")
+
diff --git a/xmake/templates/go/console/template.lua b/xmake/templates/go/console/template.lua
new file mode 100644
index 000000000..09412f86d
--- /dev/null
+++ b/xmake/templates/go/console/template.lua
@@ -0,0 +1,11 @@
+-- set description
+set_description("The Console Program")
+
+-- set project directory
+set_projectdir("project")
+
+-- add macros
+add_macros("targetname", "$(targetname)")
+
+-- add macro files
+add_macrofiles("xmake.lua")
diff --git a/xmake/templates/go/static_library/project/src/main.go b/xmake/templates/go/static_library/project/src/main.go
new file mode 100755
index 000000000..f2b477453
--- /dev/null
+++ b/xmake/templates/go/static_library/project/src/main.go
@@ -0,0 +1,7 @@
+package main
+
+func main() {
+
+ Run()
+}
+
diff --git a/xmake/templates/go/static_library/project/src/test.go b/xmake/templates/go/static_library/project/src/test.go
new file mode 100755
index 000000000..cf10523f9
--- /dev/null
+++ b/xmake/templates/go/static_library/project/src/test.go
@@ -0,0 +1,12 @@
+package main
+
+import (
+ "fmt"
+ "module"
+)
+
+func Run() {
+
+ fmt.Printf("add: %d\n", module.Add(1, 2));
+ fmt.Printf("sub: %d\n", module.Sub(1, 2));
+}
diff --git a/xmake/templates/go/static_library/project/src/test/add.go b/xmake/templates/go/static_library/project/src/test/add.go
new file mode 100755
index 000000000..98ffef600
--- /dev/null
+++ b/xmake/templates/go/static_library/project/src/test/add.go
@@ -0,0 +1,6 @@
+package module
+
+func Add(a int, b int) int {
+ return a + b;
+}
+
diff --git a/xmake/templates/go/static_library/project/src/test/sub.go b/xmake/templates/go/static_library/project/src/test/sub.go
new file mode 100755
index 000000000..a24a9abb7
--- /dev/null
+++ b/xmake/templates/go/static_library/project/src/test/sub.go
@@ -0,0 +1,6 @@
+package module
+
+func Sub(a int, b int) int {
+ return a - b;
+}
+
diff --git a/xmake/templates/go/static_library/project/xmake.lua b/xmake/templates/go/static_library/project/xmake.lua
new file mode 100755
index 000000000..ddf3b14c5
--- /dev/null
+++ b/xmake/templates/go/static_library/project/xmake.lua
@@ -0,0 +1,50 @@
+-- the debug mode
+if is_mode("debug") then
+
+ -- enable the debug symbols
+ set_symbols("debug")
+
+ -- disable optimization
+ set_optimize("none")
+end
+
+-- the release mode
+if is_mode("release") then
+
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
+
+ -- enable fastest optimization
+ set_optimize("fastest")
+
+ -- strip all symbols
+ set_strip("all")
+end
+
+-- add target
+target("module")
+
+ -- set kind
+ set_kind("static")
+
+ -- add files
+ add_files("src/test/*.go")
+
+-- add target
+target("[targetname]_demo")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("module")
+
+ -- add files
+ add_files("src/*.go")
+
+ -- add link directory
+ add_linkdirs("$(buildir)")
+
+ -- add include directory
+ add_includedirs("$(buildir)")
+
diff --git a/xmake/templates/go/static_library/template.lua b/xmake/templates/go/static_library/template.lua
new file mode 100644
index 000000000..fdc5ae91c
--- /dev/null
+++ b/xmake/templates/go/static_library/template.lua
@@ -0,0 +1,11 @@
+-- set description
+set_description("The Static Library")
+
+-- set project directory
+set_projectdir("project")
+
+-- add macros
+add_macros("targetname", "$(targetname)")
+
+-- add macro files
+add_macrofiles("xmake.lua")
diff --git a/xmake/templates/rust/console/project/src/main.rs b/xmake/templates/rust/console/project/src/main.rs
new file mode 100644
index 000000000..e8d2ae9b2
--- /dev/null
+++ b/xmake/templates/rust/console/project/src/main.rs
@@ -0,0 +1,4 @@
+fn main()
+{
+ println!("hello xmake!");
+}
diff --git a/xmake/templates/rust/console/project/xmake.lua b/xmake/templates/rust/console/project/xmake.lua
new file mode 100755
index 000000000..0e4bd709d
--- /dev/null
+++ b/xmake/templates/rust/console/project/xmake.lua
@@ -0,0 +1,32 @@
+-- the debug mode
+if is_mode("debug") then
+
+ -- enable the debug symbols
+ set_symbols("debug")
+
+ -- disable optimization
+ set_optimize("none")
+end
+
+-- the release mode
+if is_mode("release") then
+
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
+
+ -- enable fastest optimization
+ set_optimize("fastest")
+
+ -- strip all symbols
+ set_strip("all")
+end
+
+-- add target
+target("[targetname]")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add files
+ add_files("src/*.rs")
+
diff --git a/xmake/templates/rust/console/template.lua b/xmake/templates/rust/console/template.lua
new file mode 100644
index 000000000..09412f86d
--- /dev/null
+++ b/xmake/templates/rust/console/template.lua
@@ -0,0 +1,11 @@
+-- set description
+set_description("The Console Program")
+
+-- set project directory
+set_projectdir("project")
+
+-- add macros
+add_macros("targetname", "$(targetname)")
+
+-- add macro files
+add_macrofiles("xmake.lua")
diff --git a/xmake/templates/rust/static_library/project/src/interfaces.rs b/xmake/templates/rust/static_library/project/src/interfaces.rs
new file mode 100644
index 000000000..277008ba4
--- /dev/null
+++ b/xmake/templates/rust/static_library/project/src/interfaces.rs
@@ -0,0 +1,5 @@
+pub fn add(a: i32, b: i32) -> i32
+{
+ return a + b;
+}
+
diff --git a/xmake/templates/rust/static_library/project/src/main.rs b/xmake/templates/rust/static_library/project/src/main.rs
new file mode 100644
index 000000000..0cd4449d1
--- /dev/null
+++ b/xmake/templates/rust/static_library/project/src/main.rs
@@ -0,0 +1,7 @@
+extern crate interfaces;
+
+fn main()
+{
+ println!("hello xmake!");
+ println!("add: {}", interfaces::add(1, 1));
+}
diff --git a/xmake/templates/rust/static_library/project/xmake.lua b/xmake/templates/rust/static_library/project/xmake.lua
new file mode 100755
index 000000000..c3a5b497a
--- /dev/null
+++ b/xmake/templates/rust/static_library/project/xmake.lua
@@ -0,0 +1,48 @@
+-- the debug mode
+if is_mode("debug") then
+
+ -- enable the debug symbols
+ set_symbols("debug")
+
+ -- disable optimization
+ set_optimize("none")
+end
+
+-- the release mode
+if is_mode("release") then
+
+ -- set the symbols visibility: hidden
+ set_symbols("hidden")
+
+ -- enable fastest optimization
+ set_optimize("fastest")
+
+ -- strip all symbols
+ set_strip("all")
+end
+
+-- add target
+target("interfaces")
+
+ -- set kind
+ set_kind("static")
+
+ -- add files
+ add_files("src/interfaces.rs")
+
+-- add target
+target("[targetname]_demo")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("interfaces")
+
+ -- add files
+ add_files("src/main.rs")
+
+ -- add link directory
+ add_linkdirs("$(buildir)")
+
+
diff --git a/xmake/templates/rust/static_library/template.lua b/xmake/templates/rust/static_library/template.lua
new file mode 100644
index 000000000..fdc5ae91c
--- /dev/null
+++ b/xmake/templates/rust/static_library/template.lua
@@ -0,0 +1,11 @@
+-- set description
+set_description("The Static Library")
+
+-- set project directory
+set_projectdir("project")
+
+-- add macros
+add_macros("targetname", "$(targetname)")
+
+-- add macro files
+add_macrofiles("xmake.lua")