Skip to content

Commit

Permalink
fix skip binaries (#17033)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Sep 23, 2024
1 parent 95fa028 commit b10a5f6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion conans/client/graph/graph_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
41 changes: 41 additions & 0 deletions test/integration/graph/test_skip_binaries.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit b10a5f6

Please sign in to comment.