1bf215546Sopenharmony_ci# Copyright © Microsoft Corporation
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a
4bf215546Sopenharmony_ci# copy of this software and associated documentation files (the "Software"),
5bf215546Sopenharmony_ci# to deal in the Software without restriction, including without limitation
6bf215546Sopenharmony_ci# the rights to use, copy, modify, merge, publish, distribute, sublicense,
7bf215546Sopenharmony_ci# and/or sell copies of the Software, and to permit persons to whom the
8bf215546Sopenharmony_ci# Software is furnished to do so, subject to the following conditions:
9bf215546Sopenharmony_ci
10bf215546Sopenharmony_ci# The above copyright notice and this permission notice (including the next
11bf215546Sopenharmony_ci# paragraph) shall be included in all copies or substantial portions of the
12bf215546Sopenharmony_ci# Software.
13bf215546Sopenharmony_ci
14bf215546Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bf215546Sopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf215546Sopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17bf215546Sopenharmony_ci# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18bf215546Sopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19bf215546Sopenharmony_ci# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20bf215546Sopenharmony_ci# IN THE SOFTWARE.
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_cidzn_entrypoints = custom_target(
23bf215546Sopenharmony_ci  'dzn_entrypoints',
24bf215546Sopenharmony_ci  input : [vk_entrypoints_gen, vk_api_xml],
25bf215546Sopenharmony_ci  output : ['dzn_entrypoints.h', 'dzn_entrypoints.c'],
26bf215546Sopenharmony_ci  command : [
27bf215546Sopenharmony_ci    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
28bf215546Sopenharmony_ci    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'dzn'
29bf215546Sopenharmony_ci  ],
30bf215546Sopenharmony_ci  depend_files : vk_entrypoints_gen_depend_files,
31bf215546Sopenharmony_ci)
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_cilibdzn_files = files(
34bf215546Sopenharmony_ci  'dzn_cmd_buffer.c',
35bf215546Sopenharmony_ci  'dzn_descriptor_set.c',
36bf215546Sopenharmony_ci  'dzn_device.c',
37bf215546Sopenharmony_ci  'dzn_dxcore.cpp',
38bf215546Sopenharmony_ci  'dzn_image.c',
39bf215546Sopenharmony_ci  'dzn_meta.c',
40bf215546Sopenharmony_ci  'dzn_nir.c',
41bf215546Sopenharmony_ci  'dzn_pipeline.c',
42bf215546Sopenharmony_ci  'dzn_query.c',
43bf215546Sopenharmony_ci  'dzn_sync.c',
44bf215546Sopenharmony_ci  'dzn_util.c',
45bf215546Sopenharmony_ci  'dzn_wsi.c',
46bf215546Sopenharmony_ci)
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_cidzn_deps = [
49bf215546Sopenharmony_ci  idep_libdxil_compiler,
50bf215546Sopenharmony_ci  idep_libspirv_to_dxil,
51bf215546Sopenharmony_ci  idep_nir,
52bf215546Sopenharmony_ci  idep_nir_headers,
53bf215546Sopenharmony_ci  idep_vulkan_util,
54bf215546Sopenharmony_ci  idep_vulkan_runtime,
55bf215546Sopenharmony_ci  idep_vulkan_wsi,
56bf215546Sopenharmony_ci  dep_dxheaders,
57bf215546Sopenharmony_ci]
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_cidzn_flags = [ ]
60bf215546Sopenharmony_cidzn_cpp_flags = [ ]
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ciif with_platform_windows
63bf215546Sopenharmony_ci  dzn_flags += '-DVK_USE_PLATFORM_WIN32_KHR'
64bf215546Sopenharmony_ci  libdzn_files += files('dzn_dxgi.c')
65bf215546Sopenharmony_ciendif
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ciif cc.get_argument_syntax() != 'msvc'
68bf215546Sopenharmony_ci  dzn_flags_to_try = [
69bf215546Sopenharmony_ci    '-Werror=unused-variable',
70bf215546Sopenharmony_ci    '-Werror=unused-but-set-variable',
71bf215546Sopenharmony_ci    '-Werror=unused-value',
72bf215546Sopenharmony_ci    '-Werror=format',
73bf215546Sopenharmony_ci    '-Werror=switch',
74bf215546Sopenharmony_ci  ]
75bf215546Sopenharmony_ci  dzn_flags += cc.get_supported_arguments(dzn_flags_to_try)
76bf215546Sopenharmony_ci  dzn_cpp_flags = cpp.get_supported_arguments(['-Wno-error=unused-value'])
77bf215546Sopenharmony_ciendif
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_cilibvulkan_dzn = shared_library(
80bf215546Sopenharmony_ci  'vulkan_dzn',
81bf215546Sopenharmony_ci  [libdzn_files, dzn_entrypoints, sha1_h],
82bf215546Sopenharmony_ci  vs_module_defs : vulkan_api_def,
83bf215546Sopenharmony_ci  include_directories : [
84bf215546Sopenharmony_ci    inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux,
85bf215546Sopenharmony_ci    inc_compiler, inc_util
86bf215546Sopenharmony_ci  ],
87bf215546Sopenharmony_ci  dependencies : [dzn_deps, idep_vulkan_wsi],
88bf215546Sopenharmony_ci  c_args : dzn_flags,
89bf215546Sopenharmony_ci  cpp_args : dzn_cpp_flags,
90bf215546Sopenharmony_ci  gnu_symbol_visibility : 'hidden',
91bf215546Sopenharmony_ci  link_args : [ld_args_bsymbolic, ld_args_gc_sections],
92bf215546Sopenharmony_ci  name_prefix : host_machine.system() == 'windows' ? '' : 'lib',
93bf215546Sopenharmony_ci  install : true,
94bf215546Sopenharmony_ci)
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ciicd_file_name = 'libvulkan_dzn.so'
97bf215546Sopenharmony_cimodule_dir = join_paths(get_option('prefix'), get_option('libdir'))
98bf215546Sopenharmony_ciif with_platform_windows
99bf215546Sopenharmony_ci  module_dir = join_paths(get_option('prefix'), get_option('bindir'))
100bf215546Sopenharmony_ci  icd_file_name = 'vulkan_dzn.dll'
101bf215546Sopenharmony_ciendif
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ciicd_command = [
105bf215546Sopenharmony_ci   prog_python, '@INPUT0@',
106bf215546Sopenharmony_ci   '--api-version', '1.1', '--xml', '@INPUT1@',
107bf215546Sopenharmony_ci   '--lib-path', join_paths(module_dir, icd_file_name),
108bf215546Sopenharmony_ci   '--out', '@OUTPUT@',
109bf215546Sopenharmony_ci]
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ciicd_dev_command = [
112bf215546Sopenharmony_ci   prog_python, '@INPUT0@',
113bf215546Sopenharmony_ci   '--api-version', '1.1', '--xml', '@INPUT1@',
114bf215546Sopenharmony_ci   '--lib-path', join_paths(meson.current_build_dir(), icd_file_name),
115bf215546Sopenharmony_ci   '--out', '@OUTPUT@',
116bf215546Sopenharmony_ci]
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ciif with_platform_windows
119bf215546Sopenharmony_ci  icd_command += '--use-backslash'
120bf215546Sopenharmony_ci  icd_dev_command += '--use-backslash'
121bf215546Sopenharmony_ciendif
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_cidzn_icd = custom_target(
124bf215546Sopenharmony_ci  'dzn_icd',
125bf215546Sopenharmony_ci  input : [vk_icd_gen, vk_api_xml],
126bf215546Sopenharmony_ci  output : 'dzn_icd.@0@.json'.format(host_machine.cpu()),
127bf215546Sopenharmony_ci  command : icd_command,
128bf215546Sopenharmony_ci  build_by_default : true,
129bf215546Sopenharmony_ci  install_dir : with_vulkan_icd_dir,
130bf215546Sopenharmony_ci  install : true,
131bf215546Sopenharmony_ci)
132bf215546Sopenharmony_ci
133bf215546Sopenharmony_ciif meson.version().version_compare('>= 0.58')
134bf215546Sopenharmony_ci  _dev_icdname = 'dzn_devenv_icd.@0@.json'.format(host_machine.cpu())
135bf215546Sopenharmony_ci  custom_target(
136bf215546Sopenharmony_ci    'dzn_devenv_icd',
137bf215546Sopenharmony_ci    input : [vk_icd_gen, vk_api_xml],
138bf215546Sopenharmony_ci    output : _dev_icdname,
139bf215546Sopenharmony_ci    command : icd_dev_command,
140bf215546Sopenharmony_ci    build_by_default : true,
141bf215546Sopenharmony_ci  )
142bf215546Sopenharmony_ci
143bf215546Sopenharmony_ci  devenv.append('VK_ICD_FILENAMES', meson.current_build_dir() / _dev_icdname)
144bf215546Sopenharmony_ciendif
145