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

[feature] Added cross-building conf variable #15616

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions conan/tools/build/cross_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def cross_building(conanfile=None, skip_x64_x86=False):
x86_64 to x86, sparcv9 to sparc or ppc64 to ppc32
:return: ``True`` if we are cross building, ``False`` otherwise.
"""
force = conanfile.conf.get("tools.build.cross_building:force", check_type=bool)
if force is not None:
return force

build_os = conanfile.settings_build.get_safe('os')
build_arch = conanfile.settings_build.get_safe('arch')
Expand Down
1 change: 1 addition & 0 deletions conans/model/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"tools.apple:enable_visibility": "(boolean) Enable/Disable Visibility Apple Clang flags",
"tools.env.virtualenv:powershell": "If it is set to True it will generate powershell launchers if os=Windows",
# Compilers/Flags configurations
"tools.build.cross_building:force": "Force cross-building regardless of arch/OS settings.",
"tools.build:compiler_executables": "Defines a Python dict-like with the compilers path to be used. Allowed keys {'c', 'cpp', 'cuda', 'objc', 'objcxx', 'rc', 'fortran', 'asm', 'hip', 'ispc'}",
"tools.build:cxxflags": "List of extra CXX flags used by different toolchains like CMakeToolchain, AutotoolsToolchain and MesonToolchain",
"tools.build:cflags": "List of extra C flags used by different toolchains like CMakeToolchain, AutotoolsToolchain and MesonToolchain",
Expand Down
16 changes: 16 additions & 0 deletions conans/test/unittests/tools/build/test_cross_building.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest

from conan.tools.build import cross_building
from conans.test.utils.mocks import ConanFileMock


@pytest.mark.parametrize("force", (True, False))
def test_using_force_conf(force):
"""
Tests cross_building function is using the conf variable to force or not.

Issue related: https://github.com/conan-io/conan/issues/15392
"""
conanfile = ConanFileMock()
conanfile.conf.define("tools.build.cross_building:force", force)
assert cross_building(conanfile) == force