diff --git a/conans/client/graph/graph_binaries.py b/conans/client/graph/graph_binaries.py index 67d148cc2df..e5c11174535 100644 --- a/conans/client/graph/graph_binaries.py +++ b/conans/client/graph/graph_binaries.py @@ -447,7 +447,10 @@ def _skip_binaries(graph): required_nodes.add(graph.root) for node in graph.nodes: if node.binary in (BINARY_BUILD, BINARY_EDITABLE_BUILD, BINARY_EDITABLE): - if not node.build_allowed: # Only those that are forced to build, not only "missing" + can_skip = node.conanfile.conf.get("tools.graph:skip_binaries", + check_type=bool, default=True) + # Only those that are forced to build, not only "missing" + if not node.build_allowed or not can_skip: required_nodes.add(node) root_nodes = required_nodes.copy() diff --git a/test/integration/graph/test_skip_binaries.py b/test/integration/graph/test_skip_binaries.py index 6155d68a901..09e27777f46 100644 --- a/test/integration/graph/test_skip_binaries.py +++ b/test/integration/graph/test_skip_binaries.py @@ -1,4 +1,5 @@ import re +import textwrap from conan.test.assets.genconanfile import GenConanfile from conan.test.utils.tools import TestClient, NO_SETTINGS_PACKAGE_ID @@ -194,3 +195,43 @@ def test_skip_visible_build(): c.run("create libc") c.run("install app --format=json") assert re.search(r"Skipped binaries(\s*)libb/0.1, liba/0.1", c.out) + + +def test_skip_tool_requires_context(): + c = TestClient() + cmake = textwrap.dedent(""" + from conan import ConanFile + class CMake(ConanFile): + name = "cmake" + version = "1.0" + def package_info(self): + self.buildenv_info.define("MYVAR", "MYVALUE") + """) + gtest = textwrap.dedent(""" + from conan import ConanFile + from conan.tools.files import load + class gtest(ConanFile): + name = "gtest" + version = "1.0" + settings = "os" + package_type = "static-library" + def build(self): + env = load(self, "conanbuildenv.sh") + self.output.info(f"MYENV: {env}") + """) + c.save({"cmake/conanfile.py": cmake, + "gtest/conanfile.py": gtest, + "lib/conanfile.py": GenConanfile("lib", "1.0").with_package_type("static-library") + .with_test_requires("gtest/1.0"), + "app/conanfile.py": GenConanfile("app", "1.0").with_settings("os") + .with_requires("lib/1.0"), + "profile": "[tool_requires]\ncmake/[>=1.0]"}) + + c.run("create cmake") + c.run("create gtest -s:a os=Linux") + c.run("create lib -s:a os=Linux") + + c.run("remove gtest:* -c") + c.run("install app -s:a os=Linux -pr=profile -c=tools.graph:skip_binaries=False --build=missing") + assert 'export MYVAR="MYVALUE"' in c.out + assert "gtest/1.0: Package '9a4eb3c8701508aa9458b1a73d0633783ecc2270' built" in c.out