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

fix skip binaries #17033

Merged
merged 1 commit into from
Sep 23, 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
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