meson: Allow others to build GIR files when using GStreamer as subproject
[platform/upstream/gstreamer.git] / gst / meson.build
1 gst_sources = [
2   'gst.c',
3   'gstobject.c',
4   'gstallocator.c',
5   'gstbin.c',
6   'gstbuffer.c',
7   'gstbufferlist.c',
8   'gstbufferpool.c',
9   'gstbus.c',
10   'gstcaps.c',
11   'gstcapsfeatures.c',
12   'gstchildproxy.c',
13   'gstclock.c',
14   'gstclock-linreg.c',
15   'gstcontext.c',
16   'gstcontrolbinding.c',
17   'gstcontrolsource.c',
18   'gstdatetime.c',
19   'gstdebugutils.c',
20   'gstdevice.c',
21   'gstdeviceprovider.c',
22   'gstdeviceproviderfactory.c',
23   'gstelement.c',
24   'gstelementfactory.c',
25   'gsterror.c',
26   'gstevent.c',
27   'gstformat.c',
28   'gstghostpad.c',
29   'gstdevicemonitor.c',
30   'gstinfo.c',
31   'gstiterator.c',
32   'gstatomicqueue.c',
33   'gstmessage.c',
34   'gstmeta.c',
35   'gstmemory.c',
36   'gstminiobject.c',
37   'gstpad.c',
38   'gstpadtemplate.c',
39   'gstparamspecs.c',
40   'gstpipeline.c',
41   'gstplugin.c',
42   'gstpluginfeature.c',
43   'gstpluginloader.c',
44   'gstpoll.c',
45   'gstpreset.c',
46   'gstprotection.c',
47   'gstquark.c',
48   'gstquery.c',
49   'gstregistry.c',
50   'gstregistrychunks.c',
51   'gstsample.c',
52   'gstsegment.c',
53   'gststreamcollection.c',
54   'gststreams.c',
55   'gststructure.c',
56   'gstsystemclock.c',
57   'gsttaglist.c',
58   'gsttagsetter.c',
59   'gsttask.c',
60   'gsttaskpool.c',
61   'gsttoc.c',
62   'gsttocsetter.c',
63   'gsttracer.c',
64   'gsttracerfactory.c',
65   'gsttracerrecord.c',
66   'gsttracerutils.c',
67   'gsttypefind.c',
68   'gsttypefindfactory.c',
69   'gsturi.c',
70   'gstutils.c',
71   'gstvalue.c',
72   'gstparse.c',
73 ]
74
75 gst_headers = [
76   'gst.h',
77   'glib-compat.h',
78   'gstobject.h',
79   'gstallocator.h',
80   'gstbin.h',
81   'gstbuffer.h',
82   'gstbufferlist.h',
83   'gstbufferpool.h',
84   'gstbus.h',
85   'gstcaps.h',
86   'gstcapsfeatures.h',
87   'gstchildproxy.h',
88   'gstclock.h',
89   'gstcompat.h',
90   'gstcontext.h',
91   'gstcontrolbinding.h',
92   'gstcontrolsource.h',
93   'gstdatetime.h',
94   'gstdebugutils.h',
95   'gstelement.h',
96   'gstelementmetadata.h',
97   'gstdevice.h',
98   'gstdeviceprovider.h',
99   'gstdeviceproviderfactory.h',
100   'gstelementfactory.h',
101   'gsterror.h',
102   'gstevent.h',
103   'gstformat.h',
104   'gstghostpad.h',
105   'gstdevicemonitor.h',
106   'gstinfo.h',
107   'gstiterator.h',
108   'gstatomicqueue.h',
109   'gstmacros.h',
110   'gstmessage.h',
111   'gstmeta.h',
112   'gstmemory.h',
113   'gstminiobject.h',
114   'gstpad.h',
115   'gstpadtemplate.h',
116   'gstparamspecs.h',
117   'gstpipeline.h',
118   'gstplugin.h',
119   'gstpluginfeature.h',
120   'gstpoll.h',
121   'gstpreset.h',
122   'gstprotection.h',
123   'gstquery.h',
124   'gstsample.h',
125   'gstsegment.h',
126   'gststreamcollection.h',
127   'gststreams.h',
128   'gststructure.h',
129   'gstsystemclock.h',
130   'gsttaglist.h',
131   'gsttagsetter.h',
132   'gsttask.h',
133   'gsttaskpool.h',
134   'gsttoc.h',
135   'gsttocsetter.h',
136   'gsttracer.h',
137   'gsttracerfactory.h',
138   'gsttracerrecord.h',
139   'gsttypefind.h',
140   'gsttypefindfactory.h',
141   'gsturi.h',
142   'gstutils.h',
143   'gstvalue.h',
144   'gstregistry.h',
145   'gstparse.h',
146   'math-compat.h',
147 ]
148 install_headers(gst_headers, subdir : 'gstreamer-1.0/gst')
149
150 if not get_option('disable_registry')
151   gst_registry = ['gstregistrybinary.c']
152 else
153   gst_registry = []
154 endif
155
156 configure_file(input : 'gstconfig.h.in',
157   output : 'gstconfig.h',
158   install_dir : 'include/gstreamer-1.0/gst',
159   configuration : cdata)
160 configure_file(input : 'gstversion.h.in',
161   output : 'gstversion.h',
162   install_dir : 'include/gstreamer-1.0/gst',
163   configuration : cdata)
164
165 mkenums = find_program('build_mkenum.py')
166 glib_mkenums = find_program('glib-mkenums')
167
168 gstenum_h = custom_target('gstenum_h',
169   output : 'gstenumtypes.h',
170   input : gst_headers,
171   install : true,
172   install_dir : 'include/gstreamer-1.0/gst',
173   command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
174
175 gstenum_c = custom_target('gstenum_c',
176   output : 'gstenumtypes.c',
177   input : gst_headers,
178   depends : [gstenum_h],
179   command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
180
181 subdir('parse')
182 subdir('printf')
183
184 libgst_c_args = gst_c_args + [
185   '-D_GNU_SOURCE',
186   '-DGST_EXPORTS',
187   '-DG_LOG_DOMAIN=g_log_domain_gstreamer',
188   '-DGST_DISABLE_DEPRECATED',
189 ]
190
191 # Make it possible to build both static and shared versions
192 # at the same time. By default use shared for unit tests etc.
193 # This choice is arbitrary.
194 if libtype != 'shared'
195   libgst_static = static_library('gstreamer-1.0', gst_sources,
196     gstenum_h, gstenum_c, grammar, parser, gst_registry,
197     c_args : [libgst_c_args],
198     include_directories : [configinc,
199       # HACK, change include paths in .y and .l in final version.
200       include_directories('parse')],
201     install : true,
202     link_with : printf_lib,
203     dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib] + platform_deps,
204   )
205   libgst = libgst_static
206 endif
207
208 # Make sure that subproject building gir files work
209 gst_incdirs = [configinc]
210 gst_gen_sources = [gstenum_h]
211 if libtype != 'static'
212   libgst_shared = shared_library('gstreamer-1.0', gst_sources,
213     gstenum_h, gstenum_c, grammar, parser, gst_registry,
214     version : libversion,
215     soversion : soversion,
216     c_args : libgst_c_args,
217     include_directories : [configinc,
218       # HACK, change include paths in .y and .l in final version.
219       include_directories('parse')],
220     link_with : printf_lib,
221     install : true,
222     dependencies : [gobject_dep, gmodule_dep, glib_dep, mathlib] + platform_deps,
223     vs_module_defs: vs_module_defs_dir + 'libgstreamer.def',
224   )
225   libgst = libgst_shared
226   if build_gir
227     gst_gir_extra_args = gir_init_section + [ '--c-include=gst/gst.h' ]
228     if meson.is_subproject()
229       # FIXME: There must be a better way to do this
230       # Need to pass the include path to find gst/gst.h and gst/gstenumtypes.h (built)
231       gst_gir_extra_args += ['--cflags-begin',
232           '-I' + meson.current_source_dir() + '/..',
233           '-I' + meson.current_build_dir() + '/..',
234           '--cflags-end']
235     endif
236
237     gst_incdirs += [include_directories(meson.current_build_dir() + '/..')]
238     gst_gen_sources += [gnome.generate_gir(libgst_shared,
239       sources : gst_sources + gst_headers,
240       namespace : 'Gst',
241       nsversion : apiversion,
242       identifier_prefix : 'Gst',
243       symbol_prefix : 'gst',
244       export_packages : 'gstreamer-1.0',
245       includes : ['GLib-2.0', 'GObject-2.0', 'GModule-2.0' ],
246       install : true,
247       extra_args : gst_gir_extra_args,
248     )]
249   endif
250 endif
251
252 gst_dep = declare_dependency(link_with : libgst,
253   include_directories : gst_incdirs,
254   dependencies : [glib_dep, gobject_dep, gmodule_dep],
255   # Everything that uses libgst needs this built to compile
256   sources : gst_gen_sources,
257 )