Skip to content
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
4 changes: 4 additions & 0 deletions conan/internal/api/profile/profile_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ def get_package_name_value(item):
result_name, result_value = item.split("=", 1)
result_name = result_name.strip()
result_value = _unquote(result_value)
if result_value == "~": # Can be used to undefine an already defined setting
result_value = None
return packagename, result_name, result_value

package_settings = OrderedDict()
Expand Down Expand Up @@ -388,6 +390,8 @@ def _get_simple_and_package_tuples(items):
package_items = defaultdict(list)
tuples = _get_tuples_list_from_extender_arg(items)
for name, value in tuples:
if value == "~": # Can be used to undefine an already defined setting
value = None
if ":" in name: # Scoped items
tmp = name.split(":", 1)
ref_name = tmp[0]
Expand Down
31 changes: 30 additions & 1 deletion test/integration/configuration/profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from textwrap import dedent

import pytest
from parameterized import parameterized

from conan.internal.paths import CONANFILE
from conan.test.assets.genconanfile import GenConanfile
Expand Down Expand Up @@ -645,3 +644,33 @@ def test_compose_numeric_values_scoped_pkg():

tc.run("create . -pr=profile")
assert "user.var.value: 10" in tc.out


def test_nullify_settings():
c = TestClient()
conanfile = textwrap.dedent("""
from conan import ConanFile
class Pkg(ConanFile):
settings = "build_type"
def configure(self):
if not self.settings.build_type:
self.output.info("BUILD TYPE NOT DEFINED!!!")
else:
self.output.info(f"I am a {self.settings.build_type} pkg!!!")
""")
c.save({"conanfile.py": conanfile,
"profile": "[settings]\nbuild_type=Release\npkg1/*:build_type=~"})
c.run("create . --name=pkg1 --version=0.1")
c.run("create . --name=pkg2 --version=0.1")
c.run("create . --name=pkg3 --version=0.1")
c.save({"conanfile.py": GenConanfile().with_requires("pkg1/0.1", "pkg2/0.1", "pkg3/0.1")})

c.run("graph info . -s build_type=Release -s pkg1/*:build_type=~")
assert "pkg1/0.1: BUILD TYPE NOT DEFINED!!!" in c.out
assert "pkg2/0.1: I am a Release pkg!!!" in c.out
assert "pkg3/0.1: I am a Release pkg!!!" in c.out

c.run("graph info . -pr=profile")
assert "pkg1/0.1: BUILD TYPE NOT DEFINED!!!" in c.out
assert "pkg2/0.1: I am a Release pkg!!!" in c.out
assert "pkg3/0.1: I am a Release pkg!!!" in c.out
Loading