From 7b61af9bfeab6bd8d7dcc33baba3607abaa03928 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 14 May 2024 00:48:39 +0800 Subject: [PATCH 1/4] link full path for packages #5066 --- xmake/core/project/target.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index c933b4a9afc..1cc0c00932f 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -304,7 +304,13 @@ end -- get values from target packages with {interface|public = ...} function _instance:_get_from_packages(name, result_values, result_sources, opt) for _, pkg in ipairs(self:orderpkgs(opt)) do + -- use full link path instead of links + -- @see https://github.com/xmake-io/xmake/issues/5066 + local valuename = name local configinfo = self:pkgconfig(pkg:name()) + if name == "links" and configinfo and configinfo.linkpath and pkg:get("libfiles") then + valuename = "libfiles" + end -- get values from package components -- e.g. `add_packages("sfml", {components = {"graphics", "window"}})` local selected_components = configinfo and configinfo.components or pkg:components_default() @@ -325,7 +331,7 @@ function _instance:_get_from_packages(name, result_values, result_sources, opt) if components_enabled:has(component_name) then local info = components[component_name] if info then - table.join2(values, info[name]) + table.join2(values, info[valuename]) else local components_str = table.concat(table.wrap(configinfo.components), ", ") utils.warning("unknown component(%s) in add_packages(%s, {components = {%s}})", component_name, pkg:name(), components_str) @@ -346,7 +352,7 @@ function _instance:_get_from_packages(name, result_values, result_sources, opt) end else -- get values from the builtin package configs - local values = pkg:get(name) + local values = pkg:get(valuename) if values ~= nil then table.insert(result_values, values) table.insert(result_sources, "package::" .. pkg:name()) From 3cf9f4d5b831280e2668557a09f0e21441f41802 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 14 May 2024 00:52:47 +0800 Subject: [PATCH 2/4] improve package links --- xmake/core/project/target.lua | 36 +++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 1cc0c00932f..58c5c89d949 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -303,14 +303,17 @@ end -- get values from target packages with {interface|public = ...} function _instance:_get_from_packages(name, result_values, result_sources, opt) + local function _filter_libfiles(libfiles) + local result = {} + for _, libfile in ipairs(table.wrap(libfiles)) do + if not libfile:endswith(".dll") then + table.insert(result, libfiles) + end + end + return table.unwrap(result) + end for _, pkg in ipairs(self:orderpkgs(opt)) do - -- use full link path instead of links - -- @see https://github.com/xmake-io/xmake/issues/5066 - local valuename = name local configinfo = self:pkgconfig(pkg:name()) - if name == "links" and configinfo and configinfo.linkpath and pkg:get("libfiles") then - valuename = "libfiles" - end -- get values from package components -- e.g. `add_packages("sfml", {components = {"graphics", "window"}})` local selected_components = configinfo and configinfo.components or pkg:components_default() @@ -331,7 +334,16 @@ function _instance:_get_from_packages(name, result_values, result_sources, opt) if components_enabled:has(component_name) then local info = components[component_name] if info then - table.join2(values, info[valuename]) + local compvalues = info[name] + -- use full link path instead of links + -- @see https://github.com/xmake-io/xmake/issues/5066 + if name == "links" and configinfo and configinfo.linkpath then + local libfiles = info.libfiles + if libfiles then + compvalues = _filter_libfiles(libfiles) + end + end + table.join2(values, compvalues) else local components_str = table.concat(table.wrap(configinfo.components), ", ") utils.warning("unknown component(%s) in add_packages(%s, {components = {%s}})", component_name, pkg:name(), components_str) @@ -352,7 +364,15 @@ function _instance:_get_from_packages(name, result_values, result_sources, opt) end else -- get values from the builtin package configs - local values = pkg:get(valuename) + local values = pkg:get(name) + -- use full link path instead of links + -- @see https://github.com/xmake-io/xmake/issues/5066 + if name == "links" and configinfo and configinfo.linkpath then + local libfiles = pkg:libraryfiles() + if libfiles then + values = _filter_libfiles(libfiles) + end + end if values ~= nil then table.insert(result_values, values) table.insert(result_sources, "package::" .. pkg:name()) From 5148f8f3c0c492810c85f42dbc09a89dc8201d2e Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 14 May 2024 00:53:42 +0800 Subject: [PATCH 3/4] fix libfiles --- xmake/core/project/target.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 58c5c89d949..03e7ff62608 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -307,7 +307,7 @@ function _instance:_get_from_packages(name, result_values, result_sources, opt) local result = {} for _, libfile in ipairs(table.wrap(libfiles)) do if not libfile:endswith(".dll") then - table.insert(result, libfiles) + table.insert(result, libfile) end end return table.unwrap(result) From 0c7941e96868550daf639cfd50762a6d2b03f12e Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 14 May 2024 00:54:22 +0800 Subject: [PATCH 4/4] remove linkdirs for linkpath --- xmake/core/project/target.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 03e7ff62608..3b98e15f2f8 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -337,10 +337,16 @@ function _instance:_get_from_packages(name, result_values, result_sources, opt) local compvalues = info[name] -- use full link path instead of links -- @see https://github.com/xmake-io/xmake/issues/5066 - if name == "links" and configinfo and configinfo.linkpath then + if configinfo and configinfo.linkpath then local libfiles = info.libfiles - if libfiles then - compvalues = _filter_libfiles(libfiles) + if name == "links" then + if libfiles then + compvalues = _filter_libfiles(libfiles) + end + elseif name == "linkdirs" then + if libfiles then + compvalues = nil + end end end table.join2(values, compvalues) @@ -367,10 +373,16 @@ function _instance:_get_from_packages(name, result_values, result_sources, opt) local values = pkg:get(name) -- use full link path instead of links -- @see https://github.com/xmake-io/xmake/issues/5066 - if name == "links" and configinfo and configinfo.linkpath then + if configinfo and configinfo.linkpath then local libfiles = pkg:libraryfiles() - if libfiles then - values = _filter_libfiles(libfiles) + if name == "links" then + if libfiles then + values = _filter_libfiles(libfiles) + end + elseif name == "linkdirs" then + if libfiles then + values = nil + end end end if values ~= nil then