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

options patterns warning #16233

Merged
merged 8 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions conan/api/subapi/profiles.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

from conan.api.output import ConanOutput
from conan.internal.cache.home_paths import HomePaths

from conans.client.loader import load_python_file
Expand Down Expand Up @@ -97,6 +98,11 @@ def _get_profile(self, profiles, settings, options, conf, cwd, cache_settings,
profile.conf.validate()
# Apply the new_config to the profiles the global one, so recipes get it too
profile.conf.rebase_conf_definition(global_conf)
for k, v in sorted(profile.options._package_options.items()):
ConanOutput().warning("Unscoped option definition is ambiguous.\n"
f"Use '&:{k}={v}' to refer to the current package.\n"
f"Use '*:{k}={v}' or other pattern if the intent was to apply to "
f"dependencies", warn_tag="legacy")
return profile

def get_path(self, profile, cwd=None, exists=True):
Expand Down
6 changes: 3 additions & 3 deletions conans/test/integration/command/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_shorthand_syntax():
tc.run(
"profile show -o:a=both_options=True -pr:a=profile -s:a=os=WindowsCE -s:a=os.platform=conan -c:a=user.conf:cli=True -f=json")

out = json.loads(tc.out)
out = json.loads(tc.stdout)
assert out == {'build': {'build_env': '',
'conf': {'user.conf:cli': True, 'user:profile': True},
'options': {'both_options': 'True'},
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_shorthand_syntax():
'tool_requires': {}}}

tc.run("profile show -pr:a=pre -pr:h=post -f=json")
out = json.loads(tc.out)
out = json.loads(tc.stdout)
assert out == {'build': {'build_env': '',
'conf': {},
'options': {},
Expand All @@ -112,7 +112,7 @@ def test_shorthand_syntax():
'tool_requires': {}}}

tc.run("profile show -pr:a=pre -o:b foo=False -o:a foo=True -o:h foo=False -f=json")
out = json.loads(tc.out)
out = json.loads(tc.stdout)
assert out == {'build': {'build_env': '',
'conf': {},
'options': {'foo': 'True'},
Expand Down
1 change: 1 addition & 0 deletions conans/test/integration/options/options_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def configure(self):
client.run("create . --name=pkg --version=0.1 --user=user --channel=testing -o *:shared=1")
self.assertIn("pkg/0.1@user/testing: BUILD SHARED: 1", client.out)
client.run("create . --name=pkg --version=0.1 --user=user --channel=testing -o shared=2")
assert 'legacy: Unscoped option definition is ambiguous' in client.out
self.assertIn("pkg/0.1@user/testing: BUILD SHARED: 2", client.out)
# With test_package
client.save({"conanfile.py": conanfile,
Expand Down