You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the PkgConfigDeps generator allows placing only specific dependencies in the build context by opting to explicitly indicate them as such and even requires renaming them when used in both the build and host contexts.
This functionality is primarily used by Meson projects which use pkg-config files to find build tools, such as how xkbcommon and wayland find the wayland-scanner program provided by the wayland package.
The current approach is problematic for multiple reasons.
It requires explicitly defining which tool_requires packages should be available in the build context for PkgConfigDeps, which requires more work effort in the conanfile.py.
Renaming pkg-config files always requires a corresponding patch to the consumer's build system to find the renamed pkg-config file.
It's potentially necessary to manually work out the dependencies of all packages placed in the build context and to add each of the dependencies to build_context_activated to ensure that all dependencies are found properly by pkg-config. Currently, everything falls apart here when renaming an individual package with a build context suffix, as the dependencies listed as Requires of the renamed pkg-config files are not themselves renamed, resulting in pkg-config files in the build context requiring pkg-config files in the host context.
Here's an example of wayland-scanner_BUILD.pc demonstrating this predicament.
Note that it requires expat while expat.pc is in the host context and not the build context.
No expat_BUILD.pc is generated automatically, either.
In Meson, it's necessary to explicitly define tc.project_options["build.pkg_config_path"] = self.generators_folder to add the generators directory to the pkg-config search path for native packages.
An alternative approach is to separate the pkg-config files for the host and build contexts by directory rather than by renaming pkg-config files.
This solves the three problems with the current approach.
The pkg-config files can be safely generated for all build and host requirements automatically.
The generated pkg-config files can safely use the same names, as they are placed in separate directories. No patching is necessary.
The pkg-config files for all dependencies can be produced automatically.
The Meson generator can automatically define the build.pkg_config_path to point to the directory containing the pkg-config files in the build context.
There are a couple of drawbacks to this approach.
It can result in the generation of extraneous pkg-config files which are not required when building a package, especially when building non-Meson projects which don't appear - in my limited experience - to find dependencies in the build context in this manner.
Changes to PkgConfigDeps must not break existing packages, requiring careful consideration of how this is implemented.
The MesonToolchain generator needs to be aware when pkg-config directories are being used for both the build and host contexts so that it can define pkg_config_path and build.pkg_config_path appropriately.
To address the concerns, perhaps the implementation could follow a similar approach to VirtualBuildEnv and VirtualRunEnv where separate generators are used per context or the existing PkgConfigDeps could be modified to provide a different constructor or to provide an option to generate pkg-config files for build dependencies in a separate directory from host dependencies.
The implementation could still require consumers to declare specific dependencies to provide in the build context, if desired, to reduce the number of pkg-config files generated, but dependencies of any such package should automatically have pkg-config files generated in the build context as well to ensure that transitive dependencies can be found if needed.
Have you read the CONTRIBUTING guide?
I've read the CONTRIBUTING guide
The text was updated successfully, but these errors were encountered:
Thanks for reporting it and the great explanation!
Also, I saw the related issue was opened a long time ago 😢 Sorry about the delay in looking into this issue.
I was thinking of this one yesterday, and it seems like a bug instead of a feature, doesn't it?
Indeed, PkgConfigDeps is not isolating the whole build context, and the build context suffixes management is not helping so much. I need to perform a test to see it better, but yes, IMO, looks like a bug.
I'll update this issue when I have a PR or any other further investigations.
jwillikers
changed the title
[feature] PkgConfigDeps: Separate pkg-config files between the host and build contexts by directory
[bug] PkgConfigDeps: Separate pkg-config files between the host and build contexts by directory
Oct 18, 2023
What is your suggestion?
Currently, the PkgConfigDeps generator allows placing only specific dependencies in the build context by opting to explicitly indicate them as such and even requires renaming them when used in both the build and host contexts.
This functionality is primarily used by Meson projects which use pkg-config files to find build tools, such as how
xkbcommon
andwayland
find thewayland-scanner
program provided by thewayland
package.The current approach is problematic for multiple reasons.
tool_requires
packages should be available in the build context for PkgConfigDeps, which requires more work effort in theconanfile.py
.build_context_activated
to ensure that all dependencies are found properly by pkg-config. Currently, everything falls apart here when renaming an individual package with a build context suffix, as the dependencies listed asRequires
of the renamed pkg-config files are not themselves renamed, resulting in pkg-config files in the build context requiring pkg-config files in the host context.Here's an example of
wayland-scanner_BUILD.pc
demonstrating this predicament.expat
whileexpat.pc
is in the host context and not the build context.No
expat_BUILD.pc
is generated automatically, either.tc.project_options["build.pkg_config_path"] = self.generators_folder
to add the generators directory to the pkg-config search path for native packages.An alternative approach is to separate the pkg-config files for the host and build contexts by directory rather than by renaming pkg-config files.
This solves the three problems with the current approach.
build.pkg_config_path
to point to the directory containing the pkg-config files in the build context.There are a couple of drawbacks to this approach.
pkg_config_path
andbuild.pkg_config_path
appropriately.To address the concerns, perhaps the implementation could follow a similar approach to
VirtualBuildEnv
andVirtualRunEnv
where separate generators are used per context or the existingPkgConfigDeps
could be modified to provide a different constructor or to provide an option to generate pkg-config files for build dependencies in a separate directory from host dependencies.The implementation could still require consumers to declare specific dependencies to provide in the build context, if desired, to reduce the number of pkg-config files generated, but dependencies of any such package should automatically have pkg-config files generated in the build context as well to ensure that transitive dependencies can be found if needed.
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: