conan
conan copied to clipboard
[question] test variable substitution in profiles
Look into revisiting the expected behaviours with regards to variable substitution in profiles
Maybe drop our custom made variable substitution in favor of jinja templates ones?
Maybe drop our custom made variable substitution in favor of jinja templates ones?
no way
no way
Why not?
Why not?
it's useful, clean and easy to understand syntax, compare to obscure and hard to read jinja2 templates
But now we have 2 mechanisms to do the same thing, which is undesired, it would make sense to keep only 1 of them, probably the most flexible, generic and "standard" one. In that sense, jinja, even if the syntax is less terse, is more standard than our variable substitution.
It is also not that clean, the way they can propagate and overwrite over multiple composed profiles or included() profiles is less than evident and can lead to confusion. I was thinking of simplifying this bit also.
Lets try a POC how a profile looks like with Jinja variable substitution
Simple example doing a bit of inheriting and variables declaring (already working):
profile_vars at ~/.conan2/profiles/profile_vars
:
{% set bar = "Bar-baridad" %}
foo at ~/.conan2/profiles/foo
:
{% import "profile_vars" as vars %}
{% set foo = "default" %}
include({{ foo }})
[conf]
user.foo.bar = "{{ vars.bar }}"
Running an install with the profile (conan-including the default profile):
conan install . --profile foo
-------- Input profiles --------
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu98
compiler.libcxx=libc++
compiler.version=13
os=Macos
[conf]
user.foo.bar="Bar-baridad"
So I would say, the current include
mechanism by Conan is ok, but if you need to reuse variables from other profile (including the default) you should use the jinja2 import
and we should drop all that part.
WDYT?
Yes, I think I would drop support for our own variable replacement and use jinja syntax only for this. Leave the include()
Yes, I think I would drop support for our own variable replacement and use jinja syntax only for this. Leave the
include()
can we consider keeping the old support? there are a lot of existing profiles that use it, it would be a significant effort to re-write them, plus all the tutorials, examples, etc.
We want only one way to do things and jinja does it perfectly. It doesn't make any sense to keep the support for a custom one. That is one big purpose of Conan 2, simplify and grow solid and better.
Closed by https://github.com/conan-io/conan/pull/12152