diff --git a/conan/tools/apple/xcodebuild.py b/conan/tools/apple/xcodebuild.py index 277473fd2b8..f0a66deba84 100644 --- a/conan/tools/apple/xcodebuild.py +++ b/conan/tools/apple/xcodebuild.py @@ -12,11 +12,26 @@ def __init__(self, conanfile): @property def _verbosity(self): - verbosity = self._conanfile.conf.get("tools.apple.xcodebuild:verbosity", default="", check_type=str) - if verbosity == "quiet" or verbosity == "verbose": - return "-{}".format(verbosity) - elif verbosity: - raise ConanException("Value {} for 'tools.apple.xcodebuild:verbosity' is not valid".format(verbosity)) + verbosity = self._conanfile.conf.get("tools.build:verbosity") + if verbosity: + if verbosity not in ("quiet", "error", "warning", "notice", "status", "verbose", + "normal", "debug", "v", "trace", "vv"): + raise ConanException(f"Value '{verbosity}' for 'tools.build:verbosity' is not valid") + else: + # quiet, nothing, verbose + verbosity = {"quiet": "quiet", + "error": "quiet", + "warning": "quiet", + "notice": "quiet", + "status": None, + "verbose": None, + "normal": None, + "debug": "verbose", + "v": "verbose", + "trace": "verbose", + "vv": "verbose"}.get(verbosity) + if verbosity is not None: + return "-{}".format(verbosity) return "" @property diff --git a/conan/tools/microsoft/msbuild.py b/conan/tools/microsoft/msbuild.py index 6d74709ab2b..bdca57f9e59 100644 --- a/conan/tools/microsoft/msbuild.py +++ b/conan/tools/microsoft/msbuild.py @@ -2,11 +2,27 @@ def msbuild_verbosity_cmd_line_arg(conanfile): - verbosity = conanfile.conf.get("tools.microsoft.msbuild:verbosity") + verbosity = conanfile.conf.get("tools.build:verbosity") if verbosity: - if verbosity not in ("Quiet", "Minimal", "Normal", "Detailed", "Diagnostic"): - raise ConanException("Unknown msbuild verbosity: {}".format(verbosity)) - return '/verbosity:{}'.format(verbosity) + if verbosity not in ("quiet", "error", "warning", "notice", "status", "verbose", + "normal", "debug", "v", "trace", "vv"): + raise ConanException(f"Unknown value '{verbosity}' for 'tools.build:verbosity'") + else: + # "Quiet", "Minimal", "Normal", "Detailed", "Diagnostic" + verbosity = { + "quiet": "Quiet", + "error": "Minimal", + "warning": "Minimal", + "notice": "Minimal", + "status": "Normal", + "verbose": "Normal", + "normal": "Normal", + "debug": "Detailed", + "v": "Detailed", + "trace": "Diagnostic", + "vv": "Diagnostic" + }.get(verbosity) + return '/verbosity:{}'.format(verbosity) def msbuild_arch(arch): diff --git a/conans/model/conf.py b/conans/model/conf.py index 36dac709537..31d61861458 100644 --- a/conans/model/conf.py +++ b/conans/model/conf.py @@ -46,6 +46,8 @@ "tools.build:sysroot": "Pass the --sysroot= flag if available. (None by default)", "tools.build.cross_building:can_run": "Bool value that indicates whether is possible to run a non-native " "app on the same architecture. It's used by 'can_run' tool", + "tools.build:verbosity": "Verbosity of MSBuild and XCodeBuild build systems. " + "Possible values are 'quiet', 'error', 'warning', 'notice', 'status', 'verbose', 'normal', 'debug', 'v', 'trace' and 'vv'", "tools.cmake.cmaketoolchain:generator": "User defined CMake generator to use instead of default", "tools.cmake.cmaketoolchain:find_package_prefer_config": "Argument for the CMAKE_FIND_PACKAGE_PREFER_CONFIG", "tools.cmake.cmaketoolchain:toolchain_file": "Use other existing file rather than conan_toolchain.cmake one", @@ -66,7 +68,6 @@ "tools.google.bazel:bazelrc_path": "Defines Bazel rc-path", "tools.meson.mesontoolchain:backend": "Any Meson backend: ninja, vs, vs2010, vs2012, vs2013, vs2015, vs2017, vs2019, xcode", "tools.meson.mesontoolchain:extra_machine_files": "List of paths for any additional native/cross file references to be appended to the existing Conan ones", - "tools.microsoft.msbuild:verbosity": "Verbosity level for MSBuild: 'Quiet', 'Minimal', 'Normal', 'Detailed', 'Diagnostic'", "tools.microsoft.msbuild:vs_version": "Defines the IDE version when using the new msvc compiler", "tools.microsoft.msbuild:max_cpu_count": "Argument for the /m when running msvc to build parallel projects", "tools.microsoft.msbuild:installation_path": "VS install path, to avoid auto-detect via vswhere, like C:/Program Files (x86)/Microsoft Visual Studio/2019/Community. Use empty string to disable", @@ -81,7 +82,6 @@ "tools.system.package_manager:mode": "Mode for package_manager tools: 'check' or 'install'", "tools.system.package_manager:sudo": "Use 'sudo' when invoking the package manager tools in Linux (False by default)", "tools.system.package_manager:sudo_askpass": "Use the '-A' argument if using sudo in Linux to invoke the system package manager (False by default)", - "tools.apple.xcodebuild:verbosity": "Verbosity level for xcodebuild: 'verbose' or 'quiet", "tools.apple:sdk_path": "Path to the SDK to be used", "tools.apple:enable_bitcode": "(boolean) Enable/Disable Bitcode Apple Clang flags", "tools.apple:enable_arc": "(boolean) Enable/Disable ARC Apple Clang flags", @@ -564,7 +564,7 @@ def rebase_conf_definition(self, other): def update(self, key, value, profile=False, method="define"): """ Define/append/prepend/unset any Conf line - >> update("tools.microsoft.msbuild:verbosity", "Detailed") + >> update("tools.build:verbosity", "verbose") """ pattern, name = self._split_pattern_name(key) diff --git a/conans/test/integration/configuration/conf/test_conf.py b/conans/test/integration/configuration/conf/test_conf.py index 794b47e87fc..4471ce0c1d1 100644 --- a/conans/test/integration/configuration/conf/test_conf.py +++ b/conans/test/integration/configuration/conf/test_conf.py @@ -29,32 +29,32 @@ def generate(self): def test_basic_composition(client): profile1 = textwrap.dedent("""\ [conf] - tools.microsoft.msbuild:verbosity=Quiet + tools.build:verbosity=quiet tools.microsoft.msbuild:vs_version=Slow tools.cmake.cmaketoolchain:generator=Extra """) profile2 = textwrap.dedent("""\ [conf] - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice tools.microsoft.msbuild:max_cpu_count=High tools.meson.mesontoolchain:backend=Super """) client.save({"profile1": profile1, "profile2": profile2}) client.run("install . -pr=profile1") - assert "tools.microsoft.msbuild:verbosity$Quiet" in client.out + assert "tools.build:verbosity$quiet" in client.out assert "tools.microsoft.msbuild:vs_version$Slow" in client.out assert "tools.cmake.cmaketoolchain:generator$Extra" in client.out client.run("install . -pr=profile1 -pr=profile2") - assert "tools.microsoft.msbuild:verbosity$Minimal" in client.out + assert "tools.build:verbosity$notice" in client.out assert "tools.microsoft.msbuild:vs_version$Slow" in client.out assert "tools.microsoft.msbuild:max_cpu_count$High" in client.out assert "tools.cmake.cmaketoolchain:generator$Extra" in client.out assert "tools.meson.mesontoolchain:backend$Super" in client.out client.run("install . -pr=profile2 -pr=profile1") - assert "tools.microsoft.msbuild:verbosity$Quiet" in client.out + assert "tools.build:verbosity$quiet" in client.out assert "tools.microsoft.msbuild:vs_version$Slow" in client.out assert "tools.microsoft.msbuild:max_cpu_count$High" in client.out assert "tools.cmake.cmaketoolchain:generator$Extra" in client.out @@ -64,14 +64,14 @@ def test_basic_composition(client): def test_basic_inclusion(client): profile1 = textwrap.dedent("""\ [conf] - tools.microsoft.msbuild:verbosity=Quiet + tools.build:verbosity=quiet tools.microsoft.msbuild:vs_version=Slow tools.cmake.cmaketoolchain:generator=Extra """) profile2 = textwrap.dedent("""\ include(profile1) [conf] - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice tools.microsoft.msbuild:max_cpu_count=High tools.meson.mesontoolchain:backend=Super """) @@ -79,7 +79,7 @@ def test_basic_inclusion(client): "profile2": profile2}) client.run("install . -pr=profile2") - assert "tools.microsoft.msbuild:verbosity$Minimal" in client.out + assert "tools.build:verbosity$notice" in client.out assert "tools.microsoft.msbuild:vs_version$Slow" in client.out assert "tools.microsoft.msbuild:max_cpu_count$High" in client.out assert "tools.cmake.cmaketoolchain:generator$Extra" in client.out @@ -88,20 +88,20 @@ def test_basic_inclusion(client): def test_composition_conan_conf(client): conf = textwrap.dedent("""\ - tools.microsoft.msbuild:verbosity=Quiet + tools.build:verbosity=quiet tools.microsoft.msbuild:vs_version=Slow tools.cmake.cmaketoolchain:generator=Extra """) save(client.cache.new_config_path, conf) profile = textwrap.dedent("""\ [conf] - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice tools.microsoft.msbuild:max_cpu_count=High tools.meson.mesontoolchain:backend=Super """) client.save({"profile": profile}) client.run("install . -pr=profile") - assert "tools.microsoft.msbuild:verbosity$Minimal" in client.out + assert "tools.build:verbosity$notice" in client.out assert "tools.microsoft.msbuild:vs_version$Slow" in client.out assert "tools.microsoft.msbuild:max_cpu_count$High" in client.out assert "tools.cmake.cmaketoolchain:generator$Extra" in client.out @@ -110,14 +110,14 @@ def test_composition_conan_conf(client): def test_new_config_file(client): conf = textwrap.dedent("""\ - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice user.mycompany.myhelper:myconfig=myvalue *:tools.cmake.cmaketoolchain:generator=X cache:read_only=True """) save(client.cache.new_config_path, conf) client.run("install .") - assert "tools.microsoft.msbuild:verbosity$Minimal" in client.out + assert "tools.build:verbosity$notice" in client.out assert "user.mycompany.myhelper:myconfig$myvalue" in client.out assert "tools.cmake.cmaketoolchain:generator$X" in client.out assert "read_only" not in client.out @@ -138,19 +138,19 @@ def test_new_config_file_required_version(): def test_composition_conan_conf_overwritten_by_cli_arg(client): conf = textwrap.dedent("""\ - tools.microsoft.msbuild:verbosity=Quiet + tools.build:verbosity=quiet tools.microsoft.msbuild:max_cpu_count=Slow """) save(client.cache.new_config_path, conf) profile = textwrap.dedent("""\ [conf] - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice tools.microsoft.msbuild:vs_version=High """) client.save({"profile": profile}) - client.run("install . -pr=profile -c tools.microsoft.msbuild:verbosity=Detailed " + client.run("install . -pr=profile -c tools.build:verbosity=debug " "-c tools.meson.mesontoolchain:backend=Super") - assert "tools.microsoft.msbuild:verbosity$Detailed" in client.out + assert "tools.build:verbosity$debug" in client.out assert "tools.microsoft.msbuild:max_cpu_count$Slow" in client.out assert "tools.microsoft.msbuild:vs_version$High" in client.out assert "tools.meson.mesontoolchain:backend$Super" in client.out diff --git a/conans/test/integration/configuration/conf/test_conf_profile.py b/conans/test/integration/configuration/conf/test_conf_profile.py index e0268b9b470..2e5e70adf81 100644 --- a/conans/test/integration/configuration/conf/test_conf_profile.py +++ b/conans/test/integration/configuration/conf/test_conf_profile.py @@ -54,7 +54,7 @@ def test_cmake_config(client): compiler.runtime=dynamic build_type=Release [conf] - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice """) client.save({"myprofile": profile}) client.run("create . --name=pkg --version=0.1 -pr=myprofile") @@ -71,11 +71,11 @@ def test_cmake_config_error(client): compiler.runtime=dynamic build_type=Release [conf] - tools.microsoft.msbuild:verbosity=non-existing + tools.build:verbosity=non-existing """) client.save({"myprofile": profile}) client.run("create . --name=pkg --version=0.1 -pr=myprofile", assert_error=True) - assert "Unknown msbuild verbosity: non-existing" in client.out + assert "Unknown value 'non-existing' for 'tools.build:verbosity'" in client.out def test_cmake_config_package(client): @@ -88,7 +88,7 @@ def test_cmake_config_package(client): compiler.runtime=dynamic build_type=Release [conf] - dep*:tools.microsoft.msbuild:verbosity=Minimal + dep*:tools.build:verbosity=notice """) client.save({"myprofile": profile}) client.run("create . --name=pkg --version=0.1 -pr=myprofile") @@ -107,7 +107,7 @@ def test_cmake_config_package_not_scoped(client): compiler.runtime=dynamic build_type=Release [conf] - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice """) client.save({"myprofile": profile}) client.run("create . --name=pkg --version=0.1 -pr=myprofile") @@ -149,7 +149,7 @@ def build(self): compiler.runtime=dynamic build_type=Release [conf] - tools.microsoft.msbuild:verbosity=Minimal + tools.build:verbosity=notice """) client.save({"myprofile": profile}) client.run("create . --name=pkg --version=0.1 -pr=myprofile") diff --git a/conans/test/unittests/client/tools/apple/test_xcodebuild.py b/conans/test/unittests/client/tools/apple/test_xcodebuild.py index f5cdbbdabb8..48c575abe2f 100644 --- a/conans/test/unittests/client/tools/apple/test_xcodebuild.py +++ b/conans/test/unittests/client/tools/apple/test_xcodebuild.py @@ -6,22 +6,21 @@ from conans.test.utils.mocks import ConanFileMock, MockSettings -@pytest.mark.parametrize("mode", ["quiet", "verbose", "invalid"]) -def test_verbosity(mode): +@pytest.mark.parametrize("mode", ["quiet", "error", "warning", "notice", "status", "verbose", + "normal", "debug", "v", "trace", "vv"]) +def test_verbosity_global(mode): conanfile = ConanFileMock() conf = ConfDefinition() - conf.loads("tools.apple.xcodebuild:verbosity={}".format(mode)) + conf.loads(f"tools.build:verbosity={mode}") conanfile.conf = conf conanfile.settings = MockSettings({}) xcodebuild = XcodeBuild(conanfile) - if mode != "invalid": - xcodebuild.build("app.xcodeproj") - assert "-{}".format(mode) in conanfile.command + + xcodebuild.build("app.xcodeproj") + if mode not in ("status", "verbose", "normal"): + assert "-quiet" in conanfile.command or "-verbose" in conanfile.command else: - with pytest.raises(ConanException) as excinfo: - xcodebuild.build("app.xcodeproj") - assert "Value {} for 'tools.apple.xcodebuild:verbosity' is not valid".format(mode) == str( - excinfo.value) + assert "-quiet" not in conanfile.command and "-verbose" not in conanfile.command def test_sdk_path(): diff --git a/conans/test/unittests/model/test_conf.py b/conans/test/unittests/model/test_conf.py index 794e4fab9f5..602d4fad164 100644 --- a/conans/test/unittests/model/test_conf.py +++ b/conans/test/unittests/model/test_conf.py @@ -10,7 +10,7 @@ @pytest.fixture() def conf_definition(): text = textwrap.dedent("""\ - tools.microsoft.msbuild:verbosity=minimal + tools.build:verbosity=notice user.company.toolchain:flags=someflags """) c = ConfDefinition() @@ -23,7 +23,7 @@ def test_conf_definition(conf_definition): # Round trip assert c.dumps() == text # access - assert c.get("tools.microsoft.msbuild:verbosity") == "minimal" + assert c.get("tools.build:verbosity") == "notice" assert c.get("user.company.toolchain:flags") == "someflags" assert c.get("user.microsoft.msbuild:nonexist") is None assert c.get("user:nonexist") is None @@ -54,7 +54,7 @@ def test_conf_update(conf_definition): c2.loads(text) c.update_conf_definition(c2) result = textwrap.dedent("""\ - tools.microsoft.msbuild:verbosity=minimal + tools.build:verbosity=notice user.company.toolchain:flags=newvalue user.something:key=value """) @@ -65,13 +65,13 @@ def test_conf_rebase(conf_definition): c, _ = conf_definition text = textwrap.dedent("""\ user.company.toolchain:flags=newvalue - tools.microsoft.msbuild:verbosity=Diagnostic""") + tools.build:verbosity=trace""") c2 = ConfDefinition() c2.loads(text) c.rebase_conf_definition(c2) # The c profile will have precedence, and " result = textwrap.dedent("""\ - tools.microsoft.msbuild:verbosity=minimal + tools.build:verbosity=notice user.company.toolchain:flags=someflags """) assert c.dumps() == result diff --git a/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py b/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py index 916543950c3..c4f5175180e 100644 --- a/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py +++ b/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py @@ -1,14 +1,13 @@ import pytest from mock import mock -from mock.mock import Mock from conan.tools.cmake import CMake from conan.tools.cmake.presets import write_cmake_presets -from conan.tools.build import save_toolchain_args from conans.model.conan_file import ConanFile from conans.model.conf import Conf from conans.model.settings import Settings from conans.test.utils.test_files import temp_folder +from conans.util.files import load @pytest.fixture(scope="module")