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