Update the flexmeson windows binary version
[platform/upstream/gstreamer.git] / meson.build
1 project('All GStreamer modules', 'c',
2   version : '1.17.0.1',
3   meson_version : '>= 0.48.0',
4   default_options : ['buildtype=debugoptimized'])
5
6 gst_version = '>= @0@'.format(meson.project_version())
7 gst_branch = 'master'
8
9 glib_req = '>= 2.44.0'
10
11 build_system = build_machine.system()
12 cc = meson.get_compiler('c')
13
14 python3 = import('python').find_installation()
15 # Ensure that we're not being run from inside the gst-uninstalled env
16 # because that will confuse meson, and it might find the already-built
17 # gstreamer. It's fine if people run `ninja` as long as it doesn't run
18 # reconfigure because ninja doesn't care about the env.
19 ensure_not_uninstalled = '''
20 import os
21 assert('GST_ENV' not in os.environ)
22 '''
23 cmdres = run_command(python3, '-c', ensure_not_uninstalled)
24 if cmdres.returncode() != 0
25   error('Do not run `ninja` or `meson` for gst-build inside the uninstalled environment, you will run into problems')
26 endif
27
28 documented_projects = ''
29 # Make it possible to use msys2 built zlib which fails
30 # when not using the mingw toolchain as it uses unistd.h
31 if not meson.is_subproject() and cc.get_id() == 'msvc'
32   uname = find_program('uname', required: false)
33   if uname.found()
34     ret = run_command(uname, '-o')
35     if ret.returncode() == 0 and ret.stdout().to_lower() == 'msys'
36       ret = run_command(uname, '-r')
37       # The kernel version returned by uname is actually the msys version
38       if ret.returncode() == 0 and ret.stdout().startswith('2')
39         # If a system zlib is found, disable UNIX features in zlib.h and zconf.h
40         if cc.find_library('z').found()
41           add_global_arguments('-DZ_SOLO', language: 'c')
42         endif
43       endif
44     endif
45   endif
46 endif
47
48 # Ordered list of subprojects (dict has no ordering guarantees)
49 subprojects = [
50   ['gstreamer', {'build-hotdoc': true, 'has-plugins': true}],
51   ['gst-plugins-base', {'build-hotdoc': true, 'has-plugins': true}],
52   ['gst-plugins-good', {'build-hotdoc': true, 'has-plugins': true}],
53   ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
54   ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true, 'has-plugins': true}],
55   ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true, 'has-plugins': true}],
56   ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true, 'has-plugins': true}],
57   ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true }],
58   ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
59   ['gst-integration-testsuites', { 'option': get_option('devtools') }],
60   ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true, 'has-plugins': true}],
61   ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true, 'has-plugins': true}],
62   ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true, 'has-plugins': true}],
63   ['gstreamer-sharp', { 'option': get_option('sharp') }],
64   ['pygobject', { 'option': get_option('python'), 'match_gst_version': false }],
65   ['gst-python', { 'option': get_option('python'), 'has-plugins': true}],
66   ['gst-examples', { 'option': get_option('examples'), 'match_gst_versions': false}],
67 ]
68
69 symlink = '''
70 import os
71
72 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
73   os.path.join('@1@', '@0@'))
74 '''
75
76 if build_system == 'windows'
77   subproject('win-flex-bison-binaries')
78   subproject('win-nasm')
79 endif
80
81 pathsep = host_machine.system() == 'windows' ? ';' : ':'
82
83 subproject('orc', required: get_option('orc'))
84
85 subprojects_names = []
86 plugins_doc_caches = []
87 all_plugins = ''
88 foreach sp : subprojects
89   project_name = sp[0]
90   build_infos = sp[1]
91   is_required = build_infos.get('option', true)
92   match_gst_version = build_infos.get('match_gst_version', true)
93
94   if match_gst_version
95     subproj = subproject(project_name, version: gst_version, required: is_required)
96   else
97     subproj = subproject(project_name, required: is_required)
98   endif
99
100   if subproj.found()
101     # Replace by using subproject.get_variable('plugins', [])
102     # when https://github.com/mesonbuild/meson/pull/5426/files
103     # is merged and released
104     if build_infos.has_key('has-plugins', default: false)
105       plugins = subproj.get_variable('plugins')
106     else
107       plugins = []
108     endif
109
110     foreach plugin: plugins
111       all_plugins += pathsep + plugin.full_path()
112     endforeach
113
114     subprojects_names += [project_name]
115     cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
116     if cmdres.returncode() == 0
117       message('Created symlink to ' + project_name)
118     endif
119
120     if not meson.is_cross_build() and build_infos.has_key('build-hotdoc', default: false)
121       if plugins.length() > 0
122         plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
123       endif
124       if documented_projects != ''
125         documented_projects += ','
126       endif
127       documented_projects  += project_name
128     endif
129   endif
130 endforeach
131
132 plugins_doc_dep = custom_target('plugins-doc-cache',
133   command: [python3, '-c', 'print("Built all doc caches")'],
134   input: plugins_doc_caches,
135   output: 'plugins_doc_caches',
136   capture: true,
137 )
138
139 foreach custom_subproj: get_option('custom_subprojects').split(',')
140     if custom_subproj != ''
141         message ('Adding custom subproject ' + custom_subproj)
142         subproject(custom_subproj)
143         subprojects_names += [custom_subproj]
144     endif
145 endforeach
146
147 if meson.is_cross_build() or build_machine.system() == 'windows'
148     if get_option('doc').enabled()
149         error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
150     endif
151
152     message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
153 else
154   hotdoc_p = find_program('hotdoc', required : get_option('doc'))
155   if hotdoc_p.found()
156     if documented_projects != ''
157         subproject('gst-docs', default_options: 'built_subprojects=' + documented_projects)
158       message('Gst docs subprojects: ' + documented_projects)
159     endif
160   else
161     message('Not building documentation as hotdoc was not found')
162   endif
163 endif
164
165 cmdres = run_command(python3, find_program('scripts/generate_plugins_path.py'), '--builddir',
166     meson.build_root(), all_plugins)
167 assert(cmdres.returncode() == 0, 'Could not create plugins path: @0@'.format(cmdres.stderr()))
168
169 message('Building subprojects: ' + ', '.join(subprojects_names))
170 setenv = find_program('gst-uninstalled.py')
171 run_target('uninstalled', command : [setenv, '--builddir=@0@'.format(meson.build_root()),
172            '--srcdir=@0@'.format(meson.source_root())])
173
174 update = find_program('git-update')
175 run_target('git-update', command : [update])
176 run_target('update', command : [update,
177     '--builddir=@0@'.format(meson.current_build_dir())])