Skip to content

Commit

Permalink
Implement conf that avoids binary skipping in the graph (#14466)
Browse files Browse the repository at this point in the history
* Implement conf that avoids binary skipping in the graph

* Move to tools.graph:skip_binaries for finer grained control

* Different versions to clarify test

* Duplicated test

* Add description for conf

* Better conf description
  • Loading branch information
AbrilRBS authored Aug 23, 2023
1 parent 528d296 commit bc74147
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conan/cli/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create(conan_api, parser, *args):
add_common_install_arguments(parser)
parser.add_argument("--build-require", action='store_true', default=False,
help='Whether the package being created is a build-require (to be used'
'as tool_requires() by other packages)')
' as tool_requires() by other packages)')
parser.add_argument("-tf", "--test-folder", action=OnceArgument,
help='Alternative test folder name. By default it is "test_package". '
'Use "" to skip the test stage')
Expand Down
2 changes: 1 addition & 1 deletion conans/client/graph/graph_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,5 @@ def _skip_binaries(graph):
required_nodes.add(dep_node)

for node in graph.nodes:
if node not in required_nodes:
if node not in required_nodes and node.conanfile.conf.get("tools.graph:skip_binaries", check_type=bool, default=True):
node.binary = BINARY_SKIP
1 change: 1 addition & 0 deletions conans/model/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"tools.files.download:retry": "Number of retries in case of failure when downloading",
"tools.files.download:retry_wait": "Seconds to wait between download attempts",
"tools.files.download:verify": "If set, overrides recipes on whether to perform SSL verification for their downloaded files. Only recommended to be set while testing",
"tools.graph:skip_binaries": "Allow the graph to skip binaries not needed in the current configuration (True by default)",
"tools.gnu:make_program": "Indicate path to make program",
"tools.gnu:define_libcxx11_abi": "Force definition of GLIBCXX_USE_CXX11_ABI=1 for libstdc++11",
"tools.gnu:pkg_config": "Path to pkg-config executable used by PkgConfig build helper",
Expand Down
29 changes: 29 additions & 0 deletions conans/test/integration/graph/test_skip_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,32 @@ def test_list_skip_printing():
c.run("install app --build=missing")
c.assert_listed_binary({"tool/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Cache")},
build=True)


def test_conf_skip():
client = TestClient()
client.save({"conanfile.py": GenConanfile()})
client.run("create . --name=maths --version=1.0")
client.run("create . --name=ai --version=1.0")

client.save({"conanfile.py": GenConanfile().with_requirement("maths/1.0", visible=False)})
client.run("create . --name=liba --version=1.0")
client.save({"conanfile.py": GenConanfile().with_requirement("ai/1.0", visible=False)})
client.run("create . --name=libb --version=1.0")

client.save({"conanfile.py": GenConanfile().with_requires("liba/1.0", "libb/1.0")})
client.run("create . --name=app --version=0.0 -v")
client.assert_listed_binary({"maths/1.0": (NO_SETTINGS_PACKAGE_ID, "Skip")})
client.assert_listed_binary({"ai/1.0": (NO_SETTINGS_PACKAGE_ID, "Skip")})

client.run("create . --name=app --version=1.0 -v -c *:tools.graph:skip_binaries=False")
client.assert_listed_binary({"maths/1.0": (NO_SETTINGS_PACKAGE_ID, "Cache")})
client.assert_listed_binary({"ai/1.0": (NO_SETTINGS_PACKAGE_ID, "Cache")})

client.run("create . --name=app --version=2.0 -v -c maths/*:tools.graph:skip_binaries=False")
client.assert_listed_binary({"maths/1.0": (NO_SETTINGS_PACKAGE_ID, "Cache")})
client.assert_listed_binary({"ai/1.0": (NO_SETTINGS_PACKAGE_ID, "Skip")})

client.run("create . --name=app --version=3.0 -v -c *:tools.graph:skip_binaries=True")
client.assert_listed_binary({"maths/1.0": (NO_SETTINGS_PACKAGE_ID, "Skip")})
client.assert_listed_binary({"ai/1.0": (NO_SETTINGS_PACKAGE_ID, "Skip")})

0 comments on commit bc74147

Please sign in to comment.