gst-env: Set the prompt for fish to be same as bash
[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
47   # Change some warning which belong to level 3 (production quality) or
48   # 4 (informational) to level 1 (severe)
49   add_global_arguments (
50       '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
51       '/w14101', # 'identifier' : unreferenced local variable
52       '/w14189', # 'identifier' : local variable is initialized but not referenced
53       cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
54       language: 'c')
55 endif
56
57 # Ordered list of subprojects (dict has no ordering guarantees)
58 subprojects = [
59   ['gstreamer', {'build-hotdoc': true, 'has-plugins': true}],
60   ['gst-plugins-base', {'build-hotdoc': true, 'has-plugins': true}],
61   ['gst-plugins-good', {'build-hotdoc': true, 'has-plugins': true}],
62   ['libnice', { 'option': get_option('libnice'), 'match_gst_version': false}],
63   ['gst-plugins-bad', { 'option': get_option('bad'), 'build-hotdoc': true, 'has-plugins': true}],
64   ['gst-plugins-ugly', { 'option': get_option('ugly'), 'build-hotdoc': true, 'has-plugins': true}],
65   ['gst-libav', { 'option': get_option('libav'), 'build-hotdoc': true, 'has-plugins': true}],
66   ['gst-rtsp-server', { 'option': get_option('rtsp_server'), 'build-hotdoc': true }],
67   ['gst-devtools', { 'option': get_option('devtools'), 'build-hotdoc': true }],
68   ['gst-integration-testsuites', { 'option': get_option('devtools') }],
69   ['gst-editing-services', { 'option': get_option('ges'), 'build-hotdoc': true, 'has-plugins': true}],
70   ['gstreamer-vaapi', { 'option': get_option('vaapi'), 'build-hotdoc': true, 'has-plugins': true}],
71   ['gst-omx', { 'option': get_option('omx'), 'build-hotdoc': true, 'has-plugins': true}],
72   ['gstreamer-sharp', { 'option': get_option('sharp') }],
73   ['pygobject', { 'option': get_option('python'), 'match_gst_version': false }],
74   ['gst-python', { 'option': get_option('python'), 'has-plugins': true}],
75   ['gst-examples', { 'option': get_option('gst-examples'), 'match_gst_versions': false}],
76 ]
77
78 symlink = '''
79 import os
80
81 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
82   os.path.join('@1@', '@0@'))
83 '''
84
85 if build_system == 'windows'
86   subproject('win-flex-bison-binaries')
87   subproject('win-nasm')
88 endif
89
90 pathsep = host_machine.system() == 'windows' ? ';' : ':'
91
92 subproject('orc', required: get_option('orc'))
93
94 subprojects_names = []
95 plugins_doc_caches = []
96 all_plugins = ''
97 foreach sp : subprojects
98   project_name = sp[0]
99   build_infos = sp[1]
100   is_required = build_infos.get('option', true)
101   match_gst_version = build_infos.get('match_gst_version', true)
102
103   if match_gst_version
104     subproj = subproject(project_name, version: gst_version, required: is_required)
105   else
106     subproj = subproject(project_name, required: is_required)
107   endif
108
109   if subproj.found()
110     # Replace by using subproject.get_variable('plugins', [])
111     # when https://github.com/mesonbuild/meson/pull/5426/files
112     # is merged and released
113     if build_infos.has_key('has-plugins', default: false)
114       plugins = subproj.get_variable('plugins')
115     else
116       plugins = []
117     endif
118
119     foreach plugin: plugins
120       all_plugins += pathsep + plugin.full_path()
121     endforeach
122
123     subprojects_names += [project_name]
124     cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
125     if cmdres.returncode() == 0
126       message('Created symlink to ' + project_name)
127     endif
128
129     if not meson.is_cross_build() and build_infos.has_key('build-hotdoc', default: false)
130       if plugins.length() > 0
131         plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
132       endif
133       if documented_projects != ''
134         documented_projects += ','
135       endif
136       documented_projects  += project_name
137     endif
138   endif
139 endforeach
140
141 plugins_doc_dep = custom_target('plugins-doc-cache',
142   command: [python3, '-c', 'print("Built all doc caches")'],
143   input: plugins_doc_caches,
144   output: 'plugins_doc_caches',
145   capture: true,
146 )
147
148 foreach custom_subproj: get_option('custom_subprojects').split(',')
149     if custom_subproj != ''
150         message ('Adding custom subproject ' + custom_subproj)
151         subproject(custom_subproj)
152         subprojects_names += [custom_subproj]
153     endif
154 endforeach
155
156 if meson.is_cross_build() or build_machine.system() == 'windows'
157     if get_option('doc').enabled()
158         error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
159     endif
160
161     message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
162 else
163   hotdoc_p = find_program('hotdoc', required : get_option('doc'))
164   if hotdoc_p.found()
165     if documented_projects != ''
166         subproject('gst-docs', default_options: 'built_subprojects=' + documented_projects)
167       message('Gst docs subprojects: ' + documented_projects)
168     endif
169   else
170     message('Not building documentation as hotdoc was not found')
171   endif
172 endif
173
174 cmdres = run_command(python3, find_program('scripts/generate_plugins_path.py'), '--builddir',
175     meson.build_root(), all_plugins)
176 assert(cmdres.returncode() == 0, 'Could not create plugins path: @0@'.format(cmdres.stderr()))
177
178 message('Building subprojects: ' + ', '.join(subprojects_names))
179 setenv = find_program('gst-env.py')
180
181 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
182               '--srcdir=@0@'.format(meson.source_root())]
183
184 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
185   # FIXME: Ideally we could get the wrapper directly from meson
186   devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
187   sysroot = meson.get_cross_property('sys_root')
188   if sysroot != ''
189     # Logic from meson
190     devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
191   endif
192 endif
193
194 run_target('uninstalled', command : devenv_cmd)
195 run_target('devenv', command : devenv_cmd)
196
197 update = find_program('git-update')
198 run_target('git-update', command : [update])
199 run_target('update', command : [update,
200     '--builddir=@0@'.format(meson.current_build_dir())])