summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-21 13:27:22 +0800
committerruki <[email protected]>2017-02-21 13:27:22 +0800
commit60bce69c3f3be74e0de627d337b9b39e24aa45b8 (patch)
treebe7ae576eba06738e34b217f676464309afb00e8
parent4d635c3a48b87f92866ebfbc229558becf896158 (diff)
impl dmd compile and link
-rw-r--r--xmake/platforms/linux/check.lua1
-rw-r--r--xmake/platforms/macosx/check.lua40
-rwxr-xr-xxmake/tools/dmd.lua21
3 files changed, 32 insertions, 30 deletions
diff --git a/xmake/platforms/linux/check.lua b/xmake/platforms/linux/check.lua
index 8b0c38dc6..e4a3b1a5a 100644
--- a/xmake/platforms/linux/check.lua
+++ b/xmake/platforms/linux/check.lua
@@ -78,7 +78,6 @@ function _check_toolchains(config)
checker.check_toolchain_from_env(config, "ex", "AR", "the static library extractor")
checker.check_toolchain_from_env(config, "sh", "SH", "the shared library linker")
checker.check_toolchain_from_env(config, "sc", "SC", "the swift compiler")
- checker.check_toolchain_from_env(config, "dg", "DD", "the debugger")
end
-- check for gcc
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index 6a670534b..eec29c9c3 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -40,7 +40,6 @@ function _check_toolchains(config)
checker.check_toolchain_from_env(config, "ar", "AR", "the static library archiver")
checker.check_toolchain_from_env(config, "ex", "AR", "the static library extractor")
checker.check_toolchain_from_env(config, "sh", "SH", "the shared library linker")
- checker.check_toolchain_from_env(config, "dd", "DD", "the debugger")
-- check with xcrun
checker.check_toolchain(config, "cc", "xcrun -sdk macosx ", "clang", "the c compiler")
@@ -57,7 +56,7 @@ function _check_toolchains(config)
checker.check_toolchain(config, "ex", "xcrun -sdk macosx ", "ar", "the static library extractor")
checker.check_toolchain(config, "sh", "xcrun -sdk macosx ", "clang++", "the shared library linker")
checker.check_toolchain(config, "sh", "xcrun -sdk macosx ", "clang", "the shared library linker")
- checker.check_toolchain(config, "dd", "xcrun -sdk macosx ", "lldb", "the debugger")
+ checker.check_toolchain(config, "dg", "xcrun -sdk macosx ", "lldb", "the debugger")
-- check without xcrun
checker.check_toolchain(config, "cc", "", "clang", "the c compiler")
@@ -77,26 +76,27 @@ function _check_toolchains(config)
checker.check_toolchain(config, "dg", "", "lldb", "the debugger")
-- check for golang tools
- checker.check_toolchain(config, "go", "", "go", "the golang compiler")
- checker.check_toolchain(config, "go", "", "gccgo", "the golang compiler")
- checker.check_toolchain(config, "go-ar","", "go", "the golang static library archiver")
- checker.check_toolchain(config, "go-ar","", "gccgo", "the golang static library archiver")
- checker.check_toolchain(config, "go-ld","", "go", "the golang linker")
- checker.check_toolchain(config, "go-ld","", "gccgo", "the golang linker")
+ checker.check_toolchain(config, "go", "", "go", "the golang compiler")
+ checker.check_toolchain(config, "go", "", "gccgo", "the golang compiler")
+ checker.check_toolchain(config, "go-ar", "", "go", "the golang static library archiver")
+ checker.check_toolchain(config, "go-ar", "", "gccgo", "the golang static library archiver")
+ checker.check_toolchain(config, "go-ld", "", "go", "the golang linker")
+ checker.check_toolchain(config, "go-ld", "", "gccgo", "the golang linker")
-- check for dlang tools
- checker.check_toolchain(config, "dd", "", "dmd", "the dlang compiler")
- checker.check_toolchain(config, "dd", "", "ldc2", "the dlang compiler")
- checker.check_toolchain(config, "dd", "", "gdc", "the dlang compiler")
- checker.check_toolchain(config, "dd-ar","", "dmd", "the dlang static library archiver")
- checker.check_toolchain(config, "dd-ar","", "ldc2", "the dlang static library archiver")
- checker.check_toolchain(config, "dd-ar","", "gdc", "the dlang static library archiver")
- checker.check_toolchain(config, "dd-sh","", "dmd", "the dlang shared library linker")
- checker.check_toolchain(config, "dd-sh","", "ldc2", "the dlang shared library linker")
- checker.check_toolchain(config, "dd-sh","", "gdc", "the dlang shared library linker")
- checker.check_toolchain(config, "dd-ld","", "dmd", "the dlang linker")
- checker.check_toolchain(config, "dd-ld","", "ldc2", "the dlang linker")
- checker.check_toolchain(config, "dd-ld","", "gdc", "the dlang linker")
+ checker.check_toolchain(config, "dd", "", "dmd", "the dlang compiler")
+ checker.check_toolchain(config, "dd", "", "ldc2", "the dlang compiler")
+ checker.check_toolchain(config, "dd", "", "gdc", "the dlang compiler")
+ checker.check_toolchain(config, "dd-ar", "", "dmd", "the dlang static library archiver")
+ checker.check_toolchain(config, "dd-ar", "", "ldc2", "the dlang static library archiver")
+ checker.check_toolchain(config, "dd-ar", "", "gdc", "the dlang static library archiver")
+ checker.check_toolchain(config, "dd-sh", "", "dmd", "the dlang shared library linker")
+ checker.check_toolchain(config, "dd-sh", "", "ldc2", "the dlang shared library linker")
+ checker.check_toolchain(config, "dd-sh", "", "gdc", "the dlang shared library linker")
+ checker.check_toolchain(config, "dd-id", "", "dmd", "the dlang linker")
+ checker.check_toolchain(config, "dd-ld", "", "ldc2", "the dlang linker")
+ checker.check_toolchain(config, "dd-ld", "", "gdc", "the dlang linker")
+
end
-- check it
diff --git a/xmake/tools/dmd.lua b/xmake/tools/dmd.lua
index 3be2f5d12..f0f3a2373 100755
--- a/xmake/tools/dmd.lua
+++ b/xmake/tools/dmd.lua
@@ -55,25 +55,28 @@ end
function nf_includedir(dir)
-- make it
- return "-I " .. dir
+ return ""
end
-- make the linkdir flag
function nf_linkdir(dir)
-- make it
- return "-L " .. dir
+ return ""
end
-- make the link command
function linkcmd(objectfiles, targetkind, targetfile, flags)
+ -- kinds
+ local kinds =
+ {
+ static = " -lib"
+ , shared = " -shared"
+ }
+
-- make it
- if targetkind == "static" then
- return format("%s tool pack %s %s %s", _g.shellname, flags, targetfile, objectfiles)
- else
- return format("%s tool link %s -o %s %s", _g.shellname, flags, targetfile, objectfiles)
- end
+ return format("%s%s %s -of%s %s", _g.shellname, kinds[targetkind] or "", flags, targetfile, objectfiles)
end
-- link the target file
@@ -90,7 +93,7 @@ end
function compcmd(sourcefiles, objectfile, flags)
-- make it
- return format("%s %s -of%s %s", _g.shellname, flags, objectfile, table.concat(table.wrap(sourcefiles), " "))
+ return format("%s -c %s -of%s %s", _g.shellname, flags, objectfile, table.concat(table.wrap(sourcefiles), " "))
end
-- complie the source file
@@ -114,7 +117,7 @@ function check(flags)
io.write(sourcefile, "void main() {\n}")
-- check it
- os.run("%s %s -of%s %s", _g.shellname, ifelse(flags, flags, ""), objectfile, sourcefile)
+ os.run("%s -c %s -of%s %s", _g.shellname, ifelse(flags, flags, ""), objectfile, sourcefile)
-- remove files
os.rm(objectfile)