1bf215546Sopenharmony_ci# Copyright © 2017 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_cisubdir('gen')
22bf215546Sopenharmony_ci
23bf215546Sopenharmony_ciinc_glapi = include_directories('.')
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_cistatic_glapi_files = []
26bf215546Sopenharmony_cistatic_glapi_args = []
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ciif with_dri and ['apple', 'windows'].contains(with_dri_platform)
29bf215546Sopenharmony_ci  static_glapi_files += [glapi_gentable_c, glapitable_h]
30bf215546Sopenharmony_ciendif
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_cibridge_glapi_files = static_glapi_files
33bf215546Sopenharmony_cibridge_glapi_args = static_glapi_args
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_cibridge_glapi_files += files(
36bf215546Sopenharmony_ci  '../entry.c',
37bf215546Sopenharmony_ci  '../entry.h',
38bf215546Sopenharmony_ci  '../entry_x86-64_tls.h',
39bf215546Sopenharmony_ci  '../entry_x86_tls.h',
40bf215546Sopenharmony_ci  '../entry_ppc64le_tls.h',
41bf215546Sopenharmony_ci  '../mapi_tmp.h',
42bf215546Sopenharmony_ci)
43bf215546Sopenharmony_cibridge_glapi_files += glapi_mapi_tmp_h
44bf215546Sopenharmony_cibridge_glapi_args += [
45bf215546Sopenharmony_ci  '-DMAPI_MODE_BRIDGE',
46bf215546Sopenharmony_ci  '-DMAPI_ABI_HEADER="@0@"'.format(glapi_mapi_tmp_h.full_path()),
47bf215546Sopenharmony_ci  gcc_lto_quirk,
48bf215546Sopenharmony_ci]
49bf215546Sopenharmony_ciif with_platform_windows
50bf215546Sopenharmony_ci  bridge_glapi_args += ['-D_GDI32_']
51bf215546Sopenharmony_ciendif
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_cistatic_glapi_args += '-DMAPI_MODE_UTIL'
54bf215546Sopenharmony_ciif with_platform_windows
55bf215546Sopenharmony_ci  static_glapi_args += ['-D_GDI32_', '-DKHRONOS_DLL_EXPORTS', '-D_GLAPI_DLL_EXPORTS']
56bf215546Sopenharmony_ciendif
57bf215546Sopenharmony_cistatic_glapi_files += files(
58bf215546Sopenharmony_ci  'glapi_dispatch.c',
59bf215546Sopenharmony_ci  'glapi_entrypoint.c',
60bf215546Sopenharmony_ci  'glapi_getproc.c',
61bf215546Sopenharmony_ci  'glapi_nop.c',
62bf215546Sopenharmony_ci  'glapi.c',
63bf215546Sopenharmony_ci  'glapi.h',
64bf215546Sopenharmony_ci  'glapi_priv.h',
65bf215546Sopenharmony_ci)
66bf215546Sopenharmony_cistatic_glapi_files += files_mapi_util
67bf215546Sopenharmony_cistatic_glapi_files += [
68bf215546Sopenharmony_ci  glapitable_h, glapi_mapi_tmp_h, glprocs_h, glapitemp_h,
69bf215546Sopenharmony_ci]
70bf215546Sopenharmony_ciif with_asm_arch == 'x86'
71bf215546Sopenharmony_ci  static_glapi_files += glapi_x86_s
72bf215546Sopenharmony_cielif with_asm_arch == 'x86_64'
73bf215546Sopenharmony_ci  static_glapi_files += glapi_x86_64_s
74bf215546Sopenharmony_cielif with_asm_arch == 'sparc'
75bf215546Sopenharmony_ci  static_glapi_files += glapi_sparc_s
76bf215546Sopenharmony_ciendif
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_cilibglapi_bridge = static_library(
80bf215546Sopenharmony_ci  'glapi_bridge',
81bf215546Sopenharmony_ci  bridge_glapi_files,
82bf215546Sopenharmony_ci  include_directories : [inc_mesa, inc_include, inc_src, inc_mapi],
83bf215546Sopenharmony_ci  c_args : [c_msvc_compat_args, bridge_glapi_args],
84bf215546Sopenharmony_ci  dependencies : [dep_thread, dep_selinux, idep_mesautilc11],
85bf215546Sopenharmony_ci  build_by_default : false,
86bf215546Sopenharmony_ci)
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ciif with_shared_glapi
89bf215546Sopenharmony_ci  libglapi_static = libglapi_bridge
90bf215546Sopenharmony_cielse
91bf215546Sopenharmony_ci  libglapi_static = static_library(
92bf215546Sopenharmony_ci    'glapi_static',
93bf215546Sopenharmony_ci    static_glapi_files,
94bf215546Sopenharmony_ci    include_directories : [inc_mesa, inc_include, inc_src, inc_mapi],
95bf215546Sopenharmony_ci    c_args : [c_msvc_compat_args, static_glapi_args],
96bf215546Sopenharmony_ci    dependencies : [dep_thread, dep_selinux, idep_mesautilc11],
97bf215546Sopenharmony_ci    build_by_default : false,
98bf215546Sopenharmony_ci  )
99bf215546Sopenharmony_ciendif
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci# TODO: this test doesn't compile on windows with mingw or msvc due to
102bf215546Sopenharmony_ci# undefined symbols from libglapi_static, but that should be fixable.
103bf215546Sopenharmony_ciif with_any_opengl and not with_shared_glapi and with_tests and not with_platform_windows
104bf215546Sopenharmony_ci  test(
105bf215546Sopenharmony_ci    'glapi_static_check_table',
106bf215546Sopenharmony_ci    executable(
107bf215546Sopenharmony_ci      'glapi_static_check_table',
108bf215546Sopenharmony_ci      ['tests/check_table.cpp', glapitable_h],
109bf215546Sopenharmony_ci      include_directories : [inc_include, inc_src, inc_mesa, inc_mapi],
110bf215546Sopenharmony_ci      link_with : [libglapi_static],
111bf215546Sopenharmony_ci      dependencies : [idep_gtest, dep_thread],
112bf215546Sopenharmony_ci    ),
113bf215546Sopenharmony_ci    suite : ['mapi'],
114bf215546Sopenharmony_ci    protocol : gtest_test_protocol,
115bf215546Sopenharmony_ci  )
116bf215546Sopenharmony_ciendif
117