• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright © 2017-2019 Intel Corporation
2# SPDX-License-Identifier: MIT
3
4inc_egl = include_directories('.', 'main')
5
6c_args_for_egl = [asan_c_args]
7cpp_args_for_egl = []
8link_args_for_egl = []
9link_deps_for_egl = []
10link_for_egl = [libpipe_loader_dynamic]
11if with_dri
12  link_for_egl += libgallium_dri
13endif
14if with_platform_windows
15  link_for_egl += libgallium_wgl
16endif
17deps_for_egl = []
18incs_for_egl = [inc_include, inc_src, inc_egl]
19
20files_egl = files(
21  'main/eglapi.c',
22  'main/eglarray.c',
23  'main/eglarray.h',
24  'main/eglconfigdebug.c',
25  'main/eglconfigdebug.h',
26  'main/eglconfig.c',
27  'main/eglconfig.h',
28  'main/eglcontext.c',
29  'main/eglcontext.h',
30  'main/eglcurrent.c',
31  'main/eglcurrent.h',
32  'main/egldefines.h',
33  'main/egldevice.c',
34  'main/egldevice.h',
35  'main/egldisplay.c',
36  'main/egldisplay.h',
37  'main/egldriver.h',
38  'main/eglglobals.c',
39  'main/eglglobals.h',
40  'main/eglimage.c',
41  'main/eglimage.h',
42  'main/egllog.c',
43  'main/egllog.h',
44  'main/eglsurface.c',
45  'main/eglsurface.h',
46  'main/eglsync.c',
47  'main/eglsync.h',
48  'main/eglentrypoint.h',
49  'main/egltypedefs.h',
50)
51
52g_egldispatchstubs_c = custom_target(
53  'g_egldispatchstubs.c',
54  input : [
55    'generate/gen_egl_dispatch.py',
56    'generate/egl.xml', 'generate/egl_other.xml'
57  ],
58  output : 'g_egldispatchstubs.c',
59  command : [
60    prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@',
61  ],
62  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
63  capture : true,
64)
65
66g_egldispatchstubs_h = custom_target(
67  'g_egldispatchstubs.h',
68  input : [
69    'generate/gen_egl_dispatch.py',
70    'generate/egl.xml', 'generate/egl_other.xml'
71  ],
72  output : 'g_egldispatchstubs.h',
73  command : [
74    prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@',
75  ],
76  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
77  capture : true,
78)
79
80if with_dri
81  files_egl += files(
82    'drivers/dri2/egl_dri2.c',
83    'drivers/dri2/egl_dri2.h',
84  )
85  files_egl += sha1_h
86  deps_for_egl += idep_xmlconfig
87  link_for_egl += libloader
88  incs_for_egl += inc_loader
89  incs_for_egl += inc_loader_x11
90  incs_for_egl += inc_gallium
91  incs_for_egl += inc_gallium_aux
92  incs_for_egl += inc_mesa
93  incs_for_egl += inc_st_dri
94
95  files_egl += files(
96    'drivers/dri2/platform_device.c',
97    'drivers/dri2/platform_surfaceless.c',
98  )
99
100  if with_platform_x11
101    files_egl += files('drivers/dri2/platform_x11.c')
102    if with_dri_platform == 'drm'
103      files_egl += files('drivers/dri2/platform_x11_dri3.c')
104      link_for_egl += [libloader_x11]
105    endif
106    deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xrandr, dep_xcb_xfixes, dep_xcb_shm]
107  endif
108  if with_gbm and not with_platform_android and not with_platform_ohos
109    files_egl += files('drivers/dri2/platform_drm.c')
110    link_for_egl += libgbm
111    incs_for_egl += [inc_gbm, include_directories('../gbm/main')]
112    deps_for_egl += dep_libdrm
113  endif
114  if with_platform_wayland
115    deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
116    link_for_egl += [libwayland_drm, libloader_wayland_helper]
117    files_egl += files('drivers/dri2/platform_wayland.c')
118    files_egl += wp_files['linux-dmabuf-unstable-v1']
119    files_egl += [wayland_drm_client_protocol_h]
120    incs_for_egl += include_directories('wayland/wayland-drm')
121  endif
122  if with_platform_android
123    deps_for_egl += [dep_android, idep_u_gralloc]
124    files_egl += files('drivers/dri2/platform_android.c')
125  endif
126  if with_platform_ohos
127    deps_for_egl += [dependency('libsurface')]
128    files_egl += files('drivers/dri2/platform_ohos.c')
129  endif
130elif with_platform_haiku
131  c_args_for_egl += [
132    '-D_EGL_BUILT_IN_DRIVER_HAIKU',
133  ]
134  files_egl += files('drivers/haiku/egl_haiku.cpp')
135
136  incs_for_egl += [inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_gallium_winsys, inc_gallium_winsys_sw]
137  incs_for_egl += [inc_mesa, inc_mapi]
138  incs_for_egl += [include_directories('../gallium/frontends/hgl')]
139
140  link_for_egl += [libmesa, libgallium, libswhgl, libsthgl]
141  deps_for_egl += [cpp.find_library('be'), driver_swrast]
142elif with_platform_windows
143  c_args_for_egl += [
144    '-DEGLAPI=', '-DPUBLIC='
145  ]
146  files_egl += files('drivers/wgl/egl_wgl.c')
147  incs_for_egl += [inc_wgl, inc_gallium, inc_gallium_aux, inc_mesa, inc_mapi]
148  link_for_egl += libgallium_wgl
149
150else
151  error('No EGL driver available.')
152endif
153
154if cc.has_function('mincore')
155  c_args_for_egl += '-DHAVE_MINCORE'
156endif
157
158if 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'
162else
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_tag : 'runtime',
177    install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
178  )
179endif
180
181if with_ld_version_script
182  if with_glvnd
183    link_args_for_egl += [
184      '-Wl,--version-script', join_paths(meson.current_source_dir(), 'egl-glvnd.sym')
185    ]
186    link_deps_for_egl += files('egl-glvnd.sym')
187  else
188    link_args_for_egl += [
189      '-Wl,--version-script', join_paths(meson.current_source_dir(), 'egl.sym')
190    ]
191    link_deps_for_egl += files('egl.sym')
192  endif
193endif
194
195egl_def = custom_target(
196  'egl.def',
197  input: 'main/egl.def.in',
198  output : 'egl.def',
199  command : gen_vs_module_defs_normal_command,
200)
201
202libegl = shared_library(
203  egl_lib_name,
204  files_egl,
205  c_args : [
206    c_args_for_egl,
207    '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
208  ],
209  cpp_args : [cpp_args_for_egl],
210  gnu_symbol_visibility : 'hidden',
211  include_directories : incs_for_egl,
212  link_with : [link_for_egl],
213  link_args : [ld_args_bsymbolic, ld_args_gc_sections, link_args_for_egl],
214  link_depends : [link_deps_for_egl],
215  dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread, idep_mesautil],
216  install : true,
217  name_prefix : host_machine.system() == 'windows' ? 'lib' : [],  # always use lib, but avoid warnings on !windows
218  vs_module_defs : egl_def
219)
220
221if not with_glvnd
222  pkg.generate(
223    name : 'egl',
224    description : 'Mesa EGL Library',
225    version : meson.project_version(),
226    libraries : libegl,
227    libraries_private: gl_priv_libs,
228    requires_private : gl_priv_reqs,
229    extra_cflags : gl_pkgconfig_c_flags,
230  )
231endif
232
233if with_symbols_check
234  if with_glvnd
235    egl_symbols = files('egl-glvnd-symbols.txt')
236  else
237    egl_symbols = files('egl-symbols.txt')
238  endif
239  test('egl-symbols-check',
240    symbols_check,
241    args : [
242      '--lib', libegl,
243      '--symbols-file', egl_symbols,
244      symbols_check_args,
245    ],
246    suite : ['egl'],
247  )
248  test('egl-entrypoint-check',
249    prog_python,
250    args : files('egl-entrypoint-check.py', 'main/eglentrypoint.h'),
251    suite : ['egl'],
252  )
253endif
254