diff options
| author | ruki <[email protected]> | 2021-03-05 22:42:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-03-05 22:42:48 +0800 |
| commit | 6ad24d9abe5b30d3b3c7dbf812afc558a10ecc08 (patch) | |
| tree | 81116129f0209732ef4970627ad87c121d1652ec | |
| parent | 1e293d3a5f31afed5e4f78670d66b5b18ccc2608 (diff) | |
add is_static/is_shared
| -rw-r--r-- | xmake/actions/run/main.lua | 4 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 10 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_solution.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/utils/symbols/export_all/export_all.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/utils/symbols/export_all/xmake.lua | 2 |
5 files changed, 15 insertions, 5 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index b187357f5..04b0d76d4 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -32,7 +32,7 @@ import("private.action.run.make_runenvs") function _do_run_target(target) -- only for binary program - if target:kind() ~= "binary" then + if not target:is_binary() then return end @@ -204,7 +204,7 @@ function main() else -- run default or all binary targets for _, target in ipairs(project.ordertargets()) do - if (target:is_default() or option.get("all")) and target:kind() == "binary" then + if (target:is_default() or option.get("all")) and target:is_binary() then _run(target) end end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 22ffa5cf4..079199b47 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -650,6 +650,16 @@ function _instance:is_binary() return self:kind() == "binary" end +-- is shared library target? +function _instance:is_shared() + return self:kind() == "shared" +end + +-- is static library target? +function _instance:is_static() + return self:kind() == "static" +end + -- is default target? function _instance:is_default() local default = self:get("default") diff --git a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua index fdd948561..8b018a5d4 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua @@ -50,7 +50,7 @@ function _make_projects(slnfile, vsinfo) -- @see https://github.com/xmake-io/xmake/issues/1249 if target:get("default") == true then table.insert(targets, 1, target) - elseif target:kind() == "binary" then + elseif target:is_binary() then local first_target = targets[1] if not first_target or first_target:get("default") ~= true then table.insert(targets, 1, target) diff --git a/xmake/rules/utils/symbols/export_all/export_all.lua b/xmake/rules/utils/symbols/export_all/export_all.lua index 52408957c..5d14e979b 100644 --- a/xmake/rules/utils/symbols/export_all/export_all.lua +++ b/xmake/rules/utils/symbols/export_all/export_all.lua @@ -30,7 +30,7 @@ import("private.utils.progress") function main (target, opt) -- @note it only supports windows/dll now - assert(target:kind() == "shared", 'rule("utils.symbols.export_all"): only for shared target(%s)!', target:name()) + assert(target:is_shared(), 'rule("utils.symbols.export_all"): only for shared target(%s)!', target:name()) if not target:is_plat("windows") or option.get("dry-run") then return end diff --git a/xmake/rules/utils/symbols/export_all/xmake.lua b/xmake/rules/utils/symbols/export_all/xmake.lua index 9d766356e..f804e3c3e 100644 --- a/xmake/rules/utils/symbols/export_all/xmake.lua +++ b/xmake/rules/utils/symbols/export_all/xmake.lua @@ -28,7 +28,7 @@ rule("utils.symbols.export_all") before_load(function (target) -- @note it only supports windows/dll now - assert(target:kind() == "shared", 'rule("utils.symbols.export_all"): only for shared target(%s)!', target:name()) + assert(target:is_shared(), 'rule("utils.symbols.export_all"): only for shared target(%s)!', target:name()) if target:is_plat("windows") then assert(target:get("optimize") ~= "smallest", 'rule("utils.symbols.export_all"): does not support set_optimize("smallest") for target(%s)!', target:name()) local allsymbols_filepath = path.join(target:autogendir(), "rules", "symbols", "export_all.def") |
