Back to development
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / meson.build
1 project('gstreamer-sharp', ['cs', 'c'], version: '1.22.2.1',
2     meson_version : '>= 0.62', license: 'LGPL')
3
4 if host_machine.system() == 'osx'
5   lib_prefix=''
6   lib_suffix='.dylib'
7 else
8   lib_prefix='.so'
9   lib_suffix=''
10 endif
11
12 gtk_sharp_required_version = '>=3.22.6'
13
14 csc = meson.get_compiler('cs')
15 if csc.get_id() == 'mono'
16     add_project_arguments('-keyfile:' + join_paths(meson.current_source_dir(), meson.project_name() + '.snk'),
17         language: ['cs'])
18 endif
19
20
21 subproject('gtk-sharp', default_options: ['install=false'])
22 gtk_sharp = subproject('gtk-sharp')
23
24 glib_sharp_dep = gtk_sharp.get_variable('glib_sharp_dep')
25 glib_sharp = gtk_sharp.get_variable('glib_sharp')
26
27 gio_sharp_dep = gtk_sharp.get_variable('gio_sharp_dep')
28 gio_sharp = gtk_sharp.get_variable('gio_sharp')
29
30 gapi_fixup = gtk_sharp.get_variable('gapi_fixup')
31 gapi_codegen = gtk_sharp.get_variable('gapi_codegen')
32
33 glib_api_includes = gtk_sharp.get_variable('glib_api_includes')
34 gio_api_includes = gtk_sharp.get_variable('gio_api_includes')
35 has_gtk = gtk_sharp.get_variable('has_gtk')
36 if has_gtk
37   gtk_sharp_dep = [gtk_sharp.get_variable('gtk_sharp_dep'),
38     gtk_sharp.get_variable('atk_sharp_dep')]
39 else
40   gtk_sharp_dep = dependency('gtk-sharp-3.0', version: gtk_sharp_required_version,
41       required: false)
42 endif
43
44 mono_path = [gtk_sharp.get_variable('mono_path'), join_paths(meson.current_build_dir(), 'sources')]
45
46 codegen_dependencies = [gapi_codegen, gapi_fixup, glib_sharp, gio_sharp]
47 gapi_fixup = gapi_fixup.full_path()
48 gapi_codegen = gapi_codegen.full_path()
49
50 gacutil = find_program('gacutil')
51 generate_api = find_program('generate_code.py')
52 nuget = find_program('nuget.py')
53 diff = find_program('Tests/test_abi.py')
54
55 # TODO Handle monodoc
56
57 apiversion = '1.0'
58 gst_required_version = '>=@0@'.format(meson.project_version())
59 gst_deps = []
60
61 # dependency name, [subproject-name, internal-dep-name, library-name']
62 gst_deps_defs = [
63   ['gstreamer', ['gstreamer', 'gst_dep'], 'libgst'],
64   ['gstreamer-app', ['gst-plugins-base', 'app_dep'], 'gstapp'],
65   ['gstreamer-audio', ['gst-plugins-base', 'audio_dep'], 'gstaudio'],
66   ['gstreamer-base', ['gstreamer', 'gst_base_dep'], 'gst_base'],
67   ['gstreamer-controller', ['gstreamer', 'gst_controller_dep'], 'gst_controller'],
68   ['gstreamer-fft', ['gst-plugins-base', 'fft_dep'], 'gstfft'],
69   ['gstreamer-net', ['gstreamer', 'gst_net_dep'], 'gst_net'],
70   ['gstreamer-pbutils', ['gst-plugins-base', 'pbutils_dep'], 'pbutils'],
71   ['gstreamer-riff', ['gst-plugins-base', 'riff_dep'], 'gstriff'],
72   ['gstreamer-rtp', ['gst-plugins-base', 'rtp_dep'], 'gst_rtp'],
73   ['gstreamer-rtsp', ['gst-plugins-base', 'rtsp_dep'], 'gst_rtsp'],
74   ['gstreamer-sdp', ['gst-plugins-base', 'sdp_dep'], 'gstsdp'],
75   ['gstreamer-tag', ['gst-plugins-base', 'tag_dep'], 'gsttag'],
76   ['gstreamer-video', ['gst-plugins-base', 'video_dep'], 'gstvideo'],
77   ['gstreamer-webrtc', ['gst-plugins-bad', 'gstwebrtc_dep'], 'gstwebrtc'],
78 ]
79
80 foreach dep: gst_deps_defs
81   gst_deps += [dependency(dep.get(0) + '-' + apiversion, version: gst_required_version,
82     fallback: dep.get(1))]
83 endforeach
84
85 ges_dep = dependency('gst-editing-services-' + apiversion, version: gst_required_version,
86     fallback: ['gst-editing-services', 'ges_dep'], required: false)
87
88 if ges_dep.found()
89     gst_deps_defs +=  [
90         ['gst-editing-services', ['gst-editing-services', 'ges_dep'], 'libges'],
91     ]
92     mono_path += [join_paths(meson.current_build_dir(), 'ges')]
93 endif
94
95 testsenv = environment()
96 testsenv.prepend('MONO_PATH', mono_path)
97 i = 0
98 testsenv_ld_library_path = []
99 foreach dep: gst_deps + [ges_dep]
100     if dep.type_name() == 'pkgconfig'
101         testsenv_ld_library_path += [dep.get_variable('libdir')]
102     else
103         depdef = gst_deps_defs[i][1]
104         libname = gst_deps_defs[i].get(2, '')
105         if libname != ''
106             proj = subproject(depdef[0])
107             libpath = proj.get_variable(libname).full_path().split('/')
108             dirname = ''
109             j = 1
110             foreach comp: libpath
111                 if j < libpath.length()
112                     dirname += '/' + comp
113                 endif
114                 j += 1
115             endforeach
116             testsenv_ld_library_path += [dirname]
117         endif
118     endif
119     i += 1
120 endforeach
121 # FIXME: port this to macOS and Windows
122 testsenv.prepend('LD_LIBRARY_PATH', testsenv_ld_library_path)
123
124 subdir('sources')
125 if ges_dep.found()
126   subdir('ges')
127   custom_target('GESSharp-nuget',
128       command: [nuget, '--package-name', 'GESSharp',
129           '--assembly', ges_sharp.full_path(),
130           '--dependency=GstSharp:' + meson.project_version(),
131           '--project-url', 'https://gstreamer.freedesktop.org/modules/gstreamer-sharp.html',
132           '--icon-url', 'https://gstreamer.freedesktop.org/images/header-logo-top.png',
133           '--license-url', 'https://cgit.freedesktop.org/gstreamer/gstreamer-sharp/plain/COPYING',
134           '--version', meson.project_version(),
135           '--tags', 'GStreamer GES GstSharp bindings',
136           '--builddir', meson.current_build_dir(),
137           '--dependency', 'GstSharp:' + meson.project_version(),
138       ],
139       output: 'GESSharp.' + meson.project_version() + '.nupkg'
140   )
141 endif
142
143 custom_target('GstSharp-nuget',
144     command: [nuget, '--package-name', 'GstSharp',
145         '--assembly', gst_sharp.full_path(),
146         '--assembly', gio_sharp.full_path(),
147         '--assembly', glib_sharp.full_path(),
148         '--project-url', 'https://gstreamer.freedesktop.org/modules/gstreamer-sharp.html',
149         '--icon-url', 'https://gstreamer.freedesktop.org/images/header-logo-top.png',
150         '--license-url', 'https://cgit.freedesktop.org/gstreamer/gstreamer-sharp/plain/COPYING',
151         '--version', meson.project_version(),
152         '--tags', 'GStreamer GstSharp bindings',
153         '--builddir', meson.current_build_dir(),
154     ],
155     output: 'GstSharp.' + meson.project_version() + '.nupkg',
156 )
157
158 subdir('samples')
159 subdir('Tests')
160
161 bindinator = subproject('bindinator', default_options: ['gapi_fixup=@0@'.format(gapi_fixup)])
162 if bindinator.get_variable('found')
163     bindinate = bindinator.get_variable('bindinate')
164     run_target('bindinate_gstreamer',
165         command: [bindinate,
166             '--name=gstreamer', '--regenerate=true',
167             '--merge-with=GstApp-1.0,GstAudio-1.0,GstBase-1.0,GstController-1.0,GstNet-1.0,GstPbutils-1.0,GstRtp-1.0,GstRtsp-1.0,GstSdp-1.0,GstTag-1.0,GstVideo-1.0,GstWebRTC-1.0',
168             '--gir=Gst-1.0',
169             '--copy-girs=@0@'.format(join_paths(meson.current_source_dir(), 'girs'))],
170         depends: []
171     )
172     run_target('bindinate_ges',
173         command: ['sh', '-c',
174             '''@0@ --name=gst-editing-services --regenerate=true --gir=GES-1.0 && mv @1@/sources/gst-editing-services-sharp-api.raw @1@/ges/gst-editing-services-api.raw '''.format(
175             bindinate.path(),
176             meson.current_source_dir()),
177         ],
178         depends: []
179     )
180     python3 = import('python3').find_python()
181     run_target('update-code', command: [find_program('update_sources.py')])
182     run_target('update-all', command: [find_program('update_sources.py'), 'bindinate'])
183 else
184     warning('Bindinator not usable as some required dependencies are not avalaible.')
185 endif
186
187 meson.add_dist_script('scripts/gen-changelog.py', meson.project_name(), '1.20.0', meson.project_version())