Skip to content

package(install): refine relative path generation in .pc files#6597

Merged
waruqi merged 1 commit intoxmake-io:devfrom
Doekin:pc-file
Jun 30, 2025
Merged

package(install): refine relative path generation in .pc files#6597
waruqi merged 1 commit intoxmake-io:devfrom
Doekin:pc-file

Conversation

@Doekin
Copy link
Contributor

@Doekin Doekin commented Jun 30, 2025

A previous change (#6445) was introduced to improve the relocatability of packages by using relative paths in the generated .pc files. However, this had an undesirable side effect when handling paths to external dependencies.

The Problem

For a package like libpng that depends on zlib, the paths to zlib were converted into deeply nested and fragile relative paths, which is not ideal.

For example, the Libs field was changed as follows:

- Libs:  -LC:/package/z/zlib/v1.3.1/95786712bac941e795afa187a68143a4/lib -L${libdir} -lpng -lzlib
+ Libs:  -L${libdir}/../../../../../z/zlib/v1.3.1/95786712bac941e795afa187a68143a4/lib -L${libdir} -lpng -lzlib

This path (${libdir}/../../...) is confusing and defeats the purpose of improving relocatability.

The Solution

This PR fixes the issue by applying a more precise rule for path conversion:

Paths within the package's own installation directory (installdir) are converted to be relative to ${prefix} or ${exec_prefix}.
Paths outside of the package's installdir (i.e., pointing to external dependencies) are kept as absolute paths.

@waruqi waruqi added this to the v3.0.1 milestone Jun 30, 2025
@waruqi waruqi merged commit 5cf24e4 into xmake-io:dev Jun 30, 2025
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants