(#13490) docs: v2 migration guidence for conf_info

* docs: v2 migration guidence for `conf_info`

* Update docs/v2_migration.md

Co-authored-by: Jordan Williams <jordan@jwillikers.com>

* example + notes about why to avoid it

Co-authored-by: Jordan Williams <jordan@jwillikers.com>
This commit is contained in:
Chris Mc
2022-10-19 10:05:35 -07:00
committed by GitHub
parent c7c4025ff4
commit 842c55bbf1

View File

@@ -54,6 +54,39 @@ When different build tools are use, at least one layout needs to be set.
The `src_folder` must be the same when using different layouts and should
not depend on settings or options.
## New conf_info properties
As described in the documentation `self.user_info` has been depreated and you are now required to use
`self.conf_info` to define individual properties to expose to downstream recipes.
The [2.0 migrations docs](https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html#removed-self-user-info)
should cover the technical details, however for ConanCenterIndex we need to make sure there are no collisions
`conf_info` must be named `user.<recipe_name>:<variable>`.
For usage options of `conf_info`, the [documenation](https://docs.conan.io/en/latest/reference/config_files/global_conf.html?highlight=conf_info#configuration-in-your-recipes)
In ConanCenterIndex this will typically looks like:
- defining a value
```py
def package_info(self):
tool_path = os.path.join(self.package_folder, "bin", "tool")
self.conf_info.define("user.pkg:tool", tool_path)
```
- using a value
```py
#generators = "VirtualBuildEnv", "VirtualRunEnv"
def build_requirements(self):
self.tool_requires("tool/0.1")
def build(self):
tool_path = self.conf_info.get("user.pkg:tool")
self.run(f"{tool_path} --build")
```
> **Note**: This should only be used when absolutely required. In the vast majority of cases, the new
> ["Environments"](https://docs.conan.io/en/latest/reference/conanfile/tools/env/environment.html?highlight=Virtual)
> will include the `self.cpp_info.bindirs` which will provide access to the tools in the correct scopes.
## New cpp_info set_property model
New Conan generators like