diff options
| author | ruki <[email protected]> | 2020-05-22 22:49:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-22 10:58:29 +0800 |
| commit | 9a3ccbc46480462a7d2a702c8c635af17cd85249 (patch) | |
| tree | 19595fb3fc9235ed2deec008edcee470652957de | |
| parent | b1df391694245eb0f1555b3855fad3faee0d2a82 (diff) | |
load toolchain from project
| -rw-r--r-- | xmake/core/main.lua | 1 | ||||
| -rw-r--r-- | xmake/core/platform/platform.lua | 15 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 3 | ||||
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 9 |
4 files changed, 21 insertions, 7 deletions
diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 63270ee15..ea85a605e 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -191,7 +191,6 @@ function main._init() else os.addenv("PATH", os.programdir()) end - return true end diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index af6a2f0e0..eb247f7af 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -135,6 +135,10 @@ function _instance:toolchains(opt) local toolchain_given = config.get("toolchain") if toolchain_given then local toolchain_inst, errors = toolchain.load(toolchain_given) + -- attempt to load toolchain from project + if not toolchain_inst and platform._project() then + toolchain_inst = platform._project().toolchain(toolchain_given) + end if not toolchain_inst then os.raise(errors) end @@ -149,7 +153,11 @@ function _instance:toolchains(opt) end if names then for _, name in ipairs(names) do - local toolchain_inst, errors = toolchain.load(name, self:name()) + local toolchain_inst, errors = toolchain.load(name) + -- attempt to load toolchain from project + if not toolchain_inst and platform._project() then + toolchain_inst = platform._project().toolchain(name) + end if not toolchain_inst then os.raise(errors) end @@ -343,6 +351,11 @@ function platform._interpreter() return interp end +-- get project +function platform._project() + return platform._PROJECT +end + -- get platform apis function platform._apis() return diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 08f843d0e..1c97bdfd4 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -47,6 +47,9 @@ local language = require("language/language") local sandbox_os = require("sandbox/modules/os") local sandbox_module = require("sandbox/modules/import/core/sandbox/module") +-- register project to platform +platform._PROJECT = project + -- the current os is belong to the given os? function project._api_is_os(interp, ...) diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index dd682d3b2..e2220127e 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -139,7 +139,7 @@ function _instance:sdkdir() return config.get("sdk") or self:get("sdkdir") end --- do load +-- do load, @note we need load it repeatly for each architectures function _instance:_load() local info = self:info() if not info:get("__loaded") and not info:get("__loading") then @@ -156,11 +156,10 @@ function _instance:_load() end end --- do check +-- do check, we only check it once for all architectures function _instance:check() local checkok = true - local info = self:info() - if not info:get("__checked") then + if not self._CHECKED then local on_check = self:info():get("check") if on_check then local ok, results_or_errors = sandbox.load(on_check, self) @@ -170,7 +169,7 @@ function _instance:check() os.raise(results_or_errors) end end - info:set("__checked", true) + self._CHECKED = true end return checkok end |
