cross-files/android: Update paths and args for latest NDK
[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   ['gst-plugins-rs', { 'option': get_option('rs'), 'has-plugins': true, 'match_gst_version': false}],
77 ]
78
79 symlink = '''
80 import os
81
82 os.symlink(os.path.join('@1@', 'subprojects', '@0@'),
83   os.path.join('@1@', '@0@'))
84 '''
85
86 if build_system == 'windows'
87   subproject('win-flex-bison-binaries')
88   subproject('win-nasm')
89 endif
90
91 pathsep = host_machine.system() == 'windows' ? ';' : ':'
92
93 subproject('orc', required: get_option('orc'))
94
95 subprojects_names = []
96 plugins_doc_caches = []
97 all_plugins = ''
98 foreach sp : subprojects
99   project_name = sp[0]
100   build_infos = sp[1]
101   is_required = build_infos.get('option', true)
102   match_gst_version = build_infos.get('match_gst_version', true)
103
104   if match_gst_version
105     subproj = subproject(project_name, version: gst_version, required: is_required)
106   else
107     subproj = subproject(project_name, required: is_required)
108   endif
109
110   if subproj.found()
111     # Replace by using subproject.get_variable('plugins', [])
112     # when https://github.com/mesonbuild/meson/pull/5426/files
113     # is merged and released
114     if build_infos.has_key('has-plugins', default: false)
115       plugins = subproj.get_variable('plugins')
116     else
117       plugins = []
118     endif
119
120     foreach plugin: plugins
121       all_plugins += pathsep + plugin.full_path()
122     endforeach
123
124     subprojects_names += [project_name]
125     cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
126     if cmdres.returncode() == 0
127       message('Created symlink to ' + project_name)
128     endif
129
130     if not meson.is_cross_build() and build_infos.has_key('build-hotdoc', default: false)
131       if plugins.length() > 0
132         plugins_doc_caches += [subproj.get_variable('plugins_doc_dep')]
133       endif
134       if documented_projects != ''
135         documented_projects += ','
136       endif
137       documented_projects  += project_name
138     endif
139   endif
140 endforeach
141
142 plugins_doc_dep = custom_target('plugins-doc-cache',
143   command: [python3, '-c', 'print("Built all doc caches")'],
144   input: plugins_doc_caches,
145   output: 'plugins_doc_caches',
146   capture: true,
147 )
148
149 foreach custom_subproj: get_option('custom_subprojects').split(',')
150     if custom_subproj != ''
151         message ('Adding custom subproject ' + custom_subproj)
152         subproject(custom_subproj)
153         subprojects_names += [custom_subproj]
154     endif
155 endforeach
156
157 if meson.is_cross_build() or build_machine.system() == 'windows'
158     if get_option('doc').enabled()
159         error('Documentation enabled but building the doc while cross building or building on windows is not supported yet.')
160     endif
161
162     message('Documentation not built as building the documentation while cross building or building on windows is not supported yet.')
163 else
164   hotdoc_p = find_program('hotdoc', required : get_option('doc'))
165   if hotdoc_p.found()
166     if documented_projects != ''
167         subproject('gst-docs', default_options: 'built_subprojects=' + documented_projects)
168       message('Gst docs subprojects: ' + documented_projects)
169     endif
170   else
171     message('Not building documentation as hotdoc was not found')
172   endif
173 endif
174
175 cmdres = run_command(python3, find_program('scripts/generate_plugins_path.py'), '--builddir',
176     meson.build_root(), all_plugins)
177 assert(cmdres.returncode() == 0, 'Could not create plugins path: @0@'.format(cmdres.stderr()))
178
179 message('Building subprojects: ' + ', '.join(subprojects_names))
180 setenv = find_program('gst-env.py')
181
182 devenv_cmd = [setenv, '--builddir=@0@'.format(meson.build_root()),
183               '--srcdir=@0@'.format(meson.source_root())]
184
185 if meson.has_exe_wrapper() and build_machine.system() == 'linux' and host_machine.system() == 'windows'
186   # FIXME: Ideally we could get the wrapper directly from meson
187   devenv_cmd += ['--wine', host_machine.cpu_family() == 'x86_64' ? 'wine64' : 'wine32']
188   sysroot = meson.get_cross_property('sys_root')
189   if sysroot != ''
190     # Logic from meson
191     devenv_cmd += ['--winepath', 'Z:' + join_paths(sysroot, 'bin')]
192   endif
193 endif
194
195 run_target('uninstalled', command : devenv_cmd)
196 run_target('devenv', command : devenv_cmd)
197
198 update = find_program('git-update')
199 run_target('git-update', command : [update])
200 run_target('update', command : [update,
201     '--builddir=@0@'.format(meson.current_build_dir())])