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)" \ LDFLAGS="$$($(2)_$(3)_LIBFLAGS) $$($(2)_$(3)_LDFLAGS) $$($(2)_LDFLAGS) $$($(4)LDFLAGS)" \
SOURCE_DATE_EPOCH="$$($(2)_$(3)_SOURCE_DATE_EPOCH)" \ SOURCE_DATE_EPOCH="$$($(2)_$(3)_SOURCE_DATE_EPOCH)" \
ifneq ($(4),CROSS) ifeq ($(1),wine)
# 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.
$(2)_$(3)_ENV += \ $(2)_$(3)_ENV += \
CROSSAR="$$(CROSS$(3)_TARGET)-ar" \ CROSSAR="$$(CROSS$(3)_TARGET)-ar" \

View File

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