meson: Support building lame as subproject
authorThibault Saunier <tsaunier@igalia.com>
Tue, 5 Oct 2021 14:38:33 +0000 (11:38 -0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 16 Oct 2021 00:43:10 +0000 (00:43 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1068>

subprojects/gst-plugins-good/ext/lame/gstlamemp3enc.h
subprojects/gst-plugins-good/ext/lame/meson.build
subprojects/lame.wrap [new file with mode: 0644]

index cff9a29..e0d15bd 100644 (file)
 
 G_BEGIN_DECLS
 
+#ifndef LAME_SUBPROJECT
 #include <lame/lame.h>
+#else
+#include "lame.h"
+#endif
 
 #define GST_TYPE_LAMEMP3ENC (gst_lamemp3enc_get_type())
 G_DECLARE_FINAL_TYPE (GstLameMP3Enc, gst_lamemp3enc, GST, LAMEMP3ENC,
index 2544658..8baa283 100644 (file)
@@ -1,31 +1,33 @@
 lame_option = get_option('lame')
-lame_dep = cc.find_library('mp3lame', required : lame_option)
-have_lame = lame_dep.found()
+lame_dep = dependency('mp3lame', fallback: ['lame', 'lame_dep'], required: false)
 
-# 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 = []
+lame_extra_c_args = []
+have_lame = lame_dep.found()
+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 (file)
index 0000000..d2eb6ad
--- /dev/null
@@ -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
+