From 5b83c834ac012af8bf806188e1589b5619d8e547 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max.kellermann@gmail.com>
Date: Tue, 26 Sep 2023 15:26:16 +0200
Subject: [PATCH] python/build/meson: write cross-file only if cross-compiling

---
 python/build/meson.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/python/build/meson.py b/python/build/meson.py
index 43a52188e..11e5471a3 100644
--- a/python/build/meson.py
+++ b/python/build/meson.py
@@ -88,7 +88,6 @@ endian = '{endian}'
     return path
 
 def configure(toolchain: AnyToolchain, src: str, build: str, args: list[str]=[]) -> None:
-    cross_file = make_cross_file(toolchain)
     configure = [
         'meson', 'setup',
         build, src,
@@ -98,10 +97,13 @@ def configure(toolchain: AnyToolchain, src: str, build: str, args: list[str]=[])
         '--buildtype', 'plain',
 
         '--default-library=static',
-
-        '--cross-file', cross_file,
     ] + args
 
+    if toolchain.host_triplet is not None:
+        # cross-compiling: write a cross-file
+        cross_file = make_cross_file(toolchain)
+        configure.append(f'--cross-file={cross_file}')
+
     env = toolchain.env.copy()
 
     # Meson 0.54 requires the BOOST_ROOT environment variable