From d5145e76c8ef2480dbf43ece33925bcd97fe598c Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 28 Feb 2017 10:18:42 +0800 Subject: add golang and rust templates --- xmake/templates/go/console/project/src/main.go | 14 ++++++ xmake/templates/go/console/project/xmake.lua | 32 ++++++++++++++ xmake/templates/go/console/template.lua | 11 +++++ .../go/static_library/project/src/main.go | 7 +++ .../go/static_library/project/src/test.go | 12 ++++++ .../go/static_library/project/src/test/add.go | 6 +++ .../go/static_library/project/src/test/sub.go | 6 +++ .../templates/go/static_library/project/xmake.lua | 50 ++++++++++++++++++++++ xmake/templates/go/static_library/template.lua | 11 +++++ xmake/templates/rust/console/project/src/main.rs | 4 ++ xmake/templates/rust/console/project/xmake.lua | 32 ++++++++++++++ xmake/templates/rust/console/template.lua | 11 +++++ .../rust/static_library/project/src/interfaces.rs | 5 +++ .../rust/static_library/project/src/main.rs | 7 +++ .../rust/static_library/project/xmake.lua | 48 +++++++++++++++++++++ xmake/templates/rust/static_library/template.lua | 11 +++++ 16 files changed, 267 insertions(+) create mode 100644 xmake/templates/go/console/project/src/main.go create mode 100755 xmake/templates/go/console/project/xmake.lua create mode 100644 xmake/templates/go/console/template.lua create mode 100755 xmake/templates/go/static_library/project/src/main.go create mode 100755 xmake/templates/go/static_library/project/src/test.go create mode 100755 xmake/templates/go/static_library/project/src/test/add.go create mode 100755 xmake/templates/go/static_library/project/src/test/sub.go create mode 100755 xmake/templates/go/static_library/project/xmake.lua create mode 100644 xmake/templates/go/static_library/template.lua create mode 100644 xmake/templates/rust/console/project/src/main.rs create mode 100755 xmake/templates/rust/console/project/xmake.lua create mode 100644 xmake/templates/rust/console/template.lua create mode 100644 xmake/templates/rust/static_library/project/src/interfaces.rs create mode 100644 xmake/templates/rust/static_library/project/src/main.rs create mode 100755 xmake/templates/rust/static_library/project/xmake.lua create mode 100644 xmake/templates/rust/static_library/template.lua 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") -- cgit v1.3.1