meson: Don't use get_option('buildtype')

We should directly check the values of the `debug` and `optimization`
options instead.

`get_option('buildtype')` will return `'custom'` for most combinations
of `-Doptimization` and `-Ddebug`, but those two will always be set
correctly if only `-Dbuildtype` is set. So we should look at those
options directly.

For the two-way mapping between `buildtype` and `optimization`
+ `debug`, see this table:
https://mesonbuild.com/Builtin-options.html#build-type-options
This commit is contained in:
Nirbheek Chauhan 2020-04-03 17:07:47 +05:30
parent 1f62fe1cbc
commit 387b6df948
3 changed files with 5 additions and 6 deletions

View file

@ -18,17 +18,16 @@ bin2array = find_program('bin2array.py')
# FIXME: meson compiler class instead? # FIXME: meson compiler class instead?
glslc_build_options = [] glslc_build_options = []
optimization = get_option('optimization') optimization = get_option('optimization')
buildtype = get_option('buildtype') if get_option('debug')
if get_option('debug') or optimization == 'g' or ['debug', 'debugoptimized'].contains(buildtype)
glslc_build_options += ['-g'] glslc_build_options += ['-g']
endif endif
if get_option('werror') if get_option('werror')
glslc_build_options += ['-Werror'] glslc_build_options += ['-Werror']
endif endif
if buildtype == 'minsize' or optimization == 's' if optimization == 's'
glslc_build_options += ['-Os'] glslc_build_options += ['-Os']
endif endif
if ['release', 'debugoptimized'].contains(buildtype) or ['1', '2', '3'].contains(optimization) if optimization in ['1', '2', '3']
glslc_build_options += ['-O'] glslc_build_options += ['-O']
endif endif

View file

@ -1,6 +1,6 @@
project('gst-plugins-bad', 'c', 'cpp', project('gst-plugins-bad', 'c', 'cpp',
version : '1.17.0.1', version : '1.17.0.1',
meson_version : '>= 0.48', meson_version : '>= 0.49',
default_options : [ 'warning_level=1', default_options : [ 'warning_level=1',
'buildtype=debugoptimized' ]) 'buildtype=debugoptimized' ])

View file

@ -86,7 +86,7 @@ if not have_d3d11
endif endif
# for enabling debug layer # for enabling debug layer
if get_option('buildtype').startswith('debug') if get_option('debug')
d3d11_debug_libs = [ d3d11_debug_libs = [
['d3d11sdklayers.h', 'ID3D11Debug', 'ID3D11InfoQueue', 'have_d3d11sdk_h'], ['d3d11sdklayers.h', 'ID3D11Debug', 'ID3D11InfoQueue', 'have_d3d11sdk_h'],
['dxgidebug.h', 'IDXGIDebug', 'IDXGIInfoQueue', 'have_dxgidebug_h'], ['dxgidebug.h', 'IDXGIDebug', 'IDXGIInfoQueue', 'have_dxgidebug_h'],