summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-23 09:06:08 +0800
committerruki <[email protected]>2017-02-23 09:06:08 +0800
commitbfd35395066fbea02062309dfea660144d162c43 (patch)
treef0403e610b0b70a72ebc6491d8f67252220d517e
parent4d6a57bfa24a9e0c8a35b18ba69face0d66c1a75 (diff)
improve linux platform
-rw-r--r--xmake/platforms/checker.lua23
-rw-r--r--xmake/platforms/linux/check.lua100
-rw-r--r--xmake/platforms/linux/load.lua25
3 files changed, 74 insertions, 74 deletions
diff --git a/xmake/platforms/checker.lua b/xmake/platforms/checker.lua
index e6a4ce268..856b3c696 100644
--- a/xmake/platforms/checker.lua
+++ b/xmake/platforms/checker.lua
@@ -210,15 +210,17 @@ function check_toolchain(config, kind, cross, name, description, check)
local toolpath = config.get(kind)
if not toolpath then
- -- get shell name from the env
- local shellname = os.getenv(kind:upper())
- if shellname and shellname:trim() ~= "" then
- toolpath = tool.check(shellname)
- end
-
-- get the cross
cross = config.get("cross") or cross
+ -- get shell name from the env if not cross-compilation
+ if cross and cross:trim() == "" then
+ local shellname = os.getenv(kind:upper():split('-')[1])
+ if shellname and shellname:trim() ~= "" then
+ toolpath = tool.check(shellname)
+ end
+ end
+
-- check it using the custom script
if not toolpath and check then
@@ -276,13 +278,4 @@ function check_toolchain(config, kind, cross, name, description, check)
end
end
--- check the toolchain from env
-function check_toolchain_from_env(config, kind, envname, description, check)
-
- -- get shell name from the env
- local shellname = os.getenv(envname)
- if shellname and shellname:trim() ~= "" then
- check_toolchain(config, kind, "", shellname, description, check)
- end
-end
diff --git a/xmake/platforms/linux/check.lua b/xmake/platforms/linux/check.lua
index e4a3b1a5a..e24235f8f 100644
--- a/xmake/platforms/linux/check.lua
+++ b/xmake/platforms/linux/check.lua
@@ -65,61 +65,59 @@ function _check_toolchains(config)
end
end
- -- no cross toolchains?
- if cross and cross:trim() == "" then
- -- check from env
- checker.check_toolchain_from_env(config, "cc", "CC", "the c compiler")
- checker.check_toolchain_from_env(config, "cxx", "CXX", "the c++ compiler")
- checker.check_toolchain_from_env(config, "mm", "MM", "the objc compiler")
- checker.check_toolchain_from_env(config, "mxx", "MXX", "the objc++ compiler")
- checker.check_toolchain_from_env(config, "as", "AS", "the assember")
- checker.check_toolchain_from_env(config, "ld", "LD", "the linker")
- 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, "sc", "SC", "the swift compiler")
- end
+ -- check for c/c++ tools
+ checker.check_toolchain(config, "cc", cross, "gcc", "the c compiler")
+ checker.check_toolchain(config, "cc", cross, "clang", "the c compiler")
+ checker.check_toolchain(config, "cxx", cross, "gcc", "the c++ compiler")
+ checker.check_toolchain(config, "cxx", cross, "clang", "the c++ compiler")
+ checker.check_toolchain(config, "cxx", cross, "g++", "the c++ compiler")
+ checker.check_toolchain(config, "cxx", cross, "clang++", "the c++ compiler")
+ checker.check_toolchain(config, "ld", cross, "g++", "the linker")
+ checker.check_toolchain(config, "ld", cross, "gcc", "the linker")
+ checker.check_toolchain(config, "ld", cross, "clang++", "the linker")
+ checker.check_toolchain(config, "ld", cross, "clang", "the linker")
+ checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
+ checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
+ checker.check_toolchain(config, "sh", cross, "g++", "the shared library linker")
+ checker.check_toolchain(config, "sh", cross, "gcc", "the shared library linker")
+ checker.check_toolchain(config, "sh", cross, "clang++", "the shared library linker")
+ checker.check_toolchain(config, "sh", cross, "clang", "the shared library linker")
+ checker.check_toolchain(config, "dg", cross, "gdb", "the debugger")
+ checker.check_toolchain(config, "dg", cross, "lldb", "the debugger")
- -- check for gcc
- checker.check_toolchain(config, "cc", cross, "gcc", "the c compiler")
- checker.check_toolchain(config, "cxx", cross, "gcc", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "g++", "the c++ compiler")
- checker.check_toolchain(config, "mm", cross, "gcc", "the objc compiler")
- checker.check_toolchain(config, "mxx", cross, "gcc", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", cross, "g++", "the objc++ compiler")
- checker.check_toolchain(config, "as", cross, "gcc", "the assember")
- checker.check_toolchain(config, "ld", cross, "g++", "the linker")
- checker.check_toolchain(config, "ld", cross, "gcc", "the linker")
- checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", cross, "g++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "gcc", "the shared library linker")
- checker.check_toolchain(config, "dg", cross, "gdb", "the debugger")
+ -- check for objc/c++ tools
+ checker.check_toolchain(config, "mm", cross, "clang", "the objc compiler")
+ checker.check_toolchain(config, "mm", cross, "gcc", "the objc compiler")
+ checker.check_toolchain(config, "mxx", cross, "clang++", "the objc++ compiler")
+ checker.check_toolchain(config, "mxx", cross, "clang", "the objc++ compiler")
+ checker.check_toolchain(config, "mxx", cross, "g++", "the objc++ compiler")
+ checker.check_toolchain(config, "mxx", cross, "gcc", "the objc++ compiler")
- -- check for clang
- checker.check_toolchain(config, "cc", cross, "clang", "the c compiler")
- checker.check_toolchain(config, "cxx", cross, "clang", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "clang++", "the c++ compiler")
- checker.check_toolchain(config, "mm", cross, "clang", "the objc compiler")
- checker.check_toolchain(config, "mxx", cross, "clang++", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", cross, "clang", "the objc++ compiler")
- checker.check_toolchain(config, "as", cross, "clang", "the assember")
- checker.check_toolchain(config, "ld", cross, "clang++", "the linker")
- checker.check_toolchain(config, "ld", cross, "clang", "the linker")
- checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", cross, "clang++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "clang", "the shared library linker")
- checker.check_toolchain(config, "sc", cross, "swiftc", "the swift compiler")
- checker.check_toolchain(config, "dg", cross, "lldb", "the debugger")
+ -- check for asm tools
+ checker.check_toolchain(config, "as", cross, "clang", "the assember")
+ checker.check_toolchain(config, "as", cross, "gcc", "the assember")
-- 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, "dc", "", "dmd", "the dlang compiler")
+ checker.check_toolchain(config, "dc", "", "ldc2", "the dlang compiler")
+ checker.check_toolchain(config, "dc", "", "gdc", "the dlang compiler")
+ checker.check_toolchain(config, "dc-ar", "", "dmd", "the dlang static library archiver")
+ checker.check_toolchain(config, "dc-ar", "", "ldc2", "the dlang static library archiver")
+ checker.check_toolchain(config, "dc-ar", "", "gdc", "the dlang static library archiver")
+ checker.check_toolchain(config, "dc-sh", "", "dmd", "the dlang shared library linker")
+ checker.check_toolchain(config, "dc-sh", "", "ldc2", "the dlang shared library linker")
+ checker.check_toolchain(config, "dc-sh", "", "gdc", "the dlang shared library linker")
+ checker.check_toolchain(config, "dc-ld", "", "dmd", "the dlang linker")
+ checker.check_toolchain(config, "dc-ld", "", "ldc2", "the dlang linker")
+ checker.check_toolchain(config, "dc-ld", "", "gdc", "the dlang linker")
end
-- check it
diff --git a/xmake/platforms/linux/load.lua b/xmake/platforms/linux/load.lua
index 2959bc566..cad303f7a 100644
--- a/xmake/platforms/linux/load.lua
+++ b/xmake/platforms/linux/load.lua
@@ -58,15 +58,24 @@ function main()
else archflags = "-arch " .. arch
end
end
- _g.cxflags = { archflags }
- _g.mxflags = { archflags }
- _g.asflags = { archflags }
- _g.ldflags = { archflags }
- _g.shflags = { archflags }
- -- init linkdirs and includedirs
- _g.linkdirs = {"/usr/lib", "/usr/local/lib"}
- _g.includedirs = {"/usr/include", "/usr/local/include"}
+ -- init flags for c/c++
+ _g.cxflags = { archflags, "-I/usr/local/include", "-I/usr/include" }
+ _g.ldflags = { archflags, "-L/usr/local/lib", "-L/usr/lib" }
+ _g.shflags = { archflags, "-L/usr/local/lib", "-L/usr/lib" }
+
+ -- init flags for objc/c++ (with _g.ldflags and _g.shflags)
+ _g.mxflags = { archflags }
+
+ -- init flags for asm (with _g.ldflags and _g.shflags)
+ _g.asflags = { archflags }
+
+ -- init flags for golang
+ _g["go-ldflags"] = {}
+
+ -- init flags for dlang
+ _g["dc-shflags"] = {}
+ _g["dc-ldflags"] = {}
-- ok
return _g