[vlc-commits] contrib: Add support for cross compilation with meson

Hugo Beauzée-Luyssen git at videolan.org
Tue Dec 18 18:14:34 CET 2018


vlc/vlc-3.0 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Oct 24 10:25:28 2018 +0200| [fd8a933f3cf8a78fb065fdd008660f1a705ca361] | committer: Hugo Beauzée-Luyssen

contrib: Add support for cross compilation with meson

Signed-off-by: Thomas Guillem <thomas at gllm.fr>
(cherry picked from commit 0946648d3c2dccdd930b3fa7f14af3a003a2111e)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=fd8a933f3cf8a78fb065fdd008660f1a705ca361
---

 contrib/src/main.mak | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index 91c40d6f75..304bdaa432 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -283,7 +283,7 @@ HOSTTOOLS := \
 	CC="$(CC)" CXX="$(CXX)" LD="$(LD)" \
 	AR="$(AR)" CCAS="$(CCAS)" RANLIB="$(RANLIB)" STRIP="$(STRIP)" \
 	PATH="$(PREFIX)/bin:$(PATH)"
-HOSTVARS := $(HOSTTOOLS) \
+HOSTVARS := \
 	CPPFLAGS="$(CPPFLAGS)" \
 	CFLAGS="$(CFLAGS)" \
 	CXXFLAGS="$(CXXFLAGS)" \
@@ -294,6 +294,11 @@ HOSTVARS_PIC := $(HOSTTOOLS) \
 	CXXFLAGS="$(CXXFLAGS) $(PIC)" \
 	LDFLAGS="$(LDFLAGS)"
 
+# Keep a version of HOSTVARS without the tools, since meson requires the
+# tools variables to point to the native ones
+HOSTVARS_MESON := $(HOSTVARS)
+HOSTVARS := $(HOSTTOOLS) $(HOSTVARS)
+
 download_git = \
 	rm -Rf -- "$(@:.tar.xz=)" && \
 	$(GIT) init --bare "$(@:.tar.xz=)" && \
@@ -356,7 +361,9 @@ else
 MESON += --buildtype release
 endif
 
-
+ifdef HAVE_CROSS_COMPILE
+MESON += --cross-file $(abspath crossfile.meson)
+endif
 
 ifdef GPL
 REQUIRE_GPL =
@@ -401,6 +408,7 @@ install: $(PKGS:%=.%)
 mostlyclean:
 	-$(RM) $(foreach p,$(PKGS_ALL),.$(p) .sum-$(p) .dep-$(p))
 	-$(RM) toolchain.cmake
+	-$(RM) crossfile.meson
 	-$(RM) -R "$(PREFIX)"
 	-$(RM) -R "$(BUILDBINDIR)"
 	-$(RM) -R */
@@ -513,6 +521,34 @@ ifdef HAVE_CROSS_COMPILE
 	echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> $@
 endif
 
+crossfile.meson:
+	$(RM) $@
+	echo "[binaries]" >> $@
+	echo "c = '$(CC)'" >> $@
+	echo "cpp = '$(CXX)'" >> $@
+	echo "ar = '$(AR)'" >> $@
+	echo "strip = '$(STRIP)'" >> $@
+	echo "pkgconfig = '$(PKG_CONFIG)'" >> $@
+	echo "[properties]" >> $@
+	echo "needs_exe_wrapper = true" >> $@
+ifdef HAVE_CROSS_COMPILE
+	echo "[host_machine]" >> $@
+ifdef HAVE_WIN32
+	echo "system = 'windows'" >> $@
+else
+ifdef HAVE_IOS
+	echo "system = 'darwin'" >> $@
+else
+ifdef HAVE_ANDROID
+	echo "system = 'linux'" >> $@
+endif
+endif
+endif
+	echo "cpu_family = '$(subst i386,x86,$(ARCH))'" >> $@
+	echo "cpu = '`echo $(HOST) | cut -d - -f 1`'" >> $@
+	echo "endian = 'little'" >> $@
+endif
+
 # Default pattern rules
 .sum-%: $(SRC)/%/SHA512SUMS
 	$(CHECK_SHA512)



More information about the vlc-commits mailing list