[vlc-devel] [PATCH 2/3] contrib: Add support for cross compilation with meson

Steve Lhomme robux4 at ycbcr.xyz
Wed Sep 26 08:03:32 CEST 2018



On 25/09/2018 18:11, Hugo Beauzée-Luyssen wrote:
> ---
>   contrib/src/main.mak | 36 +++++++++++++++++++++++++++++++++++-
>   1 file changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/src/main.mak b/contrib/src/main.mak
> index 0f8b51088f..71972fc896 100644
> --- a/contrib/src/main.mak
> +++ b/contrib/src/main.mak
> @@ -286,7 +286,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)" \
> @@ -297,6 +297,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_NOTOOLS := $(HOSTVARS)
> +HOSTVARS := $(HOSTTOOLS) $(HOSTVARS)
> +

Does it support cross-compilation ? Also the flags for the native 
compiler may not be the same as the ones for $(CC).

>   download_git = \
>   	rm -Rf -- "$(@:.tar.xz=)" && \
>   	$(GIT) init --bare "$(@:.tar.xz=)" && \
> @@ -363,6 +368,9 @@ MESON += --buildtype release
>   endif
>   
>   
> +ifdef HAVE_CROSS_COMPILE
> +MESON += --cross-file $(abspath crossfile.meson)
> +endif
>   
>   ifdef GPL
>   REQUIRE_GPL =
> @@ -407,6 +415,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 */
> @@ -519,6 +528,31 @@ 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)'" >> $@
> +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)
> -- 
> 2.18.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list