• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
21inc_egl = include_directories('.', 'main')
22inc_egl_dri2 = include_directories('drivers/dri2')
23
24c_args_for_egl = [asan_c_args]
25cpp_args_for_egl = []
26override_for_egl = []
27link_for_egl = []
28deps_for_egl = []
29incs_for_egl = [inc_include, inc_src, inc_egl]
30
31files_egl = files(
32  'main/eglapi.c',
33  'main/eglarray.c',
34  'main/eglarray.h',
35  'main/eglconfigdebug.c',
36  'main/eglconfigdebug.h',
37  'main/eglconfig.c',
38  'main/eglconfig.h',
39  'main/eglcontext.c',
40  'main/eglcontext.h',
41  'main/eglcurrent.c',
42  'main/eglcurrent.h',
43  'main/egldefines.h',
44  'main/egldevice.c',
45  'main/egldevice.h',
46  'main/egldisplay.c',
47  'main/egldisplay.h',
48  'main/egldriver.h',
49  'main/eglglobals.c',
50  'main/eglglobals.h',
51  'main/eglimage.c',
52  'main/eglimage.h',
53  'main/egllog.c',
54  'main/egllog.h',
55  'main/eglsurface.c',
56  'main/eglsurface.h',
57  'main/eglsync.c',
58  'main/eglsync.h',
59  'main/eglentrypoint.h',
60  'main/egltypedefs.h',
61)
62
63g_egldispatchstubs_c = custom_target(
64  'g_egldispatchstubs.c',
65  input : [
66    'generate/gen_egl_dispatch.py',
67    'generate/egl.xml', 'generate/egl_other.xml'
68  ],
69  output : 'g_egldispatchstubs.c',
70  command : [
71    prog_python, '@INPUT0@', 'source', '@INPUT1@', '@INPUT2@',
72  ],
73  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
74  capture : true,
75)
76
77g_egldispatchstubs_h = custom_target(
78  'g_egldispatchstubs.h',
79  input : [
80    'generate/gen_egl_dispatch.py',
81    'generate/egl.xml', 'generate/egl_other.xml'
82  ],
83  output : 'g_egldispatchstubs.h',
84  command : [
85    prog_python, '@INPUT0@', 'header', '@INPUT1@', '@INPUT2@',
86  ],
87  depend_files : [ files('generate/eglFunctionList.py'), genCommon_py, ],
88  capture : true,
89)
90
91if with_dri2
92  files_egl += files(
93    'drivers/dri2/egl_dri2.c',
94    'drivers/dri2/egl_dri2.h',
95  )
96  deps_for_egl += idep_xmlconfig
97  link_for_egl += libloader
98  incs_for_egl += inc_loader
99
100  files_egl += files(
101    'drivers/dri2/platform_device.c',
102    'drivers/dri2/platform_surfaceless.c',
103  )
104  if with_platform_x11
105    files_egl += files('drivers/dri2/platform_x11.c')
106    if with_dri3
107      files_egl += files('drivers/dri2/platform_x11_dri3.c')
108      link_for_egl += libloader_dri3_helper
109    endif
110    deps_for_egl += [dep_x11_xcb, dep_xcb_dri2, dep_xcb_xfixes]
111  endif
112  if with_gbm and not with_platform_android and not with_platform_ohos
113    files_egl += files('drivers/dri2/platform_drm.c')
114    link_for_egl += libgbm
115    incs_for_egl += [inc_gbm, include_directories('../gbm/main')]
116    deps_for_egl += dep_libdrm
117  endif
118  if with_platform_wayland
119    deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]
120    link_for_egl += libwayland_drm
121    files_egl += files('drivers/dri2/platform_wayland.c')
122    files_egl += [
123      linux_dmabuf_unstable_v1_protocol_c,
124      linux_dmabuf_unstable_v1_client_protocol_h,
125      wayland_drm_client_protocol_h,
126    ]
127    incs_for_egl += include_directories('wayland/wayland-drm')
128  endif
129  if with_platform_android
130    deps_for_egl += dep_android
131    files_egl += files('drivers/dri2/platform_android.c')
132    if dep_android_mapper4.found()
133      files_egl += files('drivers/dri2/platform_android_mapper.cpp')
134      c_args_for_egl += '-DUSE_IMAPPER4_METADATA_API'
135      cpp_args_for_egl += '-DUSE_IMAPPER4_METADATA_API'
136      override_for_egl += 'cpp_std=c++17'
137    endif
138  endif
139  if with_platform_ohos
140    deps_for_egl += dep_ohos
141    files_egl += files('drivers/dri2/platform_ohos.c')
142  endif
143elif with_platform_haiku
144  incs_for_egl += inc_haikugl
145  c_args_for_egl += [
146    '-D_EGL_BUILT_IN_DRIVER_HAIKU',
147  ]
148  files_egl += files('drivers/haiku/egl_haiku.cpp')
149  link_for_egl += libgl
150  deps_for_egl += cpp.find_library('be')
151elif with_platform_windows
152  c_args_for_egl += [
153    '-DEGLAPI=', '-DPUBLIC='
154  ]
155  files_egl += files('drivers/wgl/egl_wgl.c')
156  incs_for_egl += [inc_wgl, inc_gallium, inc_gallium_aux]
157  link_for_egl += libgallium_wgl
158endif
159
160if cc.has_function('mincore')
161  c_args_for_egl += '-DHAVE_MINCORE'
162endif
163
164if not with_glvnd
165  egl_lib_name = 'EGL' + get_option('egl-lib-suffix')
166  egl_lib_version = '1.0.0'
167  egl_lib_soversion = host_machine.system() == 'windows' ? '' : '1'
168else
169  egl_lib_name = 'EGL_@0@'.format(glvnd_vendor_name)
170  egl_lib_version = '0.0.0'
171  egl_lib_soversion = '0'
172  deps_for_egl += dep_glvnd
173  files_egl += [g_egldispatchstubs_h, g_egldispatchstubs_c]
174  files_egl += files('main/eglglvnd.c', 'main/egldispatchstubs.c')
175  glvnd_config = configuration_data()
176  glvnd_config.set('glvnd_vendor_name', get_option('glvnd-vendor-name'))
177  configure_file(
178    configuration: glvnd_config,
179    input : 'main/50_mesa.json',
180    output: '50_@0@.json'.format(glvnd_vendor_name),
181    install : true,
182    install_dir : join_paths(get_option('datadir'), 'glvnd', 'egl_vendor.d')
183  )
184endif
185
186egl_def = custom_target(
187  'egl.def',
188  input: 'main/egl.def.in',
189  output : 'egl.def',
190  command : [prog_python, gen_vs_module_defs_py,
191             '--in_file', '@INPUT@', '--out_file', '@OUTPUT@',
192             '--compiler_id', cc.get_argument_syntax(), '--cpu_family', host_machine.cpu_family()]
193)
194
195libegl = shared_library(
196  egl_lib_name,
197  files_egl,
198  c_args : [
199    c_args_for_egl,
200    '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()),
201  ],
202  cpp_args : [cpp_args_for_egl],
203  override_options : override_for_egl,
204  gnu_symbol_visibility : 'hidden',
205  include_directories : incs_for_egl,
206  link_with : [link_for_egl, libglapi],
207  link_args : [ld_args_bsymbolic, ld_args_gc_sections],
208  dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread, idep_mesautil],
209  install : true,
210  version : egl_lib_version,
211  soversion : egl_lib_soversion,
212  name_prefix : 'lib', # even on windows
213  vs_module_defs : egl_def
214)
215
216if not with_glvnd
217  pkg.generate(
218    name : 'egl',
219    description : 'Mesa EGL Library',
220    version : meson.project_version(),
221    libraries : libegl,
222    libraries_private: gl_priv_libs,
223    requires_private : gl_priv_reqs,
224    extra_cflags : gl_pkgconfig_c_flags,
225  )
226endif
227
228if with_symbols_check
229  if with_glvnd
230    egl_symbols = files('egl-glvnd-symbols.txt')
231  else
232    egl_symbols = files('egl-symbols.txt')
233  endif
234  test('egl-symbols-check',
235    symbols_check,
236    args : [
237      '--lib', libegl,
238      '--symbols-file', egl_symbols,
239      symbols_check_args,
240    ],
241    suite : ['egl'],
242  )
243  test('egl-entrypoint-check',
244    prog_python,
245    args : files('egl-entrypoint-check.py', 'main/eglentrypoint.h'),
246    suite : ['egl'],
247  )
248endif
249