diff options
| author | ruki <[email protected]> | 2025-06-30 18:14:44 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-30 18:14:44 +0800 |
| commit | 5cf24e4202abda4b61c3d06720e7eb820dfe42ba (patch) | |
| tree | 63e399834a17bbdabeb89a000d3fe8079007c73c | |
| parent | bbf84a79b6381ffe0a61b69e4eed498a4b966b69 (diff) | |
| parent | c6fb51d7c527267310e3c69a11a42d7202208e05 (diff) | |
Merge pull request #6597 from Doekin/pc-file
package(install): refine relative path generation in .pc files
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/install.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/target/action/install/pkgconfig_importfiles.lua | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index 4d0bada1f..907490a1e 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -78,10 +78,10 @@ function _patch_pkgconfig(package) -- get libs local libs = "" - local base_libdir = path.join(installdir, "lib") for _, linkdir in ipairs(fetchinfo.linkdirs) do - if linkdir ~= base_libdir then - libs = libs .. " -L" .. "${libdir}/" .. path.unix(path.relative(linkdir, base_libdir)) + linkdir = path.unix(path.normalize(linkdir)):replace(installdir, "${exec_prefix}", {plain = true}) + if linkdir ~= "${exec_prefix}/lib" then + libs = libs .. " -L" .. linkdir end end libs = libs .. " -L${libdir}" @@ -94,10 +94,10 @@ function _patch_pkgconfig(package) -- cflags local cflags = "" - local base_includedir = path.join(installdir, "include") for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do - if includedir ~= base_includedir then - cflags = cflags .. " -I" .. "${includedir}/" .. path.unix(path.relative(includedir, base_includedir)) + includedir = path.unix(path.normalize(includedir)):replace(installdir, "${prefix}", {plain = true}) + if includedir ~= "${prefix}/include" then + cflags = cflags .. " -I" .. includedir end end cflags = cflags .. " -I${includedir}" diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua index 67ab51b64..aa44263c9 100644 --- a/xmake/modules/target/action/install/pkgconfig_importfiles.lua +++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua @@ -41,10 +41,10 @@ function main(target, opt) -- get libs local libs = "" - local base_libdir = path.join(installdir, "lib") for _, linkdir in ipairs(linkdirs) do - if linkdir ~= base_libdir then - libs = libs .. " -L" .. "${libdir}/" .. path.unix(path.relative(linkdir, base_libdir)) + linkdir = path.unix(path.normalize(linkdir)):replace(installdir, "${exec_prefix}", {plain = true}) + if linkdir ~= "${exec_prefix}/lib" then + libs = libs .. " -L" .. linkdir end end libs = libs .. " -L${libdir}" @@ -57,10 +57,10 @@ function main(target, opt) -- get cflags local cflags = "" - local base_includedir = path.join(installdir, "include") for _, includedir in ipairs(includedirs) do - if includedir ~= base_includedir then - cflags = cflags .. " -I" .. "${includedir}/" .. path.unix(path.relative(includedir, base_includedir)) + includedir = path.unix(path.normalize(includedir)):replace(installdir, "${prefix}", {plain = true}) + if includedir ~= "${prefix}/include" then + cflags = cflags .. " -I" .. includedir end end cflags = cflags .. " -I${includedir}" |
