101e04c3fSmrg# Copyright © 2017 Intel Corporation
201e04c3fSmrg
301e04c3fSmrg# Permission is hereby granted, free of charge, to any person obtaining a copy
401e04c3fSmrg# of this software and associated documentation files (the "Software"), to deal
501e04c3fSmrg# in the Software without restriction, including without limitation the rights
601e04c3fSmrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
701e04c3fSmrg# copies of the Software, and to permit persons to whom the Software is
801e04c3fSmrg# furnished to do so, subject to the following conditions:
901e04c3fSmrg
1001e04c3fSmrg# The above copyright notice and this permission notice shall be included in
1101e04c3fSmrg# all copies or substantial portions of the Software.
1201e04c3fSmrg
1301e04c3fSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1401e04c3fSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1501e04c3fSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1601e04c3fSmrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1701e04c3fSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1801e04c3fSmrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1901e04c3fSmrg# SOFTWARE.
2001e04c3fSmrg
2101e04c3fSmrgfiles_vulkan_wsi = files('wsi_common.c')
2201e04c3fSmrg
237ec681f3Smrgif dep_libdrm.found()
247ec681f3Smrg  files_vulkan_wsi += files('wsi_common_drm.c')
257ec681f3Smrgendif
267ec681f3Smrg
2701e04c3fSmrgif with_platform_x11
2801e04c3fSmrg  files_vulkan_wsi += files('wsi_common_x11.c')
2901e04c3fSmrgendif
3001e04c3fSmrg
3101e04c3fSmrgif with_platform_wayland
3201e04c3fSmrg  files_vulkan_wsi += files('wsi_common_wayland.c')
3301e04c3fSmrg  files_vulkan_wsi += [
3401e04c3fSmrg    linux_dmabuf_unstable_v1_client_protocol_h,
3501e04c3fSmrg    linux_dmabuf_unstable_v1_protocol_c,
3601e04c3fSmrg  ]
3701e04c3fSmrgendif
3801e04c3fSmrg
397ec681f3Smrgif with_platform_windows
407ec681f3Smrg  files_vulkan_wsi += files('wsi_common_win32.c')
417ec681f3Smrgendif
427ec681f3Smrg
437ec681f3Smrgif system_has_kms_drm and not with_platform_android
4401e04c3fSmrg  files_vulkan_wsi += files('wsi_common_display.c')
4501e04c3fSmrgendif
4601e04c3fSmrg
477ec681f3Smrgwsi_entrypoints = custom_target(
487ec681f3Smrg  'wsi_entrypoints',
497ec681f3Smrg  input : [vk_entrypoints_gen, vk_api_xml],
507ec681f3Smrg  output : ['wsi_common_entrypoints.h', 'wsi_common_entrypoints.c'],
517ec681f3Smrg  command : [
527ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
537ec681f3Smrg    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'wsi',
547ec681f3Smrg  ],
557ec681f3Smrg  depend_files : vk_entrypoints_gen_depend_files,
567ec681f3Smrg)
577ec681f3Smrg
5801e04c3fSmrglibvulkan_wsi = static_library(
5901e04c3fSmrg  'vulkan_wsi',
607ec681f3Smrg  [files_vulkan_wsi, wsi_entrypoints],
617ec681f3Smrg  include_directories : [inc_include, inc_src],
627ec681f3Smrg  dependencies : [
637ec681f3Smrg    vulkan_wsi_deps, dep_libdrm, idep_vulkan_util_headers, idep_xmlconfig,
647ec681f3Smrg  ],
657ec681f3Smrg  c_args : [vulkan_wsi_args],
667ec681f3Smrg  gnu_symbol_visibility : 'hidden',
6701e04c3fSmrg  build_by_default : false,
6801e04c3fSmrg)
697ec681f3Smrg
707ec681f3Smrgidep_vulkan_wsi_headers = declare_dependency(
717ec681f3Smrg  include_directories : include_directories('.')
727ec681f3Smrg)
737ec681f3Smrg
747ec681f3Smrg# This is likely a bug in the Meson VS backend, as MSVC with ninja works fine.
757ec681f3Smrg# See this discussion here:
767ec681f3Smrg# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10506
777ec681f3Smrgif get_option('backend').startswith('vs')
787ec681f3Smrg  idep_vulkan_wsi = declare_dependency(
797ec681f3Smrg    link_with : libvulkan_wsi,
807ec681f3Smrg    dependencies : idep_vulkan_wsi_headers
817ec681f3Smrg  )
827ec681f3Smrgelse
837ec681f3Smrg  idep_vulkan_wsi = declare_dependency(
847ec681f3Smrg    # Instruct users of this library to link with --whole-archive.  Otherwise,
857ec681f3Smrg    # our weak function overloads may not resolve properly.
867ec681f3Smrg    link_whole : libvulkan_wsi,
877ec681f3Smrg    dependencies : idep_vulkan_wsi_headers
887ec681f3Smrg  )
897ec681f3Smrgendif
90