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

[bug] [xbuild] build_requires from host profile is applied to other build requires #7169

Merged
merged 8 commits into from Jun 23, 2020
6 changes: 3 additions & 3 deletions conans/client/graph/graph_manager.py
Expand Up @@ -290,7 +290,6 @@ def _recurse_build_requires(self, graph, builder, check_updates,
package_build_requires = self._get_recipe_build_requires(node.conanfile, default_context)
str_ref = str(node.ref)
new_profile_build_requires = []
profile_build_requires = profile_build_requires or {}
for pattern, build_requires in profile_build_requires.items():
if ((node.recipe == RECIPE_CONSUMER and pattern == "&") or
(node.recipe != RECIPE_CONSUMER and pattern == "&!") or
Expand All @@ -312,10 +311,11 @@ def _recurse_build_requires(self, graph, builder, check_updates,
br_list,
check_updates, update, remotes,
profile_host, profile_build, graph_lock)

build_requires = profile_build.build_requires if default_context == CONTEXT_BUILD \
else profile_build_requires
self._recurse_build_requires(graph, builder,
check_updates, update, build_mode,
remotes, profile_build_requires, recorder,
remotes, build_requires, recorder,
profile_host, profile_build, graph_lock,
nodes_subset=nodessub, root=node)

Expand Down
@@ -0,0 +1,56 @@
import unittest
import textwrap
from conans.test.utils.tools import TestClient, GenConanfile


class BuildRequiresFromProfile(unittest.TestCase):
profile_host = textwrap.dedent("""
[settings]
os=Windows
arch=x86_64
compiler=Visual Studio
compiler.version=16

[build_requires]
br2/version
""")

profile_build = textwrap.dedent("""
[settings]
os=Macos
arch=x86_64
compiler=apple-clang
compiler.version=11.0
compiler.libcxx=libc++
build_type=Release

[build_requires]
br3/version
""")

library_conanfile = textwrap.dedent("""
from conans import ConanFile

class Recipe(ConanFile):
name = "library"
version = "version"

build_requires = "br1/version"
""")

def test_br_from_profile_host_and_profile_build(self):
t = TestClient()
t.save({'profile_host': self.profile_host,
'profile_build': self.profile_build,
'library.py': self.library_conanfile,
'br1.py': GenConanfile(),
'br2.py': GenConanfile(),
'br3.py': GenConanfile()})
t.run("export br1.py br1/version@")
t.run("export br2.py br2/version@")
t.run("export br3.py br3/version@")
t.run("create library.py --profile:host=profile_host --profile:build=profile_build --build *")
self.assertNotIn("br1/version: Applying build-requirement: br2/version", t.out)
self.assertIn("br1/version: Applying build-requirement: br3/version", t.out)
memsharded marked this conversation as resolved.
Show resolved Hide resolved
self.assertIn("library/version: Applying build-requirement: br2/version", t.out)
self.assertIn("library/version: Applying build-requirement: br1/version", t.out)