1bf215546Sopenharmony_ci# Copyright © 2018 Intel Corporation
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a copy
4bf215546Sopenharmony_ci# of this software and associated documentation files (the "Software"), to deal
5bf215546Sopenharmony_ci# in the Software without restriction, including without limitation the rights
6bf215546Sopenharmony_ci# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7bf215546Sopenharmony_ci# copies of the Software, and to permit persons to whom the Software is
8bf215546Sopenharmony_ci# furnished to do so, subject to the following conditions:
9bf215546Sopenharmony_ci
10bf215546Sopenharmony_ci# The above copyright notice and this permission notice shall be included in
11bf215546Sopenharmony_ci# all copies or substantial portions of the Software.
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14bf215546Sopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15bf215546Sopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16bf215546Sopenharmony_ci# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17bf215546Sopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18bf215546Sopenharmony_ci# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19bf215546Sopenharmony_ci# SOFTWARE.
20bf215546Sopenharmony_ci
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_ciopengl32_link_args = []
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ciopengl32_def = custom_target(
25bf215546Sopenharmony_ci  'opengl32.def',
26bf215546Sopenharmony_ci  input: 'opengl32.def.in',
27bf215546Sopenharmony_ci  output : 'opengl32.def',
28bf215546Sopenharmony_ci  command : [prog_python, gen_vs_module_defs_py,
29bf215546Sopenharmony_ci             '--in_file', '@INPUT@', '--out_file', '@OUTPUT@',
30bf215546Sopenharmony_ci             '--compiler_id', cc.get_argument_syntax(), '--cpu_family', host_machine.cpu_family()]
31bf215546Sopenharmony_ci)
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_cilibopengl32 = shared_library(
34bf215546Sopenharmony_ci  'opengl32',
35bf215546Sopenharmony_ci  ['stw_wgl.c'],
36bf215546Sopenharmony_ci  vs_module_defs : opengl32_def,
37bf215546Sopenharmony_ci  include_directories : [
38bf215546Sopenharmony_ci    inc_include, inc_wgl, inc_src,
39bf215546Sopenharmony_ci  ],
40bf215546Sopenharmony_ci  link_with : [
41bf215546Sopenharmony_ci    libgallium_wgl, libglapi_bridge, libglapi
42bf215546Sopenharmony_ci  ],
43bf215546Sopenharmony_ci  dependencies : [
44bf215546Sopenharmony_ci    idep_mesautil
45bf215546Sopenharmony_ci  ],
46bf215546Sopenharmony_ci  c_args : ['-D_GDI32_'],
47bf215546Sopenharmony_ci  link_args : opengl32_link_args,
48bf215546Sopenharmony_ci  name_prefix : '',  # otherwise mingw will create libopengl32.dll
49bf215546Sopenharmony_ci  install : true,
50bf215546Sopenharmony_ci)
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ciif with_tests
53bf215546Sopenharmony_ci  extra_test_defs = []
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_ci  # The generated MinGW 32-bits import libraries are always broken due to missing @nn suffix on
56bf215546Sopenharmony_ci  # symbols, no matter what we do.  So instead we use the builtin libopengl32.a
57bf215546Sopenharmony_ci  extra_test_deps = [cpp.find_library('opengl32')]
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci  if with_gallium_d3d12
60bf215546Sopenharmony_ci    extra_test_defs += ['-DGALLIUM_D3D12']
61bf215546Sopenharmony_ci    extra_test_deps += [cpp.find_library('d3d12')]
62bf215546Sopenharmony_ci  endif
63bf215546Sopenharmony_ci
64bf215546Sopenharmony_ci  test_wgl = executable(
65bf215546Sopenharmony_ci    'test_wgl',
66bf215546Sopenharmony_ci    files('tests/wgl_tests.cpp'),
67bf215546Sopenharmony_ci    cpp_args : [cpp_msvc_compat_args, extra_test_defs],
68bf215546Sopenharmony_ci    dependencies : [idep_gtest, dep_dxheaders, extra_test_deps],
69bf215546Sopenharmony_ci  )
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_ci  wgl_test_env = environment()
72bf215546Sopenharmony_ci  wgl_test_env.append('PATH', libgallium_wgl_build_dir)
73bf215546Sopenharmony_ci  if with_shared_glapi
74bf215546Sopenharmony_ci    wgl_test_env.append('PATH', libglapi_build_dir)
75bf215546Sopenharmony_ci  endif
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_ci  test(
78bf215546Sopenharmony_ci    'wgl',
79bf215546Sopenharmony_ci    test_wgl,
80bf215546Sopenharmony_ci    suite : ['wgl'],
81bf215546Sopenharmony_ci    env : wgl_test_env,
82bf215546Sopenharmony_ci    depends : [libopengl32],
83bf215546Sopenharmony_ci    protocol : gtest_test_protocol,
84bf215546Sopenharmony_ci  )
85bf215546Sopenharmony_ciendif
86