Open SSE4 opened 1 year ago
So far, what we have:
validate_build()
with self.settings
always: https://docs.conan.io/en/latest/reference/conanfile/methods.html#validate-buildvalidate()
with self.info.settings
always: https://docs.conan.io/en/2.0/reference/conanfile/methods.html#validate-buildvalidate()
with self.settings
only when compiler is removed from your package ID (with self.info.clear()
)validate()
with self.settings.info
with regular libraries which keep compiler as part of the package ID: https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html?#the-validate-methodSo there is a trick, which is not well documented yet, but at least, we tried to sane on ConanCenterIndex by its templates.
Still, the documentation need to be improved.
@uilianries maybe we can fill a table like that?
| | validate | validate | validate_build | validate_build |
|-----|---------------|--------------------|----------------|--------------------|
| | self.settings | self.info.settings | self.settings | self.info.settings |
| 1.x | | | | |
| 2.x | | | | |
@SSE4 basically:
| | validate | validate | validate_build | validate_build |
|-----|---------------|--------------------|----------------|--------------------|
| | self.settings | self.info.settings | self.settings | self.info.settings |
| 1.x | header-only | regular libraries | ALWAYS | NEVER |
| 2.x | NEVER | ALWAYS | ALWAYS | NEVER |
I doubt it's that simple... regular package may erase settings as well (many erase libcxx, at least, several erase other settings like build_type or arch).
there are libraries with header_only
option (boost, fmt, etc.), and settings are cleared only for some package IDs.
that makes it non-trivial to write a correct validate
method.
IMO documentation should show how to write validate
so it works for both v1 and v2 (same code, no conan_version condition). and it shouldn't make a difference for header-only vs "regular-libraries", as there are many corner cases (regular libraries erasing settings, regular libraries with header-only option, etc.).
That's the goal.
I think once the 1.54 and beta 5 drop we will have an answer to this that's consistent.
there is a proposal to be considered:
package_id
and validate
execution in 1.xself.settings
access in validate
in 2.x
right now, documentation is inconsistent, e.g.: https://docs.conan.io/en/latest/reference/conanfile/methods.html#validate https://docs.conan.io/en/latest/reference/conanfile/methods.html#validate-build use just
self.settings
, while: https://docs.conan.io/en/latest/creating_packages/define_abi_compatibility.html usesself.info.settings
. for newcomers, it's not clear, which one should be used and in that circumstances. I think documentation should be aligned with the same recommendation on all pages. if for some reason, bothself.info.settings
and plainself.settings
could be used, it should have some disclaimer, describing the difference between them. see also https://github.com/conan-io/conan-center-index/pull/13754