-
Notifications
You must be signed in to change notification settings - Fork 993
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] Better way to compose configurations #17608
Comments
Hi @vasama Thanks for your question. Maybe instead of doing the negation, it would be easier to do the definition, so something like:
could work nicely. That means, that if defining a profile for several packages, it could be convenient to define a jinja template with a Note that if you want to fully undefine the conf, I think it might be possible with the
|
That happens to work for this particular case. Like in the referenced issue, there are other options that make this more difficult:
The template might work, but it looks horribly complicated. I would hope for a more easily maintained solution. Something like being able to override the entire profile for a specific dependency might solve this rather nicely:
|
I know this is not as built-in as that, but the jinja templates allow implementing the same concept, see the following test:
Furthermore the application of a full profile to a per-package pattern is not always that well defined. Profiles have some fields, like def test_profile_macro_per_package():
client = TestClient()
tpl1 = textwrap.dedent("""
{% macro set_windows_settings(lib) %}
{{lib}}/*:os=Windows
{{lib}}/*:arch=x86
{% endmacro %}
{% macro set_windows_conf(lib) %}
{{lib}}/*:user.conf:key = 2
{% endmacro %}
[settings]
os = Linux
{{set_windows_settings("mypkg")}}
[conf]
user.conf:key = 1
{{set_windows_conf("mypkg")}}
""")
conanfile = textwrap.dedent("""
from conan import ConanFile
class Pkg(ConanFile):
name = "mypkg"
version = "0.1"
settings = "os", "arch"
def generate(self):
value = self.conf.get("user.conf:key")
self.output.info(f"os={self.settings.os}!!")
self.output.info(f"arch={self.settings.arch}!!")
self.output.info(f"user.conf:key={value}!!!!")
""")
client.save({"conanfile.py": conanfile,
"profile1": tpl1})
client.run("install . -pr=profile1")
assert "conanfile.py (mypkg/0.1): user.conf:key=2!!!!" in client.out
assert "conanfile.py (mypkg/0.1): os=Windows!!" in client.out
assert "conanfile.py (mypkg/0.1): arch=x86!!" in client.out |
What is your question?
Inspired by this comment: conan-io/conan-center-index#26391 (comment)
Profiles sometimes need to specify configuration options for building packages, e.g:
However sometimes specific packages must be built using a different configuration:
OpenSSL cannot be built using Clang-CL, but MSVC and Clang-CL are binary compatible, so this works out fine.
In order to actually change the compiler being used, the
compiler_executables
option must be made conditional:All of this is pretty unwieldy and seems to break down as soon as more than one dependency should use a different configuration. Is there a better way to compose configurations to achieve this?
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: