Add a way to simply update sources and document it
[platform/upstream/gstreamer.git] / meson.build
1 project('gstreamer-sharp', ['cs', 'c'], version: '1.13.0.1',
2     meson_version: '>0.42', 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 if host_machine.system() == 'windows'
45     pathsep = ';'
46 else
47     pathsep = ':'
48 endif
49 mono_path = gtk_sharp.get_variable('mono_path') + pathsep
50 mono_path += pathsep + join_paths(meson.current_build_dir(), 'sources')
51
52 codegen_dependencies = [gapi_codegen, gapi_fixup, glib_sharp, gio_sharp]
53 gapi_fixup = gapi_fixup.full_path()
54 gapi_codegen = gapi_codegen.full_path()
55
56 gacutil = find_program('gacutil')
57 generate_api = find_program('generate_code.py')
58 nuget = find_program('nuget.py')
59 diff = find_program('Tests/test_abi.py')
60
61 # TODO Handle monodoc
62
63 apiversion = '1.0'
64 gst_required_version = '>=@0@'.format(meson.project_version())
65 gst_deps = []
66
67 # dependency name, [subproject-name, internal-dep-name, library-name']
68 gst_deps_defs = [
69   ['gstreamer', ['gstreamer', 'gst_dep'], 'libgst'],
70   ['gstreamer-app', ['gst-plugins-base', 'app_dep'], 'gstapp'],
71   ['gstreamer-audio', ['gst-plugins-base', 'audio_dep'], 'gstaudio'],
72   ['gstreamer-base', ['gstreamer', 'gst_base_dep'], 'gst_base'],
73   ['gstreamer-controller', ['gstreamer', 'gst_controller_dep'], 'gst_controller'],
74   ['gstreamer-fft', ['gst-plugins-base', 'fft_dep'], 'gstfft'],
75   ['gstreamer-net', ['gstreamer', 'gst_net_dep'], 'gst_net'],
76   ['gstreamer-pbutils', ['gst-plugins-base', 'pbutils_dep'], 'pbutils'],
77   ['gstreamer-riff', ['gst-plugins-base', 'riff_dep'], 'gstriff'],
78   ['gstreamer-rtp', ['gst-plugins-base', 'rtp_dep'], 'gst_rtp'],
79   ['gstreamer-rtsp', ['gst-plugins-base', 'rtsp_dep'], 'gst_rtsp'],
80   ['gstreamer-sdp', ['gst-plugins-base', 'sdp_dep'], 'gstsdp'],
81   ['gstreamer-tag', ['gst-plugins-base', 'tag_dep'], 'gsttag'],
82   ['gstreamer-video', ['gst-plugins-base', 'video_dep'], 'gstvideo'],]
83
84 foreach dep: gst_deps_defs
85   gst_deps += [dependency(dep.get(0) + '-' + apiversion, version: gst_required_version,
86     fallback: dep.get(1))]
87 endforeach
88
89 ges_dep = dependency('gst-editing-services-' + apiversion, version: gst_required_version,
90     fallback: ['gst-editing-services', 'ges_dep'])
91
92 if ges_dep.found()
93     gst_deps_defs +=  [
94         ['gst-editing-services', ['gst-editing-services', 'ges_dep'], 'libges'],
95     ]
96     mono_path += pathsep + join_paths(meson.current_build_dir(), 'ges')
97 endif
98
99 testsenv = environment()
100 testsenv.prepend('MONO_PATH', mono_path)
101 i = 0
102 foreach dep: gst_deps + [ges_dep]
103     if dep.type_name() == 'pkgconfig'
104         testsenv.prepend('LD_LIBRARY_PATH', dep.get_pkgconfig_variable('libdir'))
105     else
106         depdef = gst_deps_defs[i][1]
107         libname = gst_deps_defs[i].get(2, '')
108         if libname != ''
109             proj = subproject(depdef[0])
110             libpath = proj.get_variable(libname).full_path().split('/')
111             dirname = ''
112             j = 1
113             foreach comp: libpath
114                 if j < libpath.length()
115                     dirname += '/' + comp
116                 endif
117                 j += 1
118             endforeach
119             testsenv.prepend('LD_LIBRARY_PATH', dirname)
120         endif
121     endif
122     i += 1
123 endforeach
124
125 subdir('sources')
126 if ges_dep.found()
127   subdir('ges')
128   custom_target('GESSharp-nuget',
129       command: [nuget, '--package-name', 'GESSharp',
130           '--assembly', ges_sharp.full_path(),
131           '--dependency=GstSharp:' + meson.project_version(),
132           '--project-url', 'https://gstreamer.freedesktop.org/modules/gstreamer-sharp.html',
133           '--icon-url', 'https://gstreamer.freedesktop.org/images/header-logo-top.png',
134           '--license-url', 'https://cgit.freedesktop.org/gstreamer/gstreamer-sharp/plain/COPYING',
135           '--version', meson.project_version(),
136           '--tags', 'GStreamer GES GstSharp bindings',
137           '--builddir', meson.current_build_dir(),
138           '--dependency', 'GstSharp:' + meson.project_version(),
139       ],
140       output: 'GESSharp.' + meson.project_version() + '.nupkg'
141   )
142 endif
143
144 custom_target('GstSharp-nuget',
145     command: [nuget, '--package-name', 'GstSharp',
146         '--assembly', gst_sharp.full_path(),
147         '--assembly', gio_sharp.full_path(),
148         '--assembly', glib_sharp.full_path(),
149         '--project-url', 'https://gstreamer.freedesktop.org/modules/gstreamer-sharp.html',
150         '--icon-url', 'https://gstreamer.freedesktop.org/images/header-logo-top.png',
151         '--license-url', 'https://cgit.freedesktop.org/gstreamer/gstreamer-sharp/plain/COPYING',
152         '--version', meson.project_version(),
153         '--tags', 'GStreamer GstSharp bindings',
154         '--builddir', meson.current_build_dir(),
155     ],
156     output: 'GstSharp.' + meson.project_version() + '.nupkg',
157 )
158
159 subdir('samples')
160
161 bindinate = find_program('bindinate', required: false)
162 if bindinate.found()
163   run_target('bindinate_gstreamer',
164     command: [bindinate,
165       '--name=gstreamer', '--regenerate=true',
166       '--merge-with=GstApp-1.0,GstAudio-1.0,GstBase-1.0,GstController-1.0,GstFft-1.0,GstNet-1.0,GstPbutils-1.0,GstRiff-1.0,GstRtp-1.0,GstRtsp-1.0,GstSdp-1.0,GstTag-1.0,GstVideo-1.0',
167       '--gir=Gst-1.0']
168     )
169   run_target('bindinate_ges',
170     command: ['sh', '-c',
171       '''bindinate --name=gst-editing-services --regenerate=true --gir=GES-1.0 && mv @0@/sources/gst-editing-services-sharp-api.raw @0@/ges/gst-editing-services-api.raw '''.format(
172         meson.current_source_dir())
173     ]
174   )
175   python3 = import('python3').find_python()
176   run_target('update-code', command: [find_program('update_sources.py')])
177   run_target('update-all', command: [find_program('update_sources.py'), 'bindinate'])
178 endif
179