diff options
| author | ruki <[email protected]> | 2020-03-16 23:02:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-16 12:13:35 +0800 |
| commit | 76e2096c698142f07f3db817fc1a229c931cc274 (patch) | |
| tree | 2f48068be3eccfcedf3dbc53d54681124a80a3ca | |
| parent | 84ac2ca8ec5bb77cd994c6f4d42573920a45f14a (diff) | |
improve platform.tool
| -rw-r--r-- | xmake/core/platform/platform.lua | 28 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_sdar.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_sdcc.lua | 6 | ||||
| -rw-r--r-- | xmake/platforms/cross/config.lua | 17 |
4 files changed, 44 insertions, 13 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 831935b6a..580645248 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -23,14 +23,15 @@ local platform = platform or {} local _instance = _instance or {} -- load modules -local os = require("base/os") -local path = require("base/path") -local utils = require("base/utils") -local table = require("base/table") -local interpreter = require("base/interpreter") -local sandbox = require("sandbox/sandbox") -local config = require("project/config") -local global = require("base/global") +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") +local table = require("base/table") +local interpreter = require("base/interpreter") +local sandbox = require("sandbox/sandbox") +local config = require("project/config") +local global = require("base/global") +local sandbox_module = require("sandbox/modules/import/core/sandbox/module") -- new an instance function _instance.new(name, info, rootdir) @@ -311,6 +312,7 @@ end function platform.tool(toolkind, plat) -- attempt to get program from config first + local checked = false local program = config.get(toolkind) local toolname = config.get("__toolname_" .. toolkind) if program == nil then @@ -330,6 +332,7 @@ function platform.tool(toolkind, plat) -- get it again program = config.get(toolkind) toolname = config.get("__toolname_" .. toolkind) + checked = true end -- contain toolname? parse it, e.g. '[email protected]' @@ -341,6 +344,15 @@ function platform.tool(toolkind, plat) end end + -- not checked? we check it now + if program and not checked then + local tool = sandbox_module.import("lib.detect.find_tool", {anonymous = true})(toolname or program, {program = program}) + if tool and tool.program and tool.program ~= program then + program = tool.program + config.set(toolkind, program, {force = true, readonly = true}) + end + end + -- ok return program, toolname end diff --git a/xmake/modules/detect/tools/find_sdar.lua b/xmake/modules/detect/tools/find_sdar.lua index e133478cd..4f1ed46bc 100644 --- a/xmake/modules/detect/tools/find_sdar.lua +++ b/xmake/modules/detect/tools/find_sdar.lua @@ -39,6 +39,12 @@ function main(opt) -- init options opt = opt or {} opt.command = opt.command or "--version" + + -- add search pathes (sdk/bin) + local bindir = get_config("bin") + if bindir and os.isdir(bindir) then + opt.pathes = bindir + end -- find program local program = find_program(opt.program or "sdar", opt) diff --git a/xmake/modules/detect/tools/find_sdcc.lua b/xmake/modules/detect/tools/find_sdcc.lua index 01621cce0..a57a343db 100644 --- a/xmake/modules/detect/tools/find_sdcc.lua +++ b/xmake/modules/detect/tools/find_sdcc.lua @@ -39,6 +39,12 @@ function main(opt) -- init options opt = opt or {} opt.command = opt.command or "--version" + + -- add search pathes (sdk/bin) + local bindir = get_config("bin") + if bindir and os.isdir(bindir) then + opt.pathes = bindir + end -- find program local program = find_program(opt.program or "sdcc", opt) diff --git a/xmake/platforms/cross/config.lua b/xmake/platforms/cross/config.lua index c22dd7b6b..a360dfaa8 100644 --- a/xmake/platforms/cross/config.lua +++ b/xmake/platforms/cross/config.lua @@ -36,16 +36,13 @@ function _check_arch() end end --- get toolchains -function _toolchains() - +-- check the cross toolchain +function _check_cross_toolchain() -- find cross toolchain - local cross = "" local cross_toolchain = find_cross_toolchain(config.get("sdk") or config.get("bin"), {bindir = config.get("bin"), cross = config.get("cross")}) if cross_toolchain then config.set("cross", cross_toolchain.cross, {readonly = true, force = true}) config.set("bin", cross_toolchain.bindir, {readonly = true, force = true}) - cross = cross_toolchain.cross -- TODO add to environment module -- add bin search library for loading some dependent .dll files windows @@ -53,6 +50,13 @@ function _toolchains() os.addenv("PATH", cross_toolchain.bindir) end end +end + +-- get toolchains +function _toolchains() + + -- get cross prefix + local cross = config.get("cross") or "" -- init toolchains local cc = toolchain("the c compiler") @@ -120,6 +124,9 @@ function main(platform, name) -- check arch _check_arch() + + -- check cross toolchain + _check_cross_toolchain() end end |
