summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-28 10:02:26 +0800
committerruki <[email protected]>2017-02-28 10:02:26 +0800
commitfc68d8521d388daa8c6e3a21919feca864f7b741 (patch)
tree1d728c2d0d8453ee30fb940eec3250deaa4d5d5b
parente0ecb717bfff59d9a7716b3de6aef0db3532063d (diff)
add dlang template
-rw-r--r--xmake/core/project/template.lua1
-rw-r--r--xmake/templates/dlang/console/project/src/main.d6
-rwxr-xr-xxmake/templates/dlang/console/project/xmake.lua32
-rw-r--r--xmake/templates/dlang/console/template.lua11
-rw-r--r--xmake/templates/dlang/shared_library/project/src/interfaces.d9
-rw-r--r--xmake/templates/dlang/shared_library/project/src/main.d8
-rwxr-xr-xxmake/templates/dlang/shared_library/project/xmake.lua53
-rw-r--r--xmake/templates/dlang/shared_library/template.lua11
-rw-r--r--xmake/templates/dlang/static_library/project/src/interfaces.d9
-rw-r--r--xmake/templates/dlang/static_library/project/src/main.d8
-rwxr-xr-xxmake/templates/dlang/static_library/project/xmake.lua53
-rw-r--r--xmake/templates/dlang/static_library/template.lua11
12 files changed, 211 insertions, 1 deletions
diff --git a/xmake/core/project/template.lua b/xmake/core/project/template.lua
index 902949217..91ce420bc 100644
--- a/xmake/core/project/template.lua
+++ b/xmake/core/project/template.lua
@@ -232,7 +232,6 @@ function template.create(language, templateid, targetname)
return false, string.format("the template project not exists!")
end
- print(projectdir)
-- ensure the project directory
if not os.isdir(projectdir) then
os.mkdir(projectdir)
diff --git a/xmake/templates/dlang/console/project/src/main.d b/xmake/templates/dlang/console/project/src/main.d
new file mode 100644
index 000000000..524c4f94c
--- /dev/null
+++ b/xmake/templates/dlang/console/project/src/main.d
@@ -0,0 +1,6 @@
+import std.stdio;
+
+void main()
+{
+ writeln("hello world!");
+}
diff --git a/xmake/templates/dlang/console/project/xmake.lua b/xmake/templates/dlang/console/project/xmake.lua
new file mode 100755
index 000000000..8eaecc262
--- /dev/null
+++ b/xmake/templates/dlang/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/*.d")
+
diff --git a/xmake/templates/dlang/console/template.lua b/xmake/templates/dlang/console/template.lua
new file mode 100644
index 000000000..09412f86d
--- /dev/null
+++ b/xmake/templates/dlang/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/dlang/shared_library/project/src/interfaces.d b/xmake/templates/dlang/shared_library/project/src/interfaces.d
new file mode 100644
index 000000000..3386c9124
--- /dev/null
+++ b/xmake/templates/dlang/shared_library/project/src/interfaces.d
@@ -0,0 +1,9 @@
+extern(C) int add(int a, int b)
+{
+ return a + b;
+}
+
+extern(C) int sub(int a, int b)
+{
+ return a - b;
+}
diff --git a/xmake/templates/dlang/shared_library/project/src/main.d b/xmake/templates/dlang/shared_library/project/src/main.d
new file mode 100644
index 000000000..3137de217
--- /dev/null
+++ b/xmake/templates/dlang/shared_library/project/src/main.d
@@ -0,0 +1,8 @@
+import std.stdio;
+import interfaces;
+
+void main()
+{
+ printf("add: %d\n", interfaces.add(1, 1));
+ printf("sub: %d\n", interfaces.sub(2, 1));
+}
diff --git a/xmake/templates/dlang/shared_library/project/xmake.lua b/xmake/templates/dlang/shared_library/project/xmake.lua
new file mode 100755
index 000000000..962994618
--- /dev/null
+++ b/xmake/templates/dlang/shared_library/project/xmake.lua
@@ -0,0 +1,53 @@
+-- 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("shared")
+
+ -- add files
+ add_files("src/interfaces.d")
+
+-- add target
+target("[targetname]_demo")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("test")
+
+ -- add files
+ add_files("src/main.d")
+
+ -- add links
+ add_links("[targetname]")
+
+ -- add link directory
+ add_linkdirs("$(buildir)")
+
+ -- add include directory
+ add_includedirs("$(projectdir)/src")
+
diff --git a/xmake/templates/dlang/shared_library/template.lua b/xmake/templates/dlang/shared_library/template.lua
new file mode 100644
index 000000000..87e2f7183
--- /dev/null
+++ b/xmake/templates/dlang/shared_library/template.lua
@@ -0,0 +1,11 @@
+-- set description
+set_description("The Shared 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/dlang/static_library/project/src/interfaces.d b/xmake/templates/dlang/static_library/project/src/interfaces.d
new file mode 100644
index 000000000..3386c9124
--- /dev/null
+++ b/xmake/templates/dlang/static_library/project/src/interfaces.d
@@ -0,0 +1,9 @@
+extern(C) int add(int a, int b)
+{
+ return a + b;
+}
+
+extern(C) int sub(int a, int b)
+{
+ return a - b;
+}
diff --git a/xmake/templates/dlang/static_library/project/src/main.d b/xmake/templates/dlang/static_library/project/src/main.d
new file mode 100644
index 000000000..3137de217
--- /dev/null
+++ b/xmake/templates/dlang/static_library/project/src/main.d
@@ -0,0 +1,8 @@
+import std.stdio;
+import interfaces;
+
+void main()
+{
+ printf("add: %d\n", interfaces.add(1, 1));
+ printf("sub: %d\n", interfaces.sub(2, 1));
+}
diff --git a/xmake/templates/dlang/static_library/project/xmake.lua b/xmake/templates/dlang/static_library/project/xmake.lua
new file mode 100755
index 000000000..8cc9d7d9d
--- /dev/null
+++ b/xmake/templates/dlang/static_library/project/xmake.lua
@@ -0,0 +1,53 @@
+-- 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("static")
+
+ -- add files
+ add_files("src/interfaces.d")
+
+-- add target
+target("[targetname]_demo")
+
+ -- set kind
+ set_kind("binary")
+
+ -- add deps
+ add_deps("[targetname]")
+
+ -- add files
+ add_files("src/main.d")
+
+ -- add links
+ add_links("[targetname]")
+
+ -- add link directory
+ add_linkdirs("$(buildir)")
+
+ -- add include directory
+ add_includedirs("$(projectdir)/src")
+
diff --git a/xmake/templates/dlang/static_library/template.lua b/xmake/templates/dlang/static_library/template.lua
new file mode 100644
index 000000000..fdc5ae91c
--- /dev/null
+++ b/xmake/templates/dlang/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")