diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-04-04 23:39:53 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-05-26 17:06:15 +0530 |
commit | 98dae50166486a951fcb0ac3309835017a25cecc (patch) | |
tree | 324f566b2be98d8f3562a427a6802df1d8787c62 /config | |
parent | 59bd06df48d0fa85c5e96b53ea528918934cd62e (diff) |
cerbero: Refactor variant handling in platform config files
While parsing config files such as the platform config files, we were
exposing variants as an unresolved `list` of "operations" that will
enable or disable the variant once they've all been resolved
This is buggy because it means that platform config files have no way
to know whether a variant has actually been disabled or enabled by the
user.
Now we always parse variants into the `Variants` object before parsing
all configuration files.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/480>
Diffstat (limited to 'config')
-rw-r--r-- | config/android.config | 4 | ||||
-rw-r--r-- | config/cross-android-arm64.cbc | 2 | ||||
-rw-r--r-- | config/cross-android-armv7.cbc | 2 | ||||
-rw-r--r-- | config/cross-android-universal.cbc | 2 | ||||
-rw-r--r-- | config/cross-android-x86-64.cbc | 2 | ||||
-rw-r--r-- | config/cross-android-x86.cbc | 2 | ||||
-rw-r--r-- | config/cross-lin-arm.cbc | 4 | ||||
-rw-r--r-- | config/cross-lin-arm64.cbc | 4 | ||||
-rw-r--r-- | config/darwin.config | 4 | ||||
-rw-r--r-- | config/ios.config | 4 | ||||
-rw-r--r-- | config/linux.config | 19 | ||||
-rw-r--r-- | config/windows.config | 18 |
12 files changed, 24 insertions, 43 deletions
diff --git a/config/android.config b/config/android.config index c3c170f1..199c8e27 100644 --- a/config/android.config +++ b/config/android.config @@ -26,7 +26,7 @@ import cerbero.utils.messages as m # sysroot: location of the API-level libraries (no headers) # isysroot: location of the headers -variants += ['nopython', 'notestspackage'] +variants.override(['nopython', 'notestspackage']) # We don't want anything from linux system to be used on android :) allow_system_libs=False @@ -116,7 +116,7 @@ env['ANDROID_NDK'] = toolchain_prefix # so that we can construct different paths to include/lib directories to where # they actually are. Without this we don't know where the headers/libs will # actually end up -if 'universal' in variants: +if universal_archs: incl_dir = os.path.join(prefix, _cerbero_arch, 'include') lib_dir = os.path.join(prefix, _cerbero_arch, 'lib') else: diff --git a/config/cross-android-arm64.cbc b/config/cross-android-arm64.cbc index ab90259b..fc495db2 100644 --- a/config/cross-android-arm64.cbc +++ b/config/cross-android-arm64.cbc @@ -6,4 +6,4 @@ target_distro = Distro.ANDROID target_distro_version = DistroVersion.ANDROID_LOLLIPOP target_arch = Architecture.ARM64 -#variants = ['nodebug'] +#variants.override('nodebug') diff --git a/config/cross-android-armv7.cbc b/config/cross-android-armv7.cbc index 9f0eb2f2..1b30fb26 100644 --- a/config/cross-android-armv7.cbc +++ b/config/cross-android-armv7.cbc @@ -6,4 +6,4 @@ target_distro = Distro.ANDROID target_distro_version = DistroVersion.ANDROID_JELLY_BEAN target_arch = Architecture.ARMv7 -#variants = ['nodebug'] +variants.override('nodebug') diff --git a/config/cross-android-universal.cbc b/config/cross-android-universal.cbc index 81a3f3a7..9f204a3e 100644 --- a/config/cross-android-universal.cbc +++ b/config/cross-android-universal.cbc @@ -15,5 +15,5 @@ universal_archs = { Architecture.X86_64: "cross-android-x86-64.cbc", } -#variants = ['nodebug'] +#variants.override('nodebug') allow_parallel_build = True diff --git a/config/cross-android-x86-64.cbc b/config/cross-android-x86-64.cbc index 43f77af1..d17af197 100644 --- a/config/cross-android-x86-64.cbc +++ b/config/cross-android-x86-64.cbc @@ -6,4 +6,4 @@ target_distro = Distro.ANDROID target_distro_version = DistroVersion.ANDROID_LOLLIPOP target_arch = Architecture.X86_64 -#variants = ['nodebug'] +#variants.override('nodebug') diff --git a/config/cross-android-x86.cbc b/config/cross-android-x86.cbc index 1ed47611..fa551bcb 100644 --- a/config/cross-android-x86.cbc +++ b/config/cross-android-x86.cbc @@ -6,4 +6,4 @@ target_distro = Distro.ANDROID target_distro_version = DistroVersion.ANDROID_JELLY_BEAN target_arch = Architecture.X86 -#variants = ['nodebug'] +#variants.override('nodebug') diff --git a/config/cross-lin-arm.cbc b/config/cross-lin-arm.cbc index fc5c8331..03765ed8 100644 --- a/config/cross-lin-arm.cbc +++ b/config/cross-lin-arm.cbc @@ -4,5 +4,5 @@ from cerbero.config import Platform, Architecture, Distro, DistroVersion target_platform = Platform.LINUX target_distro = Distro.DEBIAN target_arch = Architecture.ARMv7 -variants = ['noalsa', 'nox11', 'nopulse', 'nocdparanoia', 'nosdl', - 'nov4l2', 'notestspackage', 'nopython'] +variants.override(['noalsa', 'nox11', 'nopulse', 'nocdparanoia', 'nosdl', + 'nov4l2', 'notestspackage', 'nopython']) diff --git a/config/cross-lin-arm64.cbc b/config/cross-lin-arm64.cbc index cec3a4dd..fedef53d 100644 --- a/config/cross-lin-arm64.cbc +++ b/config/cross-lin-arm64.cbc @@ -4,8 +4,8 @@ from cerbero.config import Platform, Architecture, Distro, DistroVersion target_platform = Platform.LINUX target_distro = Distro.DEBIAN target_arch = Architecture.ARM64 -variants = ['noalsa', 'nox11', 'nopulse', 'nocdparanoia', 'nosdl', - 'nov4l2', 'notestspackage', 'nopython'] +variants.override(['noalsa', 'nox11', 'nopulse', 'nocdparanoia', 'nosdl', + 'nov4l2', 'notestspackage', 'nopython']) extra_bootstrap_packages = { Platform.LINUX : { diff --git a/config/darwin.config b/config/darwin.config index 22b6af3a..a4dcf4dc 100644 --- a/config/darwin.config +++ b/config/darwin.config @@ -12,8 +12,8 @@ from cerbero.errors import FatalError # used later. System libs are passed through the -isysroot option allow_system_libs=False -if 'nogi' not in variants: - variants.append('gi') +# Enable introspection by default +variants.override('gi') if target_arch == Architecture.X86_64: build='x86_64-apple-darwin12' diff --git a/config/ios.config b/config/ios.config index dd212b23..4f4bb0dc 100644 --- a/config/ios.config +++ b/config/ios.config @@ -9,7 +9,7 @@ from cerbero.utils import shell from cerbero.config import Architecture, DistroVersion from cerbero.errors import FatalError -variants += ['nopython', 'notestspackage'] +variants.override(['nopython', 'notestspackage']) # We don't want anything from macports detected in configure and # used later. System libs are passed through the -isysroot option @@ -95,7 +95,7 @@ else: raise FatalError("Arch %s not supported" % target_arch) includedir = os.path.join(prefix, 'include') -if 'universal' in variants: +if universal_archs: lib_dir = os.path.join(prefix, target_arch, 'lib') else: lib_dir = os.path.join(prefix, 'lib') diff --git a/config/linux.config b/config/linux.config index 370c1e7d..77ef1f91 100644 --- a/config/linux.config +++ b/config/linux.config @@ -6,20 +6,8 @@ import os from cerbero.config import Architecture, Distro -if 'noalsa' not in variants: - variants.append('alsa') -if 'nox11' not in variants: - variants.append('x11') -if 'nopulse' not in variants: - variants.append('pulse') -if 'nocdparanoia' not in variants: - variants.append('cdparanoia') -if 'nov4l2' not in variants: - variants.append('v4l2') -if 'nogi' not in variants: - variants.append('gi') -if 'nounwind' not in variants: - variants.append('unwind') +# Set default values for some optional variants +variants.override(['alsa', 'x11', 'pulse', 'cdparanoia', 'v4l2', 'gi', 'unwind']) for f in ['CPPFLAGS', 'CFLAGS', 'CCASFLAGS', 'CXXFLAGS', 'LDFLAGS', 'OBJCFLAGS']: @@ -89,8 +77,7 @@ if target_arch != arch: if distro == Distro.REDHAT: workaround_cflags += '-I/usr/arm-linux-gnu/include' # Disable gi if we are cross-compiling - if 'gi' in variants: - variants.remove('gi') + variants.gi = False env['CFLAGS'] += arch_flags + workaround_cflags env['CXXFLAGS'] += arch_flags + workaround_cflags diff --git a/config/windows.config b/config/windows.config index d6bf61e7..aac941bd 100644 --- a/config/windows.config +++ b/config/windows.config @@ -9,12 +9,6 @@ from cerbero.config import Architecture, Platform # used later. allow_system_libs = False -# We currently don't use Visual Studio by default anywhere -if 'visualstudio' not in variants: - variants.append('novisualstudio') -if 'uwp' not in variants: - variants.append('nouwp') - if platform == Platform.WINDOWS: separator = ';' if target_arch == Architecture.X86: @@ -67,7 +61,7 @@ def cmd(command, args='', wrapper=''): target_winver = '0x0601' # Default GCC compiler flags -if not for_shell or 'novisualstudio' in variants: +if not for_shell or not variants.visualstudio: env['CFLAGS'] = arch_flags env['CPPFLAGS'] = arch_flags env['CASFLAGS'] = arch_flags @@ -76,7 +70,7 @@ if not for_shell or 'novisualstudio' in variants: else: env['CFLAGS'] = '' env['CPPFLAGS'] = '' - if 'uwp' in variants: + if variants.uwp: # Target distro for UWP is Windows 10 target_winver = '0x0A00' # Setting WINAPI_FAMILY to APP allows us to get link-time errors for @@ -105,7 +99,7 @@ env['DLLTOOL'] = cmd('dlltool', dlltool_flags) # Ensure that we never accidentally use MSYS/MinGW objc/c++ compilers env['OBJC'] = 'false' env['OBJCXX'] = 'false' -if not for_shell or 'novisualstudio' in variants: +if not for_shell or not variants.visualstudio: env['LIBRARY_PATH'] = "{0}/lib{1}".format(prefix, lib_suffix) env['CC'] = cmd('gcc', arch_flags, ccache) env['CXX'] = cmd('g++', arch_flags, ccache) @@ -139,13 +133,13 @@ if platform == Platform.WINDOWS: # Only use one process to make the build more reliable. allow_parallel_build = False -if platform == Platform.WINDOWS and 'visualstudio' in variants: +if platform == Platform.WINDOWS and variants.visualstudio: from cerbero.ide.vs.env import get_msvc_env, append_path # Contains only the env vars that MSVC needs, including any existing vars # that were appended/prepended and have new values # FIXME: Use EnvVarOp class from cerbero/build/build.py msvc_toolchain_env = {} - env, msvc_version = get_msvc_env(arch, target_arch, 'uwp' in variants, + env, msvc_version = get_msvc_env(arch, target_arch, variants.uwp, vs_install_version, vs_install_path) for key, value in env.items(): if key in ('PATH', 'PATHEXT', 'INCLUDE', 'LIB'): @@ -161,7 +155,7 @@ if platform == Platform.WINDOWS and 'visualstudio' in variants: msvc_toolchain_env['LIB'][0] = append_path(msvc_toolchain_env['LIB'][0], os.path.join(prefix, 'lib' + lib_suffix)) msvc_toolchain_env['WINDRES'] = ['rc', ''] - if 'uwp' in variants: + if variants.uwp: meson_cross_properties['needs_exe_wrapper'] = 'true' # If no BOM is found from source file, msvc assumes the file is encoded |