diff options
| author | ruki <[email protected]> | 2019-09-14 08:54:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-09-14 08:54:54 +0800 |
| commit | c08df8d304703ca1153019825ac3cc378ac92e32 (patch) | |
| tree | 05ecce5356d8e25b20136125c75a351b9c7f1371 | |
| parent | 56021b09ccfadde89756298c7d9afd688c896d21 (diff) | |
uses set_toolchain instead of set_tools and add_tools
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | xmake/core/project/deprecated/project.lua | 40 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 5 | ||||
| -rw-r--r-- | xmake/core/tool/compiler.lua | 9 | ||||
| -rw-r--r-- | xmake/core/tool/linker.lua | 9 |
5 files changed, 57 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b3db55fb..56f891e9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * [#563](https://github.com/xmake-io/xmake/pull/563): Separate build rules for specific language files from action/build * [#570](https://github.com/xmake-io/xmake/issues/570): Add `qt.widgetapp` and `qt.quickapp` rules +* [#576](https://github.com/xmake-io/xmake/issues/576): Uses `set_toolchain` instead of `add_tools` and `set_tools` ### Bugs fixed @@ -650,6 +651,7 @@ * [#563](https://github.com/xmake-io/xmake/pull/563): 重构构建逻辑,将特定语言的构建抽离到独立的rules中去 * [#570](https://github.com/xmake-io/xmake/issues/570): 改进Qt构建,将`qt.application`拆分成`qt.widgetapp`和`qt.quickapp`两个构建规则 +* [#576](https://github.com/xmake-io/xmake/issues/576): 使用`set_toolchain`替代`add_tools`和`set_tools`,解决老接口使用歧义,提供更加易理解的设置方式 ### Bugs修复 diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua index 85d05ed8f..5d1b09f8a 100644 --- a/xmake/core/project/deprecated/project.lua +++ b/xmake/core/project/deprecated/project.lua @@ -242,6 +242,42 @@ function deprecated_project._api_target_set_headerdir(interp) end) end +-- set_tools for target +function deprecated_project._api_target_set_tools(interp) + + -- get api function + local apifunc = interp:_api_within_scope("target", "set_tools") + assert(apifunc) + + -- register api + interp:_api_within_scope_set("target", "set_tools", function (key, value, ...) + + -- deprecated + deprecated.add("set_tools(%s, %s)", "set_toolchain(%s, %s)", tostring(key), tostring(value)) + + -- dispatch it + apifunc(key, value, ...) + end) +end + +-- add_tools for target +function deprecated_project._api_target_add_tools(interp) + + -- get api function + local apifunc = interp:_api_within_scope("target", "add_tools") + assert(apifunc) + + -- register api + interp:_api_within_scope_set("target", "add_tools", function (key, value, ...) + + -- deprecated + deprecated.add("add_tools(%s, %s)", "add_toolchain(%s, %s)", tostring(key), tostring(value)) + + -- dispatch it + apifunc(key, value, ...) + end) +end + -- enable options? function deprecated_project._api_is_option(interp, ...) @@ -294,6 +330,10 @@ function deprecated_project.api_register(interp) -- register api: set_headerdir() to target deprecated_project._api_target_set_headerdir(interp) + + -- register api: set_tools/add_tools() to target + deprecated_project._api_target_set_tools(interp) + deprecated_project._api_target_add_tools(interp) end -- return module: deprecated_project diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 5584ed569..0c3802347 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1602,6 +1602,7 @@ function target.apis() "target.set_values" , "target.set_configvar" , "target.set_runenv" + , "target.set_toolchain" -- target.add_xxx , "target.add_values" , "target.add_runenvs" @@ -1626,8 +1627,8 @@ function target.apis() , dictionary = { -- target.set_xxx - "target.set_tools" - , "target.add_tools" + "target.set_tools" -- TODO: deprecated + , "target.add_tools" -- TODO: deprecated } , script = { diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index cf0bf3245..67d82a1bf 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -73,9 +73,12 @@ function compiler._load_tool(sourcekind, target) -- get program from target local program = nil if target then - local tools = target:get("tools") - if tools then - program = tools[sourcekind] + program = target:get("toolchain." .. sourcekind) + if not program then + local tools = target:get("tools") -- TODO: deprecated + if tools then + program = tools[sourcekind] + end end end diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua index 2355c5f50..bc0d2eb10 100644 --- a/xmake/core/tool/linker.lua +++ b/xmake/core/tool/linker.lua @@ -80,9 +80,12 @@ function linker._load_tool(targetkind, sourcekinds, target) -- get program from target local program = nil if target then - local tools = target:get("tools") - if tools then - program = tools[_linkerinfo.linkerkind] + program = target:get("toolchain." .. _linkerinfo.linkerkind) + if not program then + local tools = target:get("tools") -- TODO: deprecated + if tools then + program = tools[_linkerinfo.linkerkind] + end end end |
