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/prober.lua | |
| parent | 99b9eb72c8db9854311fc0b5a79e07f8cae85242 (diff) | |
update platform for linux
Diffstat (limited to 'xmake/scripts/platform/linux/prober.lua')
| -rw-r--r-- | xmake/scripts/platform/linux/prober.lua | 76 |
1 files changed, 74 insertions, 2 deletions
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 |
