Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] test variable substitution in profiles #11730

Closed
jcar87 opened this issue Jul 29, 2022 · 11 comments
Closed

[question] test variable substitution in profiles #11730

jcar87 opened this issue Jul 29, 2022 · 11 comments
Assignees
Milestone

Comments

@jcar87
Copy link
Contributor

jcar87 commented Jul 29, 2022

Look into revisiting the expected behaviours with regards to variable substitution in profiles

@jcar87 jcar87 added this to the 2.0.0-beta3 milestone Jul 29, 2022
@memsharded
Copy link
Member

Maybe drop our custom made variable substitution in favor of jinja templates ones?

@SSE4
Copy link
Contributor

SSE4 commented Jul 29, 2022

Maybe drop our custom made variable substitution in favor of jinja templates ones?

no way

@memsharded
Copy link
Member

no way

Why not?

@SSE4
Copy link
Contributor

SSE4 commented Jul 29, 2022

Why not?

it's useful, clean and easy to understand syntax, compare to obscure and hard to read jinja2 templates

@memsharded
Copy link
Member

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.

@memsharded
Copy link
Member

Lets try a POC how a profile looks like with Jinja variable substitution

@lasote lasote self-assigned this Sep 8, 2022
@lasote
Copy link
Contributor

lasote commented Sep 8, 2022

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?

@memsharded
Copy link
Member

Yes, I think I would drop support for our own variable replacement and use jinja syntax only for this. Leave the include()

@SSE4
Copy link
Contributor

SSE4 commented Sep 9, 2022

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.

@lasote
Copy link
Contributor

lasote commented Sep 9, 2022

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.

@memsharded
Copy link
Member

Closed by #12152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants