build: featurize audio options
This commit is contained in:
parent
7c59e2a569
commit
a2dd4173fc
3 changed files with 45 additions and 27 deletions
|
@ -590,7 +590,7 @@ summary({
|
|||
}, section : 'Main', bool_yn : true)
|
||||
|
||||
summary({
|
||||
'Audio backends' : '@0@ (default: @1@)'.format(', '.join(enabled_audio_backends), get_option('a_default')),
|
||||
'Audio backends' : '@0@ (default: @1@)'.format(', '.join(enabled_audio_backends), default_audio_backend),
|
||||
'Rendering backends' : '@0@ (default: @1@)'.format(', '.join(enabled_renderers), default_renderer),
|
||||
'Shader translation' : shader_transpiler_enabled,
|
||||
'ZIP packages' : dep_zip.found(),
|
||||
|
|
|
@ -162,21 +162,23 @@ option(
|
|||
option(
|
||||
'a_default',
|
||||
type : 'combo',
|
||||
choices : ['sdl', 'null'],
|
||||
choices : ['auto', 'sdl', 'null'],
|
||||
description : 'Which audio backend to use by default'
|
||||
)
|
||||
|
||||
option(
|
||||
'a_sdl',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
type : 'feature',
|
||||
value : 'auto',
|
||||
deprecated : {'true' : 'enabled', 'false' : 'disabled'},
|
||||
description : 'Build the SDL audio backend'
|
||||
)
|
||||
|
||||
option(
|
||||
'a_null',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
type : 'feature',
|
||||
value : 'auto',
|
||||
deprecated : {'true' : 'enabled', 'false' : 'disabled'},
|
||||
description : 'Build the no-op audio backend (silence); you want this on!'
|
||||
)
|
||||
|
||||
|
|
|
@ -1,39 +1,55 @@
|
|||
|
||||
default_backend = get_option('a_default')
|
||||
audio_backend_opts = {
|
||||
'sdl' : get_option('a_sdl'),
|
||||
'null' : get_option('a_null'),
|
||||
}
|
||||
|
||||
if default_backend == 'sdl2mixer'
|
||||
error('Your build directory is outdated. Try running the following command:\n\n$ meson --wipe @0@ @1@ -Da_default=sdl\n'.format(meson.source_root(), meson.build_root()))
|
||||
default_audio_backend = get_option('a_default')
|
||||
audio_backends_prio = ['sdl', 'null']
|
||||
|
||||
if default_audio_backend == 'auto'
|
||||
foreach audio_backend : audio_backends_prio
|
||||
if audio_backend_opts[audio_backend].allowed()
|
||||
default_audio_backend = audio_backend
|
||||
break
|
||||
endif
|
||||
endforeach
|
||||
|
||||
if default_audio_backend == 'auto'
|
||||
audio_backends_prio_opts = []
|
||||
foreach audio_backend : audio_backends_prio
|
||||
audio_backends_prio_opts + f'a_@audio_backend@'
|
||||
endforeach
|
||||
audio_backends_prio_opts = ', '.join(audio_backends_prio_opts)
|
||||
|
||||
error('Could not pick a default audio backend. ' +
|
||||
f'Make sure you have at least one of audio_backends_prio_opts enabled.')
|
||||
endif
|
||||
endif
|
||||
|
||||
if not get_option('a_@0@'.format(default_backend))
|
||||
error('Default audio backend \'@0@\' is not enabled. Enable it with -Da_@0@=true, or set a_default to something else.'.format(default_backend))
|
||||
endif
|
||||
assert(audio_backend_opts[default_audio_backend].allowed(),
|
||||
f'Default audio backend @default_audio_backend@ is not enabled')
|
||||
|
||||
audio_src = files(
|
||||
'audio.c',
|
||||
'backend.c',
|
||||
)
|
||||
|
||||
modules = [
|
||||
'sdl',
|
||||
'null',
|
||||
]
|
||||
|
||||
audio_deps = []
|
||||
enabled_audio_backends = []
|
||||
included_deps = []
|
||||
needed_deps = []
|
||||
a_macro = []
|
||||
|
||||
foreach m : modules
|
||||
if get_option('a_@0@'.format(m))
|
||||
subdir(m)
|
||||
included_deps += [m]
|
||||
enabled_audio_backends += [m]
|
||||
a_macro += ['A(@0@)'.format(m)]
|
||||
audio_src += get_variable('a_@0@_src'.format(m))
|
||||
needed_deps += get_variable('a_@0@_deps'.format(m))
|
||||
audio_deps += get_variable('a_@0@_libdeps'.format(m))
|
||||
foreach audio_backend, aopt : audio_backend_opts
|
||||
if aopt.allowed()
|
||||
subdir(audio_backend)
|
||||
included_deps += [audio_backend]
|
||||
enabled_audio_backends += [audio_backend]
|
||||
a_macro += ['A(@0@)'.format(audio_backend)]
|
||||
audio_src += get_variable(f'a_@audio_backend@_src')
|
||||
needed_deps += get_variable(f'a_@audio_backend@_deps')
|
||||
audio_deps += get_variable(f'a_@audio_backend@_libdeps')
|
||||
endif
|
||||
endforeach
|
||||
|
||||
|
@ -48,4 +64,4 @@ endforeach
|
|||
|
||||
a_macro = ' '.join(a_macro)
|
||||
config.set('TAISEI_BUILDCONF_AUDIO_BACKENDS', a_macro)
|
||||
config.set_quoted('TAISEI_BUILDCONF_AUDIO_DEFAULT', default_backend)
|
||||
config.set_quoted('TAISEI_BUILDCONF_AUDIO_DEFAULT', default_audio_backend)
|
||||
|
|
Loading…
Reference in a new issue