vlc/vlc-3.0 | branch: master | Marvin Scholz <[email protected]> | Thu Jun 6 16:07:27 2019 +0200| [1bd78ca9c772871938885850b10bcfcb6d35fa21] | committer: Marvin Scholz
contrib: Rework meson crossfile generation Previously the crossfile had a lot of hardcoded flags, instead of the correct CFLAGS/CXXFLAGS, etc. This replaces the generation in the Makefile with a simple Python script instead, which should be fine, given that meson anyway needs Python 3 and that the crossfile is only generated when needed. (cherry picked from commit 48f6d51f6da3e02754bc1b52e45bd9652d1051a4) Signed-off-by: Marvin Scholz <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=1bd78ca9c772871938885850b10bcfcb6d35fa21 --- contrib/src/gen-meson-crossfile.py | 52 +++++++++++++++++++++++++++++++++++++ contrib/src/main.mak | 53 ++++++++++---------------------------- 2 files changed, 65 insertions(+), 40 deletions(-) diff --git a/contrib/src/gen-meson-crossfile.py b/contrib/src/gen-meson-crossfile.py new file mode 100755 index 0000000000..000074d950 --- /dev/null +++ b/contrib/src/gen-meson-crossfile.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +import os +import argparse +import shlex + +# Argument parsing +parser = argparse.ArgumentParser( + description="Generate a meson crossfile based on environment variables") +parser.add_argument('file', type=argparse.FileType('w', encoding='UTF-8'), + help="output file") +args = parser.parse_args() + +# Helper to add env variable value to crossfile +def _add_environ_val(meson_key, env_key): + env_value = os.environ.get(env_key, '') + args.file.write("{} = '{}'\n".format(meson_key, env_value)) + +# Helper to add env variable array to crossfile +def _add_environ_arr(meson_key, env_key): + env_values = shlex.split(os.environ.get(env_key, '')) + arr_string = (', '.join("'" + item + "'" for item in env_values)) + args.file.write("{} = [{}]\n".format(meson_key, arr_string)) + +# Generate meson crossfile +args.file.write("# Automatically generated by contrib makefile\n") + +# Binaries section +args.file.write("\n[binaries]\n") +_add_environ_val('c', 'CC') +_add_environ_val('cpp', 'CXX') +_add_environ_val('ar', 'AR') +_add_environ_val('strip', 'STRIP') +_add_environ_val('pkgconfig', 'PKG_CONFIG') +_add_environ_val('windres', 'WINDRES') + +# Properties section +args.file.write("\n[properties]\n") +args.file.write("needs_exe_wrapper = true\n") +_add_environ_arr('c_args', 'CFLAGS') +_add_environ_arr('c_link_args', 'LDFLAGS') +_add_environ_arr('cpp_args', 'CXXFLAGS') +_add_environ_arr('cpp_link_args', 'LDFLAGS') + +# Host machine section +args.file.write("\n[host_machine]\n") +_add_environ_val('system', 'HOST_SYSTEM') +_add_environ_val('cpu_family', 'HOST_ARCH') +args.file.write("endian = 'little'") + +# Get first part of triplet +cpu = os.environ.get('HOST', '').split('-')[0] +args.file.write("cpu = '{}'\n".format(cpu)) diff --git a/contrib/src/main.mak b/contrib/src/main.mak index f8db7d7656..717d4219fe 100644 --- a/contrib/src/main.mak +++ b/contrib/src/main.mak @@ -533,55 +533,28 @@ 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 "windres = '$(WINDRES)'" >> $@ - echo "[properties]" >> $@ - echo "needs_exe_wrapper = true" >> $@ -ifdef HAVE_CROSS_COMPILE - echo "cpp_args = [ '-I$(PREFIX)/include' ]" >> $@ - echo "cpp_link_args = [ '-L$(PREFIX)/lib' ]" >> $@ -ifdef HAVE_DARWIN_OS -ifdef HAVE_IOS -ifdef HAVE_TVOS - echo "c_args = ['-I$(PREFIX)/include', '-isysroot', '$(IOS_SDK)', '-mtvos-version-min=10.2', '-arch', '$(PLATFORM_SHORT_ARCH)', '-fembed-bitcode']" >> $@ - echo "c_link_args = ['-L$(PREFIX)/lib', '-isysroot', '$(IOS_SDK)', '-arch', '$(PLATFORM_SHORT_ARCH)', '-fembed-bitcode']" >> $@ -else - echo "c_args = ['-I$(PREFIX)/include', '-isysroot', '$(IOS_SDK)', '-miphoneos-version-min=8.4', '-arch', '$(PLATFORM_SHORT_ARCH)']" >> $@ - echo "c_link_args = ['-L$(PREFIX)/lib', '-isysroot', '$(IOS_SDK)', '-arch', '$(PLATFORM_SHORT_ARCH)']" >> $@ -endif -endif -ifdef HAVE_MACOSX - echo "c_args = ['-I$(PREFIX)/include', '-isysroot', '$(MACOSX_SDK)', '-mmacosx-version-min=10.10', '-arch', '$(ARCH)']" >> $@ - echo "c_link_args = ['-L$(PREFIX)/lib', '-isysroot', '$(MACOSX_SDK)', '-arch', '$(ARCH)']" >> $@ -endif -else - echo "c_args = [ '-I$(PREFIX)/include' ]" >> $@ - echo "c_link_args = [ '-L$(PREFIX)/lib' ]" >> $@ -endif - echo "[host_machine]" >> $@ +MESON_SYSTEM_NAME = ifdef HAVE_WIN32 - echo "system = 'windows'" >> $@ + MESON_SYSTEM_NAME = windows else ifdef HAVE_DARWIN_OS - echo "system = 'darwin'" >> $@ + MESON_SYSTEM_NAME = darwin else ifdef HAVE_LINUX # android has also system = linux and defines HAVE_LINUX - echo "system = 'linux'" >> $@ + MESON_SYSTEM_NAME = 'linux' endif endif endif - echo "cpu_family = '$(subst i386,x86,$(ARCH))'" >> $@ - echo "cpu = '`echo $(HOST) | cut -d - -f 1`'" >> $@ - echo "endian = 'little'" >> $@ -endif + +crossfile.meson: + $(HOSTVARS) \ + WINDRES="$(WINDRES)" \ + PKG_CONFIG="$(PKG_CONFIG)" \ + HOST_SYSTEM="$(MESON_SYSTEM_NAME)" \ + HOST_ARCH="$(subst i386,x86,$(ARCH))" \ + HOST="$(HOST)" \ + $(SRC)/gen-meson-crossfile.py $@ # Default pattern rules .sum-%: $(SRC)/%/SHA512SUMS _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
