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

Hugo Beauzée-Luyssen git at videolan.org
Tue Oct 30 11:51:27 CET 2018


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

contrib: Add support for cross compilation with meson

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 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 acb40c074c..c4341f9e59 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -290,7 +290,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)" \
@@ -301,6 +301,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=)" && \
@@ -367,7 +372,9 @@ else
 MESON += --buildtype release
 endif
 
-
+ifdef HAVE_CROSS_COMPILE
+MESON += --cross-file $(abspath crossfile.meson)
+endif
 
 ifdef GPL
 REQUIRE_GPL =
@@ -412,6 +419,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 */
@@ -525,6 +533,34 @@ ifdef HAVE_CROSS_COMPILE
 	echo "set(PKG_CONFIG_EXECUTABLE $(PKG_CONFIG))" >> $@
 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