make: Always use a cross file for meson builds.

This commit is contained in:
Rémi Bernon 2025-01-12 15:00:04 +01:00 committed by Arkadiusz Hiler
parent 82b173490c
commit 0c6b70a50b
2 changed files with 18 additions and 21 deletions

View File

@ -127,13 +127,7 @@ $(2)_$(3)_ENV = \
LDFLAGS="$$($(2)_$(3)_LIBFLAGS) $$($(2)_$(3)_LDFLAGS) $$($(2)_LDFLAGS) $$($(4)LDFLAGS)" \
SOURCE_DATE_EPOCH="$$($(2)_$(3)_SOURCE_DATE_EPOCH)" \
ifneq ($(4),CROSS)
# CROSS-prefixed variables for non-CROSS builds which may need to cross
# compile some binaries.
#
# This is for instance used by Wine, but also Meson, as it requires the
# environment variable to ones for native.
ifeq ($(1),wine)
$(2)_$(3)_ENV += \
CROSSAR="$$(CROSS$(3)_TARGET)-ar" \

View File

@ -5,17 +5,15 @@
# $(4): CROSS/<empty>, cross compile
#
define create-rules-meson
# Don't pass CROSS here, we need a native environment and we'll handle
# cross compilation below with the CROSS-prefixed variables.
$(call create-rules-common,$(1),$(2),$(3))
$(call create-rules-common,$(1),$(2),$(3),$(4))
define $(2)_$(3)_MESON_CROSS
cat <<EOF
[binaries]
ar = '$$$$CROSSAR'
c = '$$$$CROSSCC'
cpp = '$$$$CROSSCXX'
ld = '$$$$CROSSLD'
ar = '$$$$AR'
c = '$$$$CC'
cpp = '$$$$CXX'
ld = '$$$$LD'
windres = '$$$$RC'
strip = '$$$$STRIP'
widl = '$$$$WIDL'
@ -25,11 +23,11 @@ pkgconfig = '$$$$PKG_CONFIG'
needs_exe_wrapper = true
c_args = [$$(call list-quote,$$($(2)_$(3)_INCFLAGS) $$($(2)_CPPFLAGS) $$(COMMON_FLAGS) $$($(3)_COMMON_FLAGS))]
cpp_args = [$$(call list-quote,$$($(2)_$(3)_INCFLAGS) $$($(2)_CPPFLAGS) $$(COMMON_FLAGS) $$($(3)_COMMON_FLAGS) -std=c++17)]
link_args = [$$(call list-quote,$$($(2)_$(3)_LIBFLAGS) $$($(2)_$(3)_LDFLAGS) $$($(2)_LDFLAGS) $$(CROSSLDFLAGS))]
pkg_config_libdir = '$$$$CROSSPKG_CONFIG_LIBDIR'
link_args = [$$(call list-quote,$$($(2)_$(3)_LIBFLAGS) $$($(2)_$(3)_LDFLAGS) $$($(2)_LDFLAGS) $$($(4)LDFLAGS))]
pkg_config_libdir = '$$$$PKG_CONFIG_LIBDIR'
[host_machine]
system = 'windows'
system = '$$($(4)$(3)_MESON_SYSTEM)'
cpu_family = '$$($(3)_MESON_CPU)'
cpu = '$$($(3)_MESON_CPU)'
endian = 'little'
@ -44,14 +42,14 @@ $$(OBJ)/.$(1)-$(3)-configure: $$($(2)_SRC)/meson.build
@echo ":: configuring $(1)-$(3)..." >&2
rm -rf "$$($(2)_$(3)_OBJ)/meson-private/coredata.dat"
echo "$$$$$(2)_$(3)_MESON_CROSS" | env $$($(2)_$(3)_ENV) sh >"$$($(2)_$(3)_OBJ)/$(3)-cross.txt"
echo "$$$$$(2)_$(3)_MESON_CROSS" | env $$($(2)_$(3)_ENV) sh >"$$($(2)_$(3)_OBJ)/cross.txt"
env $$($(2)_$(3)_ENV) \
meson "$$($(2)_$(3)_OBJ)" "$$($(2)_SRC)" \
--prefix="$$($(2)_$(3)_DST)" \
--libdir="lib/$$($(4)$(3)_LIBDIR)" \
--buildtype=plain \
$(if $(4),--cross-file="$$($(2)_$(3)_OBJ)/$(3)-cross.txt",) \
--cross-file=$$($(2)_$(3)_OBJ)/cross.txt \
$$($(3)_MESON_ARGS) \
$$($(2)_MESON_ARGS) \
$$($(2)_$(3)_MESON_ARGS) \
@ -66,7 +64,12 @@ $$(OBJ)/.$(1)-$(3)-build:
touch $$@
endef
32_MESON_CPU = x86
64_MESON_CPU = x86_64
32_MESON_CPU := x86
64_MESON_CPU := x86_64
32_MESON_SYSTEM := linux
64_MESON_SYSTEM := linux
CROSS32_MESON_SYSTEM := windows
CROSS64_MESON_SYSTEM := windows
rules-meson = $(call create-rules-meson,$(1),$(call toupper,$(1)),$(2),$(3))