egl/wgl: Support eglWaitNative
[platform/upstream/mesa.git] / src / egl / meson.build
1 # Copyright © 2017-2019 Intel Corporation
2
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 # SOFTWARE.
20
21 inc_egl = include_directories('.', 'main')
22 inc_egl_dri2 = include_directories('drivers/dri2')
23
24 c_args_for_egl = [asan_c_args]
25 cpp_args_for_egl = []
26 link_for_egl = []
27 deps_for_egl = []
28 incs_for_egl = [inc_include, inc_src, inc_egl]
29
30 files_egl = files(
31   'main/eglapi.c',
32   'main/eglarray.c',
33   'main/eglarray.h',
34   'main/eglconfigdebug.c',
35   'main/eglconfigdebug.h',
36   'main/eglconfig.c',
37   'main/eglconfig.h',
38   'main/eglcontext.c',
39   'main/eglcontext.h',
40   'main/eglcurrent.c',
41   'main/eglcurrent.h',
42   'main/egldefines.h',
43   'main/egldevice.c',
44   'main/egldevice.h',
45   'main/egldisplay.c',
46   'main/egldisplay.h',
47   'main/egldriver.h',
48   'main/eglglobals.c',
49   'main/eglglobals.h',
50   'main/eglimage.c',
51   'main/eglimage.h',
52   'main/egllog.c',
53   'main/egllog.h',
54   'main/eglsurface.c',
55   'main/eglsurface.h',
56   'main/eglsync.c',
57   'main/eglsync.h',
58   'main/eglentrypoint.h',
59   'main/egltypedefs.h',
60 )
61
62 g_egldispatchstubs_c = custom_target(
63   'g_egldispatchstubs.c',
64   input : [
65     'generate/gen_egl_dispatch.py',
66     'generate/egl.xml', 'generate/egl_other.xml'
67   ],
68   output : 'g_egldispatchstubs.c',
69   command : [
70     prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@',
71   ],
72   depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
73   capture : true,
74 )
75
76 g_egldispatchstubs_h = custom_target(
77   'g_egldispatchstubs.h',
78   input : [
79     'generate/gen_egl_dispatch.py',
80     'generate/egl.xml', 'generate/egl_other.xml'
81   ],
82   output : 'g_egldispatchstubs.h',
83   command : [
84     prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@',
85   ],
86   depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
87   capture : true,
88 )
89
90 if with_dri2
91   files_egl += files(
92     'drivers/dri2/egl_dri2.c',
93     'drivers/dri2/egl_dri2.h',
94   )
95   deps_for_egl += idep_xmlconfig
96   link_for_egl += libloader
97   incs_for_egl += inc_loader
98
99   files_egl += files(
100     'drivers/dri2/platform_device.c',
101     'drivers/dri2/platform_surfaceless.c',
102   )
103   if with_platform_x11
104     files_egl += files('drivers/dri2/platform_x11.c')
105     if with_dri3
106       files_egl += files('drivers/dri2/platform_x11_dri3.c')
107       link_for_egl += libloader_dri3_helper
108     endif
109     deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xrandr, dep_xcb_xfixes]
110   endif
111   if with_gbm and not with_platform_android
112     files_egl += files('drivers/dri2/platform_drm.c')
113     link_for_egl += libgbm
114     incs_for_egl += [inc_gbm, include_directories('../gbm/main')]
115     deps_for_egl += dep_libdrm
116   endif
117   if with_platform_wayland
118     deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
119     link_for_egl += libwayland_drm
120     files_egl += files('drivers/dri2/platform_wayland.c')
121     files_egl += [
122       linux_dmabuf_unstable_v1_protocol_c,
123       linux_dmabuf_unstable_v1_client_protocol_h,
124       wayland_drm_client_protocol_h,
125     ]
126     incs_for_egl += include_directories('wayland/wayland-drm')
127   endif
128   if with_platform_android
129     deps_for_egl += dep_android
130     files_egl += files('drivers/dri2/platform_android.c')
131     if dep_android_mapper4.found()
132       files_egl += files('drivers/dri2/platform_android_mapper.cpp')
133       c_args_for_egl += '-DUSE_IMAPPER4_METADATA_API'
134       cpp_args_for_egl += ['-std=c++17', '-DUSE_IMAPPER4_METADATA_API']
135     endif
136   endif
137 elif with_platform_haiku
138   incs_for_egl += inc_haikugl
139   c_args_for_egl += [
140     '-D_EGL_BUILT_IN_DRIVER_HAIKU',
141   ]
142   files_egl += files('drivers/haiku/egl_haiku.cpp')
143   link_for_egl += libgl
144   deps_for_egl += cpp.find_library('be')
145 elif with_platform_windows
146   c_args_for_egl += [
147     '-DEGLAPI=', '-DPUBLIC='
148   ]
149   files_egl += files('drivers/wgl/egl_wgl.c')
150   incs_for_egl += [inc_wgl, inc_gallium, inc_gallium_aux]
151   link_for_egl += libgallium_wgl
152 endif
153
154 if cc.has_function('mincore')
155   c_args_for_egl += '-DHAVE_MINCORE'
156 endif
157
158 if not with_glvnd
159   egl_lib_name = 'EGL' + get_option('egl-lib-suffix')
160   egl_lib_version = '1.0.0'
161   egl_lib_soversion = host_machine.system() == 'windows' ? '' : '1'
162 else
163   egl_lib_name = 'EGL_@0@'.format(glvnd_vendor_name)
164   egl_lib_version = '0.0.0'
165   egl_lib_soversion = '0'
166   deps_for_egl += dep_glvnd
167   files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
168   files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
169   glvnd_config = configuration_data()
170   glvnd_config.set('glvnd_vendor_name', get_option('glvnd-vendor-name'))
171   configure_file(
172     configuration: glvnd_config,
173     input : 'main/50_mesa.json',
174     output: '50_@0@.json'.format(glvnd_vendor_name),
175     install : true,
176     install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
177   )
178 endif
179
180 egl_def = custom_target(
181   'egl.def',
182   input: 'main/egl.def.in',
183   output : 'egl.def',
184   command : [prog_python, gen_vs_module_defs_py,
185              '--in_file', '@INPUT@', '--out_file', '@OUTPUT@',
186              '--compiler_id', cc.get_argument_syntax(), '--cpu_family', host_machine.cpu_family()]
187 )
188
189 libegl = shared_library(
190   egl_lib_name,
191   files_egl,
192   c_args : [
193     c_args_for_egl,
194     '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
195   ],
196   cpp_args : [cpp_args_for_egl],
197   gnu_symbol_visibility : 'hidden',
198   include_directories : incs_for_egl,
199   link_with : [link_for_egl, libglapi],
200   link_args : [ld_args_bsymbolic, ld_args_gc_sections],
201   dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread, idep_mesautil],
202   install : true,
203   version : egl_lib_version,
204   soversion : egl_lib_soversion,
205   name_prefix : 'lib', # even on windows
206   vs_module_defs : egl_def
207 )
208
209 if not with_glvnd
210   pkg.generate(
211     name : 'egl',
212     description : 'Mesa EGL Library',
213     version : meson.project_version(),
214     libraries : libegl,
215     libraries_private: gl_priv_libs,
216     requires_private : gl_priv_reqs,
217     extra_cflags : gl_pkgconfig_c_flags,
218   )
219 endif
220
221 if with_symbols_check
222   if with_glvnd
223     egl_symbols = files('egl-glvnd-symbols.txt')
224   else
225     egl_symbols = files('egl-symbols.txt')
226   endif
227   test('egl-symbols-check',
228     symbols_check,
229     args : [
230       '--lib', libegl,
231       '--symbols-file', egl_symbols,
232       symbols_check_args,
233     ],
234     suite : ['egl'],
235   )
236   test('egl-entrypoint-check',
237     prog_python,
238     args : files('egl-entrypoint-check.py', 'main/eglentrypoint.h'),
239     suite : ['egl'],
240   )
241 endif