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