Skip to content

Commit

Permalink
feat: add build_triplet on conf (#15965)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErniGH authored Mar 27, 2024
1 parent f75d15a commit e5994f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions conan/tools/gnu/autotoolstoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, conanfile, namespace=None, prefix="/"):

# Cross build triplets
self._host = self._conanfile.conf.get("tools.gnu:host_triplet")
self._build = None
self._build = self._conanfile.conf.get("tools.gnu:build_triplet")
self._target = None

self.apple_arch_flag = self.apple_isysroot_flag = None
Expand All @@ -78,7 +78,8 @@ def __init__(self, conanfile, namespace=None, prefix="/"):
if not self._host:
self._host = _get_gnu_triplet(os_host, arch_host, compiler=compiler)
# Build triplet
self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler)
if not self._build:
self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler)
# Apple Stuff
if os_build == "Macos" and is_apple_os(conanfile):
# SDK path is mandatory for cross-building
Expand Down
1 change: 1 addition & 0 deletions conans/model/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"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",
"tools.gnu:build_triplet": "Custom build triplet to pass to Autotools scripts",
"tools.gnu:host_triplet": "Custom host triplet to pass to Autotools scripts",
"tools.google.bazel:configs": "List of Bazel configurations to be used as 'bazel build --config=config1 ...'",
"tools.google.bazel:bazelrc_path": "List of paths to bazelrc files to be used as 'bazel --bazelrc=rcpath1 ... build'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_invalid_target_triple():
assert "Unknown 'UNKNOWN_ARCH' machine, Conan doesn't know how " \
"to translate it to the GNU triplet," in str(excinfo)


def test_custom_host_triple():
conanfile = ConanFileMock()
conanfile.settings = MockSettings({"os": "Linux", "arch": "x86"})
Expand All @@ -67,6 +68,18 @@ def test_custom_host_triple():
obj = load_toolchain_args()
assert "--host=i686-pc-linux-gnu" in obj["configure_args"]


def test_custom_build_triple():
conanfile = ConanFileMock()
conanfile.settings = MockSettings({"os": "Linux", "arch": "x86"})
conanfile.settings_build = MockSettings({"os": "Linux", "arch": "x86_64"})
conanfile.conf.define("tools.gnu:build_triplet", "i686-pc-linux-gnu")
tc = AutotoolsToolchain(conanfile)
tc.generate_args()
obj = load_toolchain_args()
assert "--build=i686-pc-linux-gnu" in obj["configure_args"]


def test_cppstd():
# Using "cppstd" is discarded
conanfile = ConanFileMock()
Expand Down

0 comments on commit e5994f9

Please sign in to comment.