[PATCH v3 11/11] meson.build: ignore audio drivers when configured with --disable-audio

Sergei Heifetz posted 11 patches 3 weeks, 1 day ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Dr. David Alan Gilbert" <dave@treblig.org>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>
[PATCH v3 11/11] meson.build: ignore audio drivers when configured with --disable-audio
Posted by Sergei Heifetz 3 weeks, 1 day ago
When QEMU is configured with `--disable-audio`, we do not need to add the
audio drivers list to config_host_data. We also do not need to print this
list.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 meson.build | 80 ++++++++++++++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 35 deletions(-)

diff --git a/meson.build b/meson.build
index d05533488f9..7f71dce3ae5 100644
--- a/meson.build
+++ b/meson.build
@@ -2280,46 +2280,55 @@ endif
 config_host_data = configuration_data()
 
 config_host_data.set('CONFIG_HAVE_RUST', have_rust)
-audio_drivers_selected = []
-if have_system
-  audio_drivers_available = {
-    'alsa': alsa.found(),
-    'coreaudio': coreaudio.found(),
-    'dsound': dsound.found(),
-    'jack': jack.found(),
-    'oss': oss.found(),
-    'pa': pulse.found(),
-    'pipewire': pipewire.found(),
-    'sdl': sdl.found(),
-    'sndio': sndio.found(),
-  }
-  foreach k, v: audio_drivers_available
-    config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
-  endforeach
+config_host_data.set('CONFIG_AUDIO', have_audio)
+if have_audio
+  audio_drivers_selected = []
+  if have_system
+    audio_drivers_available = {
+      'alsa': alsa.found(),
+      'coreaudio': coreaudio.found(),
+      'dsound': dsound.found(),
+      'jack': jack.found(),
+      'oss': oss.found(),
+      'pa': pulse.found(),
+      'pipewire': pipewire.found(),
+      'sdl': sdl.found(),
+      'sndio': sndio.found(),
+    }
+    foreach k, v: audio_drivers_available
+      config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
+    endforeach
 
-  # Default to native drivers first, OSS second, SDL third
-  audio_drivers_priority = \
-    [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
-    (host_os == 'linux' ? [] : [ 'sdl' ])
-  audio_drivers_default = []
-  foreach k: audio_drivers_priority
-    if audio_drivers_available[k]
-      audio_drivers_default += k
-    endif
-  endforeach
+    # Default to native drivers first, OSS second, SDL third
+    audio_drivers_priority = \
+      [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
+      (host_os == 'linux' ? [] : [ 'sdl' ])
+    audio_drivers_default = []
+    foreach k: audio_drivers_priority
+      if audio_drivers_available[k]
+        audio_drivers_default += k
+      endif
+    endforeach
 
+    foreach k: get_option('audio_drv_list')
+      if k == 'default'
+        audio_drivers_selected += audio_drivers_default
+      elif not audio_drivers_available[k]
+        error('Audio driver "@0@" not available.'.format(k))
+      else
+        audio_drivers_selected += k
+      endif
+    endforeach
+  endif
+  config_host_data.set('CONFIG_AUDIO_DRIVERS',
+                      '"' + '", "'.join(audio_drivers_selected) + '", ')
+else
   foreach k: get_option('audio_drv_list')
-    if k == 'default'
-      audio_drivers_selected += audio_drivers_default
-    elif not audio_drivers_available[k]
-      error('Audio driver "@0@" not available.'.format(k))
-    else
-      audio_drivers_selected += k
+    if k != 'default'
+      error('Audio drivers are not supported because audio is disabled.')
     endif
   endforeach
 endif
-config_host_data.set('CONFIG_AUDIO_DRIVERS',
-                     '"' + '", "'.join(audio_drivers_selected) + '", ')
 
 have_host_block_device = (host_os != 'darwin' or
     cc.has_header('IOKit/storage/IOMedia.h'))
@@ -4710,7 +4719,8 @@ if enable_modules
   summary_info += {'alternative module path': get_option('module_upgrades')}
 endif
 summary_info += {'fuzzing support':   get_option('fuzzing')}
-if have_system
+summary_info += {'Audio support':     have_audio}
+if have_audio
   summary_info += {'Audio drivers':     ' '.join(audio_drivers_selected)}
 endif
 summary_info += {'Trace backends':    ','.join(get_option('trace_backends'))}
-- 
2.34.1


Re: [PATCH v3 11/11] meson.build: ignore audio drivers when configured with --disable-audio
Posted by Philippe Mathieu-Daudé 5 days, 20 hours ago
On 15/3/26 21:16, Sergei Heifetz wrote:
> When QEMU is configured with `--disable-audio`, we do not need to add the
> audio drivers list to config_host_data. We also do not need to print this
> list.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   meson.build | 80 ++++++++++++++++++++++++++++++-----------------------
>   1 file changed, 45 insertions(+), 35 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index d05533488f9..7f71dce3ae5 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2280,46 +2280,55 @@ endif
>   config_host_data = configuration_data()
>   
>   config_host_data.set('CONFIG_HAVE_RUST', have_rust)
> -audio_drivers_selected = []
> -if have_system
> -  audio_drivers_available = {
> -    'alsa': alsa.found(),
> -    'coreaudio': coreaudio.found(),
> -    'dsound': dsound.found(),
> -    'jack': jack.found(),
> -    'oss': oss.found(),
> -    'pa': pulse.found(),
> -    'pipewire': pipewire.found(),
> -    'sdl': sdl.found(),
> -    'sndio': sndio.found(),
> -  }
> -  foreach k, v: audio_drivers_available
> -    config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
> -  endforeach
> +config_host_data.set('CONFIG_AUDIO', have_audio)
> +if have_audio
> +  audio_drivers_selected = []
> +  if have_system
> +    audio_drivers_available = {
> +      'alsa': alsa.found(),
> +      'coreaudio': coreaudio.found(),
> +      'dsound': dsound.found(),
> +      'jack': jack.found(),
> +      'oss': oss.found(),
> +      'pa': pulse.found(),
> +      'pipewire': pipewire.found(),
> +      'sdl': sdl.found(),
> +      'sndio': sndio.found(),
> +    }
> +    foreach k, v: audio_drivers_available
> +      config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
> +    endforeach
>   
> -  # Default to native drivers first, OSS second, SDL third
> -  audio_drivers_priority = \
> -    [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
> -    (host_os == 'linux' ? [] : [ 'sdl' ])
> -  audio_drivers_default = []
> -  foreach k: audio_drivers_priority
> -    if audio_drivers_available[k]
> -      audio_drivers_default += k
> -    endif
> -  endforeach
> +    # Default to native drivers first, OSS second, SDL third
> +    audio_drivers_priority = \
> +      [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
> +      (host_os == 'linux' ? [] : [ 'sdl' ])
> +    audio_drivers_default = []
> +    foreach k: audio_drivers_priority
> +      if audio_drivers_available[k]
> +        audio_drivers_default += k
> +      endif
> +    endforeach
>   
> +    foreach k: get_option('audio_drv_list')
> +      if k == 'default'
> +        audio_drivers_selected += audio_drivers_default
> +      elif not audio_drivers_available[k]
> +        error('Audio driver "@0@" not available.'.format(k))
> +      else
> +        audio_drivers_selected += k
> +      endif
> +    endforeach
> +  endif
> +  config_host_data.set('CONFIG_AUDIO_DRIVERS',
> +                      '"' + '", "'.join(audio_drivers_selected) + '", ')
> +else
>     foreach k: get_option('audio_drv_list')
> -    if k == 'default'
> -      audio_drivers_selected += audio_drivers_default
> -    elif not audio_drivers_available[k]
> -      error('Audio driver "@0@" not available.'.format(k))
> -    else
> -      audio_drivers_selected += k
> +    if k != 'default'
> +      error('Audio drivers are not supported because audio is disabled.')
>       endif
>     endforeach
>   endif
> -config_host_data.set('CONFIG_AUDIO_DRIVERS',
> -                     '"' + '", "'.join(audio_drivers_selected) + '", ')
>   
>   have_host_block_device = (host_os != 'darwin' or
>       cc.has_header('IOKit/storage/IOMedia.h'))
> @@ -4710,7 +4719,8 @@ if enable_modules
>     summary_info += {'alternative module path': get_option('module_upgrades')}
>   endif
>   summary_info += {'fuzzing support':   get_option('fuzzing')}
> -if have_system
> +summary_info += {'Audio support':     have_audio}
> +if have_audio
>     summary_info += {'Audio drivers':     ' '.join(audio_drivers_selected)}
>   endif
>   summary_info += {'Trace backends':    ','.join(get_option('trace_backends'))}

Shouldn't this be squashed with patch #1 as a single meson change?

Re: [PATCH v3 11/11] meson.build: ignore audio drivers when configured with --disable-audio
Posted by Philippe Mathieu-Daudé 5 days, 20 hours ago
On 1/4/26 12:10, Philippe Mathieu-Daudé wrote:
> On 15/3/26 21:16, Sergei Heifetz wrote:
>> When QEMU is configured with `--disable-audio`, we do not need to add the
>> audio drivers list to config_host_data. We also do not need to print this
>> list.
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>>   meson.build | 80 ++++++++++++++++++++++++++++++-----------------------
>>   1 file changed, 45 insertions(+), 35 deletions(-)
>>
>> diff --git a/meson.build b/meson.build
>> index d05533488f9..7f71dce3ae5 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -2280,46 +2280,55 @@ endif
>>   config_host_data = configuration_data()
>>   config_host_data.set('CONFIG_HAVE_RUST', have_rust)
>> -audio_drivers_selected = []
>> -if have_system
>> -  audio_drivers_available = {
>> -    'alsa': alsa.found(),
>> -    'coreaudio': coreaudio.found(),
>> -    'dsound': dsound.found(),
>> -    'jack': jack.found(),
>> -    'oss': oss.found(),
>> -    'pa': pulse.found(),
>> -    'pipewire': pipewire.found(),
>> -    'sdl': sdl.found(),
>> -    'sndio': sndio.found(),
>> -  }
>> -  foreach k, v: audio_drivers_available
>> -    config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
>> -  endforeach
>> +config_host_data.set('CONFIG_AUDIO', have_audio)
>> +if have_audio
>> +  audio_drivers_selected = []
>> +  if have_system
>> +    audio_drivers_available = {
>> +      'alsa': alsa.found(),
>> +      'coreaudio': coreaudio.found(),
>> +      'dsound': dsound.found(),
>> +      'jack': jack.found(),
>> +      'oss': oss.found(),
>> +      'pa': pulse.found(),
>> +      'pipewire': pipewire.found(),
>> +      'sdl': sdl.found(),
>> +      'sndio': sndio.found(),
>> +    }
>> +    foreach k, v: audio_drivers_available
>> +      config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
>> +    endforeach
>> -  # Default to native drivers first, OSS second, SDL third
>> -  audio_drivers_priority = \
>> -    [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
>> -    (host_os == 'linux' ? [] : [ 'sdl' ])
>> -  audio_drivers_default = []
>> -  foreach k: audio_drivers_priority
>> -    if audio_drivers_available[k]
>> -      audio_drivers_default += k
>> -    endif
>> -  endforeach
>> +    # Default to native drivers first, OSS second, SDL third
>> +    audio_drivers_priority = \
>> +      [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
>> +      (host_os == 'linux' ? [] : [ 'sdl' ])
>> +    audio_drivers_default = []
>> +    foreach k: audio_drivers_priority
>> +      if audio_drivers_available[k]
>> +        audio_drivers_default += k
>> +      endif
>> +    endforeach
>> +    foreach k: get_option('audio_drv_list')
>> +      if k == 'default'
>> +        audio_drivers_selected += audio_drivers_default
>> +      elif not audio_drivers_available[k]
>> +        error('Audio driver "@0@" not available.'.format(k))
>> +      else
>> +        audio_drivers_selected += k
>> +      endif
>> +    endforeach
>> +  endif
>> +  config_host_data.set('CONFIG_AUDIO_DRIVERS',
>> +                      '"' + '", "'.join(audio_drivers_selected) + '", ')
>> +else
>>     foreach k: get_option('audio_drv_list')
>> -    if k == 'default'
>> -      audio_drivers_selected += audio_drivers_default
>> -    elif not audio_drivers_available[k]
>> -      error('Audio driver "@0@" not available.'.format(k))
>> -    else
>> -      audio_drivers_selected += k
>> +    if k != 'default'
>> +      error('Audio drivers are not supported because audio is 
>> disabled.')
>>       endif
>>     endforeach
>>   endif
>> -config_host_data.set('CONFIG_AUDIO_DRIVERS',
>> -                     '"' + '", "'.join(audio_drivers_selected) + '", ')
>>   have_host_block_device = (host_os != 'darwin' or
>>       cc.has_header('IOKit/storage/IOMedia.h'))
>> @@ -4710,7 +4719,8 @@ if enable_modules
>>     summary_info += {'alternative module path': 
>> get_option('module_upgrades')}
>>   endif
>>   summary_info += {'fuzzing support':   get_option('fuzzing')}
>> -if have_system
>> +summary_info += {'Audio support':     have_audio}
>> +if have_audio
>>     summary_info += {'Audio drivers':     ' 
>> '.join(audio_drivers_selected)}
>>   endif
>>   summary_info += {'Trace backends':    
>> ','.join(get_option('trace_backends'))}
> 
> Shouldn't this be squashed with patch #1 as a single meson change?

Ah no otherwise we'd get link failures before the other patches.