diff options
| author | ruki <[email protected]> | 2020-05-18 22:51:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-18 11:06:56 +0800 |
| commit | 3537041f82f3c12f6c9312b3325550d1f18eb94e (patch) | |
| tree | cd575f4f53b5b6e42ea877cbd196054288372145 /xmake/core/platform/platform.lua | |
| parent | 8405406c0519338e1cfb75746e4b31ca5b6c3cc7 (diff) | |
add platform.toolconfig
Diffstat (limited to 'xmake/core/platform/platform.lua')
| -rw-r--r-- | xmake/core/platform/platform.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 677e36906..1bb76db92 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -141,6 +141,36 @@ function _instance:tool(toolkind) end end +-- get tool configuration from the toolchains +function _instance:toolconfig(name) + + -- init tool configs + local toolconfigs = self._TOOLCONFIGS + if not toolconfigs then + toolconfigs = {} + self._TOOLCONFIGS = toolconfigs + end + + -- get configuration + local toolconfig = toolconfigs[name] + if toolconfig == nil then + + -- get them from all toolchains + for _, toolchain_inst in ipairs(self:toolchains()) do + local values = toolchain_inst:get(name) + if values then + toolconfig = toolconfig or {} + table.join2(toolconfig, values) + end + end + + -- cache it + toolconfig = toolconfig or false + toolconfigs[name] = toolconfig + end + return toolconfig or nil +end + -- get the platform script function _instance:script(name) return self._INFO:get(name) @@ -388,6 +418,16 @@ function platform.tool(toolkind, plat) return program, toolname end +-- get the given tool configuration +function platform.toolconfig(name, plat) + local instance, errors = platform.load(plat) + if instance then + return instance:toolconfig(name) + else + os.raise(errors) + end +end + -- get the all platforms function platform.plats() |
