From f60af61bb7bf9446eb05a20ac7c5124aed445fb9 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 5 Oct 2021 11:38:33 -0300 Subject: [PATCH] meson: Support building lame as subproject Part-of: --- .../gst-plugins-good/ext/lame/gstlamemp3enc.h | 4 ++ .../gst-plugins-good/ext/lame/meson.build | 46 ++++++++++--------- subprojects/lame.wrap | 9 ++++ 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 subprojects/lame.wrap diff --git a/subprojects/gst-plugins-good/ext/lame/gstlamemp3enc.h b/subprojects/gst-plugins-good/ext/lame/gstlamemp3enc.h index cff9a2939e..e0d15bde5d 100644 --- a/subprojects/gst-plugins-good/ext/lame/gstlamemp3enc.h +++ b/subprojects/gst-plugins-good/ext/lame/gstlamemp3enc.h @@ -29,7 +29,11 @@ G_BEGIN_DECLS +#ifndef LAME_SUBPROJECT #include +#else +#include "lame.h" +#endif #define GST_TYPE_LAMEMP3ENC (gst_lamemp3enc_get_type()) G_DECLARE_FINAL_TYPE (GstLameMP3Enc, gst_lamemp3enc, GST, LAMEMP3ENC, diff --git a/subprojects/gst-plugins-good/ext/lame/meson.build b/subprojects/gst-plugins-good/ext/lame/meson.build index 25446589da..8baa283c31 100644 --- a/subprojects/gst-plugins-good/ext/lame/meson.build +++ b/subprojects/gst-plugins-good/ext/lame/meson.build @@ -1,31 +1,33 @@ lame_option = get_option('lame') -lame_dep = cc.find_library('mp3lame', required : lame_option) +lame_dep = dependency('mp3lame', fallback: ['lame', 'lame_dep'], required: false) + +lame_extra_c_args = [] have_lame = lame_dep.found() - -# TODO: https://github.com/mesonbuild/meson/issues/3940 -if have_lame - have_lame = cc.has_header_symbol('lame/lame.h', 'lame_init') - if not have_lame and lame_option.enabled() - error('Found libmp3lame but lame.h was not usable') - endif -endif - -if have_lame - lame_extra_c_args = [] +if not have_lame + lame_dep = cc.find_library('mp3lame', required : lame_option) + have_lame = cc.has_header_symbol('lame/lame.h', 'lame_init', required : lame_option) if cc.has_header_symbol('lame/lame.h', 'lame_set_VBR_quality') lame_extra_c_args += ['-DHAVE_LAME_SET_VBR_QUALITY'] endif if cc.has_header_symbol('lame/lame.h', 'MEDIUM') lame_extra_c_args += ['-DGSTLAME_PRESET'] endif - lame = library('gstlame', - ['gstlamemp3enc.c', 'plugin.c'], - c_args : gst_plugins_good_args + lame_extra_c_args, - include_directories : [configinc, libsinc], - dependencies : [gstaudio_dep, lame_dep], - install : true, - install_dir : plugins_install_dir, - ) - pkgconfig.generate(lame, install_dir : plugins_pkgconfig_install_dir) - plugins += [lame] +else + lame_extra_c_args += ['-DHAVE_LAME_SET_VBR_QUALITY', '-DGSTLAME_PRESET', '-DLAME_SUBPROJECT'] endif + +if not have_lame + subdir_done() +endif + +lame = library('gstlame', + ['gstlamemp3enc.c', 'plugin.c'], + c_args : gst_plugins_good_args + lame_extra_c_args, + include_directories : [configinc, libsinc], + dependencies : [gstaudio_dep, lame_dep], + install : true, + install_dir : plugins_install_dir, +) + +pkgconfig.generate(lame, install_dir : plugins_pkgconfig_install_dir) +plugins += [lame] diff --git a/subprojects/lame.wrap b/subprojects/lame.wrap new file mode 100644 index 0000000000..d2eb6adfee --- /dev/null +++ b/subprojects/lame.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = lame-3.100 +source_url = http://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz +source_filename = lame-3.100.tar.gz +source_hash = ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e +patch_url = https://wrapdb.mesonbuild.com/v2/lame_3.100-1/get_patch +patch_filename = lame-3.100-1-wrap.zip +patch_hash = 3e62e95d13aef0f139e4376e775acb367525a8ed2dbeb8d09c93fd318f093654 +