meson: Pass -DGST_STATIC_COMPILATION for static builds
[platform/upstream/gstreamer.git] / gst / meson.build
index e8b1f4d..d29e370 100644 (file)
@@ -11,7 +11,6 @@ gst_sources = [
   'gstcapsfeatures.c',
   'gstchildproxy.c',
   'gstclock.c',
-  'gstclock-linreg.c',
   'gstcontext.c',
   'gstcontrolbinding.c',
   'gstcontrolsource.c',
@@ -20,6 +19,7 @@ gst_sources = [
   'gstdevice.c',
   'gstdeviceprovider.c',
   'gstdeviceproviderfactory.c',
+  'gstdynamictypefactory.c',
   'gstelement.c',
   'gstelementfactory.c',
   'gsterror.c',
@@ -48,6 +48,7 @@ gst_sources = [
   'gstquery.c',
   'gstregistry.c',
   'gstregistrychunks.c',
+  'gstpromise.c',
   'gstsample.c',
   'gstsegment.c',
   'gststreamcollection.c',
@@ -97,6 +98,7 @@ gst_headers = [
   'gstdevice.h',
   'gstdeviceprovider.h',
   'gstdeviceproviderfactory.h',
+  'gstdynamictypefactory.h',
   'gstelementfactory.h',
   'gsterror.h',
   'gstevent.h',
@@ -121,6 +123,7 @@ gst_headers = [
   'gstpreset.h',
   'gstprotection.h',
   'gstquery.h',
+  'gstpromise.h',
   'gstsample.h',
   'gstsegment.h',
   'gststreamcollection.h',
@@ -147,111 +150,140 @@ gst_headers = [
 ]
 install_headers(gst_headers, subdir : 'gstreamer-1.0/gst')
 
-if not get_option('disable_registry')
-  gst_registry = ['gstregistrybinary.c']
+gst_registry = get_option('registry')
+if gst_registry
+  gst_registry_sources = ['gstregistrybinary.c']
 else
-  gst_registry = []
+  gst_registry_sources = []
 endif
 
+# Make copy so configure_file consumes the copy and we can
+# still add to the original cdata later.
+gst_cdata = cdata
+
+if gst_debug
+  gst_cdata.set('GST_DISABLE_GST_DEBUG_DEFINE', '#undef GST_DISABLE_GST_DEBUG')
+else
+  gst_cdata.set('GST_DISABLE_GST_DEBUG_DEFINE', '#define GST_DISABLE_GST_DEBUG 1')
+endif
+
+if gst_registry
+  gst_cdata.set('GST_DISABLE_REGISTRY_DEFINE', '#undef GST_DISABLE_REGISTRY')
+else
+  gst_cdata.set('GST_DISABLE_REGISTRY_DEFINE', '#define GST_DISABLE_REGISTRY 1')
+endif
+
+gst_parse = get_option('gst_parse')
+if gst_parse
+  gst_cdata.set('GST_DISABLE_PARSE_DEFINE', '#undef GST_DISABLE_PARSE')
+else
+  gst_cdata.set('GST_DISABLE_PARSE_DEFINE', '#define GST_DISABLE_PARSE 1')
+endif
+
+gst_cdata.set10('GST_DISABLE_CAST_CHECKS_DEFINE', cast_checks.disabled())
+gst_cdata.set10('GST_DISABLE_GLIB_ASSERTS_DEFINE', glib_asserts.disabled())
+gst_cdata.set10('GST_DISABLE_GLIB_CHECKS_DEFINE', glib_checks.disabled())
+
+# FIXME: add --disable-plugin option?
+gst_cdata.set('GST_DISABLE_PLUGIN_DEFINE', '#undef GST_DISABLE_PLUGIN')
+
 configure_file(input : 'gstconfig.h.in',
   output : 'gstconfig.h',
-  install_dir : 'include/gstreamer-1.0/gst',
-  configuration : cdata)
-configure_file(input : 'gstversion.h.in',
+  install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst'),
+  configuration : gst_cdata)
+
+version_cdata = configuration_data()
+version_cdata.set('GST_VERSION_MAJOR', gst_version_major)
+version_cdata.set('GST_VERSION_MINOR', gst_version_minor)
+version_cdata.set('GST_VERSION_MICRO', gst_version_micro)
+version_cdata.set('GST_VERSION_NANO', gst_version_nano)
+
+gst_version_h = configure_file(input : 'gstversion.h.in',
   output : 'gstversion.h',
-  install_dir : 'include/gstreamer-1.0/gst',
-  configuration : cdata)
+  install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst'),
+  configuration : version_cdata)
 
-mkenums = find_program('build_mkenum.py')
-glib_mkenums = find_program('glib-mkenums')
+gst_enums = gnome.mkenums_simple('gstenumtypes',
+  sources : gst_headers,
+  header_prefix : '#include <gst/gstconfig.h>',
+  body_prefix : '#include "gst/gst_private.h"\n#include <gst/gst.h>',
+  decorator : 'GST_API',
+  install_header : true,
+  install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst'))
 
-gstenum_h = custom_target('gstenum_h',
-  output : 'gstenumtypes.h',
-  input : gst_headers,
-  install : true,
-  install_dir : 'include/gstreamer-1.0/gst',
-  command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
+gstenum_h = gst_enums[1]
+gstenum_c = gst_enums[0]
 
-gstenum_c = custom_target('gstenum_c',
-  output : 'gstenumtypes.c',
-  input : gst_headers,
-  depends : [gstenum_h],
-  command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
+gst_parse_sources = []
+if gst_parse
+  subdir('parse')
+endif
 
-subdir('parse')
 subdir('printf')
 
 libgst_c_args = gst_c_args + [
   '-D_GNU_SOURCE',
-  '-DGST_EXPORTS',
   '-DG_LOG_DOMAIN=g_log_domain_gstreamer',
   '-DGST_DISABLE_DEPRECATED',
 ]
 
-# Make it possible to build both static and shared versions
-# at the same time. By default use shared for unit tests etc.
-# This choice is arbitrary.
-if libtype != 'shared'
-  libgst_static = static_library('gstreamer-1.0', gst_sources,
-    gstenum_h, gstenum_c, grammar, parser, gst_registry,
-    c_args : [libgst_c_args],
-    include_directories : [configinc,
-      # HACK, change include paths in .y and .l in final version.
-      include_directories('parse')],
-    install : true,
-    link_with : printf_lib,
-    dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib] + platform_deps,
-  )
-  libgst = libgst_static
+tracer_hooks = get_option('tracer_hooks')
+if not tracer_hooks
+  libgst_c_args += ['-DGST_DISABLE_GST_TRACER_HOOKS']
 endif
 
 # Make sure that subproject building gir files work
 gst_incdirs = [configinc]
 gst_gen_sources = [gstenum_h]
-if libtype != 'static'
-  libgst_shared = shared_library('gstreamer-1.0', gst_sources,
-    gstenum_h, gstenum_c, grammar, parser, gst_registry,
-    version : libversion,
-    soversion : soversion,
-    c_args : libgst_c_args,
-    include_directories : [configinc,
-      # HACK, change include paths in .y and .l in final version.
-      include_directories('parse')],
-    link_with : printf_lib,
-    install : true,
-    dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib] + platform_deps,
-    vs_module_defs: vs_module_defs_dir + 'libgstreamer.def',
-  )
-  libgst = libgst_shared
-  if build_gir
-    gst_gir_extra_args = gir_init_section + [ '--c-include=gst/gst.h' ]
-    if meson.is_subproject()
-      # FIXME: There must be a better way to do this
-      # Need to pass the include path to find gst/gst.h and gst/gstenumtypes.h (built)
-      gst_gir_extra_args += ['--cflags-begin',
-         '-I' + meson.current_source_dir() + '/..',
-         '-I' + meson.current_build_dir() + '/..',
-         '--cflags-end']
-    endif
+libgst = library('gstreamer-1.0', gst_sources,
+  gstenum_h, gstenum_c, gst_parse_sources, gst_registry_sources,
+  version : libversion,
+  soversion : soversion,
+  darwin_versions : osxversion,
+  c_args : libgst_c_args + ['-DBUILDING_GST'],
+  include_directories : [configinc,
+    # HACK, change include paths in .y and .l in final version.
+    include_directories('parse')],
+  link_with : printf_lib,
+  install : true,
+  dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib, dl_dep] + backtrace_deps
+                   + platform_deps,
+)
 
-    gst_incdirs += [include_directories(meson.current_build_dir() + '/..')]
-    gst_gen_sources += [gnome.generate_gir(libgst_shared,
-      sources : gst_sources + gst_headers,
-      namespace : 'Gst',
-      nsversion : apiversion,
-      identifier_prefix : 'Gst',
-      symbol_prefix : 'gst',
-      export_packages : 'gstreamer-1.0',
-      includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0' ],
-      install : true,
-      extra_args : gst_gir_extra_args,
-    )]
+if build_gir
+  gst_gir_extra_args = gir_init_section + [ '--c-include=gst/gst.h' ]
+  if meson.is_subproject()
+    # FIXME: There must be a better way to do this
+    # Need to pass the include path to find gst/gst.h and gst/gstenumtypes.h (built)
+    gst_gir_extra_args += ['--cflags-begin',
+      '-I' + meson.current_source_dir() + '/..',
+      '-I' + meson.current_build_dir() + '/..',
+      '--cflags-end']
   endif
+
+  gst_incdirs += [configinc]
+  gst_gen_sources += [gnome.generate_gir(libgst,
+    sources : gst_sources + gst_headers + gst_enums + [gst_version_h],
+    namespace : 'Gst',
+    nsversion : apiversion,
+    identifier_prefix : 'Gst',
+    symbol_prefix : 'gst',
+    export_packages : 'gstreamer-1.0',
+    includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0' ],
+    install : true,
+    extra_args : gst_gir_extra_args,
+  )]
+endif
+
+gst_compile_args = []
+if get_option('default_library') == 'static'
+  gst_compile_args += ['-DGST_STATIC_COMPILATION']
 endif
 
 gst_dep = declare_dependency(link_with : libgst,
+  compile_args : gst_compile_args,
   include_directories : gst_incdirs,
   dependencies : [glib_dep, gobject_dep, gmodule_dep],
   # Everything that uses libgst needs this built to compile
-  sources : [gst_gen_sources, gstenum_h],
+  sources : gst_gen_sources,
 )