diff options
| author | ruki <[email protected]> | 2015-06-12 12:45:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-12 12:45:43 +0800 |
| commit | 1b9fc52acd62fea9dfa017481b146cf59993b1df (patch) | |
| tree | cd3d531fc73051415e32877eca2f49d0b7c3e9fb /xmake/scripts/platform/linux | |
| parent | 99b9eb72c8db9854311fc0b5a79e07f8cae85242 (diff) | |
update platform for linux
Diffstat (limited to 'xmake/scripts/platform/linux')
| -rw-r--r-- | xmake/scripts/platform/linux/linux.lua | 31 | ||||
| -rw-r--r-- | xmake/scripts/platform/linux/prober.lua | 76 |
2 files changed, 97 insertions, 10 deletions
diff --git a/xmake/scripts/platform/linux/linux.lua b/xmake/scripts/platform/linux/linux.lua index 6c68a6f1b..40f9b5999 100644 --- a/xmake/scripts/platform/linux/linux.lua +++ b/xmake/scripts/platform/linux/linux.lua @@ -43,15 +43,30 @@ function linux.make(configs) -- init the toolchains configs.tools = {} - configs.tools.make = "make" + configs.tools.make = config.get("make") configs.tools.ccache = config.get("__ccache") - configs.tools.cc = config.get("cc") or "gcc" - configs.tools.cxx = config.get("cxx") or "g++" - configs.tools.mm = config.get("mm") or configs.tools.cc - configs.tools.mxx = config.get("mxx") or configs.tools.cxx - configs.tools.ld = config.get("ld") or "g++" - configs.tools.ar = config.get("ar") or "ar" - configs.tools.sh = config.get("sh") or "g++" + configs.tools.cc = config.get("cc") + configs.tools.cxx = config.get("cxx") + configs.tools.mm = config.get("mm") + configs.tools.mxx = config.get("mxx") + configs.tools.ld = config.get("ld") + configs.tools.ar = config.get("ar") + configs.tools.sh = config.get("sh") + + -- init flags for architecture + local archflags = nil + local arch = config.get("arch") + if arch then + if arch == "x64" then archflags = "-m64" + elseif arch == "x86" then archflags = "-m32" + else archflags = "-arch " .. arch + end + end + configs.cxflags = { archflags } + configs.mxflags = { archflags } + configs.asflags = { archflags } + configs.ldflags = { archflags } + configs.shflags = { archflags } end diff --git a/xmake/scripts/platform/linux/prober.lua b/xmake/scripts/platform/linux/prober.lua index 9f18ccd15..ce23dadb5 100644 --- a/xmake/scripts/platform/linux/prober.lua +++ b/xmake/scripts/platform/linux/prober.lua @@ -51,6 +51,26 @@ function prober._probe_arch(configs) return true end +-- probe the make +function prober._probe_make(configs) + + -- ok? + local make = configs.get("make") + if make then return true end + + -- probe the make path + make = tools.probe("make", {"/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin"}) + + -- probe ok? update it + if make then configs.set("make", make) end + + -- trace + utils.verbose("checking for the make ... %s", utils.ifelse(make, make, "no")) + + -- ok + return true +end + -- probe the ccache function prober._probe_ccache(configs) @@ -82,12 +102,63 @@ function prober._probe_ccache(configs) return true end +-- probe the tool path +function prober._probe_toolpath(configs, kind, cross, name, description) + + -- check + assert(kind) + + -- get the cross + cross = configs.get("cross") or cross + + -- attempt to get it from the given cross toolchains + local toolpath = nil + local toolchains = configs.get("toolchains") + if toolchains then + toolpath = tools.probe(cross .. (configs.get(kind) or name), toolchains) + end + + -- attempt to get it directly from the configure + if not toolpath then + toolpath = configs.get(kind) + end + + -- attempt to run it directly + if not toolpath then + toolpath = tools.probe(cross .. name) + end + + -- probe ok? update it + if toolpath then configs.set(kind, toolpath) end + + -- trace + utils.verbose("checking for %s (%s) ... %s", description, kind, utils.ifelse(toolpath, path.filename(toolpath), "no")) + + -- ok + return true +end + +-- probe the toolchains +function prober._probe_toolchains(configs) + + -- done + if not prober._probe_toolpath(configs, "cc", "", "gcc", "the c compiler") then return false end + if not prober._probe_toolpath(configs, "cxx", "", "g++", "the c++ compiler") then return false end + if not prober._probe_toolpath(configs, "as", "", "gcc", "the assember") then return false end + if not prober._probe_toolpath(configs, "ld", "", "g++", "the linker") then return false end + if not prober._probe_toolpath(configs, "ar", "", "ar", "the static library linker") then return false end + if not prober._probe_toolpath(configs, "sh", "", "g++", "the shared library linker") then return false end + return true +end + -- probe the project configure function prober.config() -- call all probe functions utils.call( { prober._probe_arch - , prober._probe_ccache} + , prober._probe_make + , prober._probe_ccache + , prober._probe_toolchains} , nil , config) end @@ -96,7 +167,8 @@ end function prober.global() -- call all probe functions - utils.call( prober._probe_ccache + utils.call( { prober._probe_make + , prober._probe_ccache} , nil , global) end |
