From 16dc32352d979c3e3d7a559352779197dd3f6fcf Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 4 Nov 2019 13:05:33 -0800 Subject: [PATCH] Add meson build system Theres a couple of things that this meson build system does differently than autotools. It doesn't use a config.h file, it just puts #defines on the command line with -D. It also does all of the code generation in the generated folder, simply because it's simpler to do that. On my 2 core / 4 thread KBL system: autotools (no ccache): sh -c "./autogen.sh&& ./configure && make -j6 check" 44.74s user 6.70s system 145% cpu 35.269 total autotools (warm ccache): sh -c "./autogen.sh&& ./configure && make -j6 check" 32.86s user 4.22s system 129% cpu 28.580 total meson (no ccache): sh -c "meson build; ninja -C build test" 23.48s user 3.71s system 236% cpu 11.487 total meson (warm ccache) sh -c "meson build; ninja -C build test" 16.06s user 2.31s system 210% cpu 8.727 total --- .editorconfig | 4 + include/meson.build | 96 ++++++++++++ meson.build | 191 ++++++++++++++++++++++++ meson_options.txt | 77 ++++++++++ src/EGL/meson.build | 78 ++++++++++ src/GL/meson.build | 59 ++++++++ src/GLESv1/meson.build | 56 +++++++ src/GLESv2/meson.build | 57 +++++++ src/GLX/meson.build | 81 ++++++++++ src/GLdispatch/meson.build | 58 ++++++++ src/GLdispatch/vnd-glapi/meson.build | 104 +++++++++++++ src/OpenGL/meson.build | 61 ++++++++ src/generate/meson.build | 74 +++++++++ src/meson.build | 48 ++++++ src/util/meson.build | 100 +++++++++++++ tests/dummy/meson.build | 82 ++++++++++ tests/meson.build | 214 +++++++++++++++++++++++++++ 17 files changed, 1440 insertions(+) create mode 100644 include/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/EGL/meson.build create mode 100644 src/GL/meson.build create mode 100644 src/GLESv1/meson.build create mode 100644 src/GLESv2/meson.build create mode 100644 src/GLX/meson.build create mode 100644 src/GLdispatch/meson.build create mode 100644 src/GLdispatch/vnd-glapi/meson.build create mode 100644 src/OpenGL/meson.build create mode 100644 src/generate/meson.build create mode 100644 src/meson.build create mode 100644 src/util/meson.build create mode 100644 tests/dummy/meson.build create mode 100644 tests/meson.build diff --git a/.editorconfig b/.editorconfig index b77463f..bb2726e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,7 @@ indent_style = space [{Makefile.am,*.mk}] indent_size = 8 indent_style = tab + +[{meson.build,meson_options.txt}] +indent_size = 2 +indent_style = space diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 0000000..4f329c4 --- /dev/null +++ b/include/meson.build @@ -0,0 +1,96 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +inc_include = include_directories('.') + +install_headers( + 'glvnd/GLdispatchABI.h', + 'glvnd/libglxabi.h', + 'glvnd/libeglabi.h', + subdir : 'glvnd' +) + +_headers = get_option('headers') + +if _headers + install_headers( + 'GL/gl.h', + 'GL/glcorearb.h', + 'GL/glext.h', + subdir : 'GL', + ) + + install_headers( + 'KHR/khrplatform.h', + subdir : 'KHR', + ) +endif + +if with_glx and _headers + install_headers( + 'GL/glx.h', + 'GL/glxext.h', + subdir : 'GL', + ) +endif + +if get_option('gles1') and _headers + install_headers( + 'GLES/egl.h', + 'GLES/gl.h', + 'GLES/glext.h', + 'GLES/glplatform.h', + subdir : 'GLES' + ) +endif + +if get_option('gles2') and _headers + install_headers( + 'GLES2/gl2ext.h', + 'GLES2/gl2.h', + 'GLES2/gl2platform.h', + subdir : 'GLES2', + ) + install_headers( + 'GLES3/gl31.h', + 'GLES3/gl32.h', + 'GLES3/gl3.h', + 'GLES3/gl3ext.h', + 'GLES3/gl3platform.h', + subdir : 'GLES3', + ) +endif + +if get_option('egl') and _headers + install_headers( + 'EGL/egl.h', + 'EGL/eglext.h', + 'EGL/eglplatform.h', + subdir : 'EGL', + ) +endif + diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..22b78d7 --- /dev/null +++ b/meson.build @@ -0,0 +1,191 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +project( + 'glvnd', + 'c', + version : '1.3.0-devel', + meson_version : '>= 0.48', + default_options : ['c_std=gnu99'] +) + +dep_null = dependency('', required : false) +cc = meson.get_compiler('c') +prog_py = import('python').find_installation() +files_symbols_check = files('bin/symbols-check.py') +prog_nm = find_program('nm') + +with_asm = get_option('asm') +use_asm = false +if not with_asm.disabled() + use_asm = true + if (host_machine.cpu_family() == 'x86' and + ['gnu', 'freebsd', 'dragonfly', 'linux', + 'netbsd'].contains(host_machine.system())) + add_project_arguments( + '-DUSE_X86_ASM', + '-DUSE_MMX_ASM', + '-DUSE_3DNOW_ASM', + '-DUSE_SSE_ASM', + language : 'c', + ) + elif (host_machine.cpu_family() == 'x86_64' and + ['freebsd', 'dragonfly', 'linux', + 'netbsd'].contains(host_machine.system())) + add_project_arguments('-DUSE_X86_64_ASM', language : 'c') + elif host_machine.cpu_family() == 'arm' + add_project_arguments('-DUSE_ARMV7_ASM', language : 'c') + elif host_machine.cpu_family() == 'aarch64' + add_project_arguments('-DUSE_AARCH64_ASM', language : 'c') + elif host_machine.cpu_family() == 'ppc' and host_machine.endian() == 'little' + add_project_arguments('-DUSE_PPC64LE_ASM', language : 'c') + elif with_asm.enabled() + error('No ASM available for @0@ (@1@ endian)'.format(host_machine.system(), host_machine.endian())) + else + use_asm = false + endif +endif + +if use_asm + add_project_arguments('-DUSE_DISPATCH_ASM', language : 'c') +endif + +dep_dl = cc.find_library('dl', required : false) +dep_m = cc.find_library('m', required : false) +dep_threads = dependency('threads') +dep_x11 = dependency('x11', required : get_option('x11')) +dep_x11_headers = dep_x11.partial_dependency(compile_args : true, includes : true) +if dep_x11.found() + add_project_arguments('-DUSE_X11', language : ['c']) +endif + +dep_xext = dep_null +dep_glproto = dep_null +with_glx = false +if get_option('glx').enabled() and not dep_x11.found() + error('Cannot build GLX support without X11.') +elif not get_option('glx').disabled() and dep_x11.found() + dep_xext = dependency('xext', required : get_option('glx')) + dep_glproto = dependency('glproto', required : get_option('glx')) + with_glx = true +endif +dep_glx = [dep_xext, dep_glproto] + +if cc.compiles('typeof(int *);', name : 'typeof') + add_project_arguments('-DHAVE_TYPEOF', language : ['c']) +endif + +with_tls = get_option('tls') +have_tls = false +if not with_tls.disabled() + have_tls = cc.compiles( + '__thread int foo __attribute__((tls_model("initial-exec")));', + name : 'initial-exec TLS', + ) +endif + +if have_tls + add_project_arguments('-DGLDISPATCH_USE_TLS', language : ['c']) +endif + +gl_dispatch_type = 'pure_c' +if use_asm + if host_machine.cpu_family().startswith('x86') + gl_dispatch_type = '@0@_@1@'.format( + host_machine.cpu_family(), + have_tls ? 'tls' : 'tsd', + ) + elif host_machine.cpu_family() == 'arm' + gl_dispatch_type = 'armv7_tsd' + elif host_machine.cpu_family() == 'aarch64' + gl_dispatch_type = 'aarch64_tsd' + elif host_machine.cpu_family() == 'ppc64' and host_machine.endian() == 'little' + gl_dispatch_type = 'ppc64le_@1@'.format(have_tls ? 'tls' : 'tsd') + endif +endif +add_project_arguments('-DGLDISPATCH_TYPE_@0@'.format(gl_dispatch_type.to_upper()), language : ['c']) + +if cc.has_function_attribute('constructor') + add_project_arguments('-DUSE_ATTRIBUTE_CONSTRUCTOR', language : ['c']) +endif + +if cc.compiles(''' + #include + void foo(void) + { + pthread_rwlock_t lock; + pthread_rwlock_init(&lock, NULL); + }''', + name : 'pthread rwlock') + add_project_arguments('-DHAVE_PTHREAD_RWLOCK', language : ['c']) +endif + +if cc.compiles(''' + int foo(int volatile *val, int oldVal, int newVal) + { + return __sync_add_and_fetch(val, 1); + return __sync_lock_test_and_set(val, newVal); + return __sync_val_compare_and_swap(val, oldVal, newVal); + }''', + name : 'sync intrinsics') + add_project_arguments('-DHAVE_SYNC_INTRINSICS', language : ['c']) +endif + +if cc.has_function('mincore') + add_project_arguments('-DHAVE_MINCORE', language : ['c']) +endif + +if cc.has_header_symbol('dlfcn.h', 'RTLD_NOLOAD') + add_project_arguments('-DHAVE_RTLD_NOLOAD', language : ['c']) +endif + +if cc.has_member('struct dirent', 'd_type', prefix : '#include ') + add_project_arguments('-DHAVE_DIRENT_DTYPE', language : ['c']) +endif + +_p = get_option('dispatch-page-size') +if _p != 0 + add_project_arguments('-DGLDISPATCH_PAGE_SIZE=' + _p, language : ['c']) +endif + +# Set EGL_NO_X11 unconditionally, Libglvnd doesn't make any assumptions about +# native display or drawable types, so we don't need X11-specific typedefs for +# them +add_project_arguments('-DEGL_NO_X11', language : ['c']) + +pkg = import('pkgconfig') + +subdir('include') +subdir('src') +subdir('tests') + +pkg.generate( + name : 'libglvnd', + description : 'Vendor-neutral OpenGL dispatch library vendor interface', + version : meson.project_version(), +) + diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..8275770 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,77 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +option( + 'asm', + type : 'feature', + description : 'Use ASM when compiling.' +) +option( + 'x11', + type : 'feature', + description : 'Support the X11 window system.' +) +option( + 'egl', + type : 'boolean', + value : true, + description : 'Support the EGL platform.' +) +option( + 'glx', + type : 'feature', + description : 'Support the GLX platform.' +) +option( + 'gles1', + type : 'boolean', + value : true, + description : 'Support OpenGL ES 1.x.' +) +option( + 'gles2', + type : 'boolean', + value : true, + description : 'Support OpenGL ES 2.x and 3.x.' +) +option( + 'tls', + type : 'feature', + description : 'Use Thread Local Storage.' +) +option( + 'dispatch-page-size', + type : 'integer', + value : 0, + description : 'Page size to align static dispatch stubs.' +) +option( + 'headers', + type : 'boolean', + value : true, + description : 'Install headers for enabled APIs.' +) diff --git a/src/EGL/meson.build b/src/EGL/meson.build new file mode 100644 index 0000000..363bd3b --- /dev/null +++ b/src/EGL/meson.build @@ -0,0 +1,78 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +libegl_dispatch_stubs = static_library( + 'egl_dispatch_stubs', + ['egldispatchstubs.c', g_egldispatchstubs_c, g_egldispatchstubs_h], + include_directories : inc_include, + gnu_symbol_visibility : 'hidden', +) + +libEGL = shared_library( + 'EGL', + [ + 'libegl.c', + 'libeglcurrent.c', + 'libeglmapping.c', + 'libeglvendor.c', + 'libeglerror.c', + ], + c_args : [ + '-DDEFAULT_EGL_VENDOR_CONFIG_DIRS="@0@/glvnd/egl_vendor.d:@1@/glvnd/egl_vendor.d"'.format( + join_paths(get_option('prefix'), get_option('sysconfdir')), + join_paths(get_option('prefix'), get_option('datadir'))), + ], + include_directories : inc_include, + link_args : '-Wl,-Bsymbolic', + link_with : libegl_dispatch_stubs, + dependencies : [ + dep_threads, dep_dl, dep_m, dep_x11_headers, idep_trace, idep_glvnd_pthread, + idep_utils_misc, idep_cjson, idep_winsys_dispatch, idep_gldispatch, + ], + version : '1.1.0', + install : true, + gnu_symbol_visibility : 'hidden', +) + +pkg.generate( + libEGL, + filebase : 'egl', + description : 'EGL library and headers', + version : '1.5', +) + +test( + 'EGL symbols check', + prog_py, + args : [ + files_symbols_check, + '--nm', prog_nm.path(), + '--lib', libEGL, + '--symbols-file', files('egl.symbols'), + ], + suite : ['egl', 'symbols'], +) diff --git a/src/GL/meson.build b/src/GL/meson.build new file mode 100644 index 0000000..6e9c32a --- /dev/null +++ b/src/GL/meson.build @@ -0,0 +1,59 @@ + +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +libGL = shared_library( + 'GL', + ['libgl.c', g_libglglxwrapper_c], + include_directories : [inc_include], + link_args : '-Wl,-Bsymbolic', + dependencies : [ + dep_dl, idep_gldispatch, idep_glapi_gl, idep_glx, idep_utils_misc, + ], + version : '1.7.0', + gnu_symbol_visibility : 'hidden', + install : true, +) + +pkg.generate( + libGL, + filebase : 'gl', + description : 'Legacy OpenGL and GLX library and headers.', + version : '1.2', +) + +test( + 'GL symbols check', + prog_py, + args : [ + files_symbols_check, + '--nm', prog_nm.path(), + '--lib', libGL, + '--symbols-file', files('gl.symbols'), + ], + suite : ['symbols'], +) diff --git a/src/GLESv1/meson.build b/src/GLESv1/meson.build new file mode 100644 index 0000000..d191aa3 --- /dev/null +++ b/src/GLESv1/meson.build @@ -0,0 +1,56 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +libGLESv1 = shared_library( + 'GLESv1_CM', + link_whole : libopengl_main, + dependencies : [ + idep_gldispatch, idep_utils_misc, idep_glapi_glesv1, + ], + version : '1.2.0', + gnu_symbol_visibility : 'hidden', + install : true, +) + +pkg.generate( + libGLESv1, + filebase : 'glesv1_cm', + description : 'OpenGL ES-CM v1 library and headers.', + version : '1.0', +) + +test( + 'GLESv1 symbols check', + prog_py, + args : [ + files_symbols_check, + '--nm', prog_nm.path(), + '--lib', libGLESv1, + '--symbols-file', files('glesv1.symbols'), + ], + suite : ['symbols'], +) diff --git a/src/GLESv2/meson.build b/src/GLESv2/meson.build new file mode 100644 index 0000000..1eaa94d --- /dev/null +++ b/src/GLESv2/meson.build @@ -0,0 +1,57 @@ + +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +libGLESv2 = shared_library( + 'GLESv2', + link_whole : libopengl_main, + dependencies : [ + idep_gldispatch, idep_utils_misc, idep_glapi_glesv2, + ], + version : '2.1.0', + gnu_symbol_visibility : 'hidden', + install : true, +) + +pkg.generate( + libGLESv2, + filebase : 'glesv2', + description : 'OpenGL ES v2/v3 library and headers.', + version : '3.2', +) + +test( + 'GLESv2 symbols check', + prog_py, + args : [ + files_symbols_check, + '--nm', prog_nm.path(), + '--lib', libGLESv2, + '--symbols-file', files('glesv2.symbols'), + ], + suite : ['symbols'], +) diff --git a/src/GLX/meson.build b/src/GLX/meson.build new file mode 100644 index 0000000..912df2d --- /dev/null +++ b/src/GLX/meson.build @@ -0,0 +1,81 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +g_glx_dispatch_stub_list_h = custom_target( + 'g_glx_dispatch_stub_list.h', + input : 'gen_glx_stubs.py', + output : 'g_glx_dispatch_stub_list.h', + command : [prog_py, '@INPUT@'], + capture : true, +) + +libGLX = shared_library( + 'GLX', + [ + 'libglx.c', + 'libglxmapping.c', + 'libglxproto.c', + 'glvnd_genentry.c', + g_glx_dispatch_stub_list_h, + ], + include_directories : [inc_include], + link_args : '-Wl,-Bsymbolic', + dependencies : [ + dep_dl, dep_x11, dep_glx, idep_gldispatch, idep_trace, + idep_glvnd_pthread, idep_utils_misc, + idep_app_error_check, idep_winsys_dispatch, + ], + gnu_symbol_visibility : 'hidden', + install : true, + version : '0.0.0', +) + +inc_glx = include_directories('.') + +idep_glx = declare_dependency( + link_with : libGLX, + include_directories : inc_glx, +) + +pkg.generate( + libGLX, + filebase : 'glx', + description : 'GLX library and headers.', + version : '1.4', +) + +test( + 'GLX symbols check', + prog_py, + args : [ + files_symbols_check, + '--nm', prog_nm.path(), + '--lib', libGLX, + '--symbols-file', files('glx.symbols'), + ], + suite : ['glx', 'symbols'], +) diff --git a/src/GLdispatch/meson.build b/src/GLdispatch/meson.build new file mode 100644 index 0000000..9e34e2d --- /dev/null +++ b/src/GLdispatch/meson.build @@ -0,0 +1,58 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +subdir('vnd-glapi') + +if have_tls + _ver_script = 'export_list_tls.ver' +else + _ver_script = 'export_list_tsd.ver' +endif +_ver_script = join_paths(meson.current_source_dir(), _ver_script) + +libgldispatch = shared_library( + 'GLdispatch', + ['GLdispatch.c'], + include_directories : [include_directories('vnd-glapi'), inc_include], + link_args : ['-Wl,--version-script', _ver_script], + link_with : libglapi, + dependencies : [ + idep_trace, idep_glvnd_pthread, idep_app_error_check, dep_dl, + ], + gnu_symbol_visibility : 'hidden', + link_depends : [_ver_script], + install : true, + version : '0.0.0', +) + +inc_dispatch = include_directories('.') + +idep_gldispatch = declare_dependency( + link_with : libgldispatch, + include_directories : inc_dispatch, +) + diff --git a/src/GLdispatch/vnd-glapi/meson.build b/src/GLdispatch/vnd-glapi/meson.build new file mode 100644 index 0000000..c5319fc --- /dev/null +++ b/src/GLdispatch/vnd-glapi/meson.build @@ -0,0 +1,104 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +inc_vnd_glapi = include_directories('.') + +_libglapi_sources = [] +if have_tls + _libglapi_sources += 'u_current_tls.c' +else + _libglapi_sources += 'u_current_tsd.c' +endif + +_entry_files = [] +if gl_dispatch_type == 'pure_c' + _entry_files += 'entry_pure_c.c' +else + _entry_files += 'entry_common.c' + if gl_dispatch_type != 'arm_tsd' + _entry_files += 'entry_simple_asm.c' + endif + if gl_dispatch_type == 'x86_tls' + _entry_files += 'entry_x86_tls.c' + elif gl_dispatch_type == 'x86_tsd' + _entry_files += 'entry_x86_tsd.c' + elif gl_dispatch_type == 'x86_64_tls' + _entry_files += 'entry_x86_64_tls.c' + elif gl_dispatch_type == 'x86_64_tsd' + _entry_files += 'entry_x86_64_tsd.c' + elif gl_dispatch_type == 'arm_tsd' + _entry_files += 'entry_armv7_tsd.c' + elif gl_dispatch_type == 'aarch64_tsd' + _entry_files += 'entry_aarch64_tsd.c' + elif gl_dispatch_type == 'ppc64le_tls' + _entry_files += 'entry_aarch64_tls.c' + elif gl_dispatch_type == 'ppc64le_tsd' + _entry_files += 'entry_aarch64_tsd.c' + else + error('No matching ASM file for @0@'.format(gl_dispatch_type)) + endif +endif + +libglapi = static_library( + 'libglapi', + [ + 'mapi_glapi.c', + 'stub.c', + 'table.c', + _libglapi_sources, + glapi_mapi_tmp_h, + _entry_files, + ], + c_args : ['-DMAPI_ABI_HEADER="@0@"'.format(glapi_mapi_tmp_h.full_path())], + include_directories : inc_include, + dependencies : idep_utils_misc, + gnu_symbol_visibility : 'hidden', +) + +foreach g : ['gl', 'opengl', 'glesv1', 'glesv2'] + name = 'glapi_' + g + header = get_variable('g_glapi_mapi_@0@_tmp_h'.format(g)) + + _lib = static_library( + name, + ['stub.c', _entry_files, header], + c_args : [ + '-DSTATIC_DISPATCH_ONLY', + '-DMAPI_ABI_HEADER="@0@"'.format(header.full_path()), + ], + include_directories : [inc_include, inc_util], + gnu_symbol_visibility : 'hidden', + ) + + _dep = declare_dependency( + link_with : _lib, + include_directories : inc_vnd_glapi, + ) + + set_variable('idep_' + name, _dep) +endforeach + diff --git a/src/OpenGL/meson.build b/src/OpenGL/meson.build new file mode 100644 index 0000000..a08c897 --- /dev/null +++ b/src/OpenGL/meson.build @@ -0,0 +1,61 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +libopengl_main = static_library( + 'opengl_main', + ['libopengl.c'], + include_directories : [inc_util, inc_vnd_glapi, inc_include, inc_dispatch], + gnu_symbol_visibility : 'hidden', +) + +libOpenGL = shared_library( + 'OpenGL', + link_whole : libopengl_main, + dependencies : [idep_gldispatch, idep_glapi_opengl, idep_utils_misc], + gnu_symbol_visibility : 'hidden', + install : true, + version : '0.0.0', +) + +pkg.generate( + libOpenGL, + filebase : 'opengl', + description : 'OpenGL (without GLX) library and headers.', + version : '4.5', +) + +test( + 'OpenGL symbols check', + prog_py, + args : [ + files_symbols_check, + '--nm', prog_nm.path(), + '--lib', libOpenGL, + '--symbols-file', files('ogl.symbols'), + ], + suite : ['symbols'], +) diff --git a/src/generate/meson.build b/src/generate/meson.build new file mode 100644 index 0000000..068af51 --- /dev/null +++ b/src/generate/meson.build @@ -0,0 +1,74 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + + +foreach t : [['glapi_mapi_tmp.h', 'gldispatch'], + ['g_glapi_mapi_gl_tmp.h', 'gl'], + ['g_glapi_mapi_opengl_tmp.h', 'opengl'], + ['g_glapi_mapi_glesv1_tmp.h', 'glesv1'], + ['g_glapi_mapi_glesv2_tmp.h', 'glesv2']] + file = t[0] + target = t[1] + var = file.underscorify() + + _t = custom_target( + file, + input : ['gen_gldispatch_mapi.py', 'xml/gl.xml', 'xml/gl_other.xml'], + output : file, + command : [prog_py, '@INPUT0@', target, '@INPUT1@', '@INPUT2@'], + depend_files : files('genCommon.py'), + capture : true, + ) + + set_variable(var, _t) +endforeach + +foreach target : ['header', 'source'] + ext = target == 'header' ? 'h' : 'c' + _t = custom_target( + 'g_egldispatchstubs.' + ext, + input : ['gen_egl_dispatch.py', 'eglFunctionList.py', 'xml/egl.xml'], + output : ['g_egldispatchstubs.' + ext], + command : [ + prog_py, '@INPUT0@', target, '@INPUT1@', '@INPUT2@', + ], + depend_files : files('genCommon.py'), + capture : true, + ) + + set_variable('g_egldispatchstubs_' + ext, _t) +endforeach + +g_libglglxwrapper_c = custom_target( + 'g_libglglxwrapper.c', + input : ['gen_libgl_glxstubs.py', 'xml/glx.xml', 'xml/glx_other.xml'], + output : ['g_libglglxwrapper.c'], + command : [prog_py, '@INPUT@'], + depend_files : files('genCommon.py'), + capture : true, +) + diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..0d57696 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,48 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +subdir('util') +subdir('generate') +subdir('GLdispatch') +subdir('OpenGL') + +if get_option('egl') + subdir('EGL') +endif + +if with_glx + subdir('GLX') + subdir('GL') +endif + +if get_option('gles1') + subdir('GLESv1') +endif +if get_option('gles2') + subdir('GLESv2') +endif + diff --git a/src/util/meson.build b/src/util/meson.build new file mode 100644 index 0000000..27c9f69 --- /dev/null +++ b/src/util/meson.build @@ -0,0 +1,100 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +inc_util = include_directories('.') + +libglvnd_pthread = static_library( + 'glvnd_pthread', + ['glvnd_pthread.c'], + dependencies : dep_dl, + gnu_symbol_visibility : 'hidden', +) + +idep_glvnd_pthread = declare_dependency( + link_with : libglvnd_pthread, + include_directories : inc_util, +) + +libapp_error_check = static_library( + 'app_error_check', + ['app_error_check.c'], + include_directories : inc_include, + gnu_symbol_visibility : 'hidden', +) + +idep_app_error_check = declare_dependency( + link_with : libapp_error_check, + include_directories : inc_util, +) + +libutils_misc = static_library( + 'utils_misc', + ['utils_misc.c'], + gnu_symbol_visibility : 'hidden', +) + +idep_utils_misc = declare_dependency( + link_with : libutils_misc, + include_directories : inc_util, +) + +libtrace = static_library( + 'trace', + ['trace.c'], + gnu_symbol_visibility : 'hidden', +) + +idep_trace = declare_dependency( + link_with : libtrace, + include_directories : inc_util, +) + +inc_uthash = include_directories('uthash/src') + +libwinsys_dispatch = static_library( + 'winsys_dispatch', + ['winsys_dispatch.c'], + include_directories : [inc_include, inc_uthash], + gnu_symbol_visibility : 'hidden', +) + +idep_winsys_dispatch = declare_dependency( + link_with : libwinsys_dispatch, + include_directories : [inc_util, inc_uthash], +) + +libcjson = static_library( + 'cJSON', + ['cJSON.c'], + gnu_symbol_visibility : 'hidden', +) + +idep_cjson = declare_dependency( + link_with : libcjson, + include_directories : inc_util, +) + diff --git a/tests/dummy/meson.build b/tests/dummy/meson.build new file mode 100644 index 0000000..15befbf --- /dev/null +++ b/tests/dummy/meson.build @@ -0,0 +1,82 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +libpatchentrypoints = static_library( + 'patchentrypoints', + ['patchentrypoints.c'], + include_directories : [inc_include, inc_util, inc_dispatch], +) + +prog_cp = find_program('cp') + +if with_glx + libGLX_dummy = shared_module( + 'GLX_dummy', + ['GLX_dummy.c'], + include_directories : [inc_dispatch, inc_glx, inc_include], + link_with: [libpatchentrypoints], + dependencies : [idep_trace, idep_utils_misc], + ) + + # The ICD loader expects to load a .so.0, but meson generates the .X.Y.Z + # links at install time, the build time directories only have the plain .so + # files, so we copy the .so to .so.0 so tests will work + custom_target( + 'GLX_dummy.so.0', + input : [libGLX_dummy], + output : 'libGLX_dummy.so.0', + command : [prog_cp, '@INPUT@', '@OUTPUT@'], + build_by_default : true, + ) +endif + +if get_option('egl') + foreach v : ['0', '1'] + _lib = shared_module( + 'EGL_dummy' + v, + ['EGL_dummy.c'], + c_args : ['-DDUMMY_VENDOR_NAME="dummy@0@"'.format(v)], + include_directories : [inc_include], + link_with: [libpatchentrypoints], + dependencies : [idep_glvnd_pthread], + ) + + set_variable('libEGL_dummy' + v, _lib) + + # see The comment in the with_glx block + custom_target( + 'EGL_dummy@0@.so.0'.format(v), + input : _lib, + output : 'libEGL_dummy@0@.so.0'.format(v), + command : [prog_cp, '@INPUT@', '@OUTPUT@'], + build_by_default : true, + ) + endforeach +endif + +dummy_build_dir = meson.current_build_dir() + diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..3509a57 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,214 @@ +# Copyright © 2019 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and/or associated documentation files (the +# "Materials"), to deal in the Materials without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Materials, and to +# permit persons to whom the Materials are furnished to do so, subject to +# the following conditions: + +# The above copyright notice and this permission notice shall be included +# unaltered in all copies or substantial portions of the Materials. +# Any additions, deletions, or changes to the original source files +# must be clearly indicated in accompanying documentation. + +# If only executable code is distributed, then the accompanying +# documentation must state that "this software is based in part on the +# work of the Khronos Group." + +# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +subdir('dummy') + +exe_gldispatch = executable( + 'testgldispatch', + ['testgldispatch.c'], + include_directories : [inc_include], + link_with : [libOpenGL, libpatchentrypoints], + dependencies : [idep_gldispatch, idep_utils_misc, dep_threads], +) + +foreach k : [['static', ['-s']], + ['static thr', ['-s', '-t']], + ['generated', ['-g']], + ['generated end', ['-g', '-l']], + ['generated thr', ['-g', '-t']], + ['generated thr end', ['-g', '-t', '-l']], + ['patched', ['-s', '-g', '-p']], + ['patched end', ['-s', '-g', '-p', '-l']], + ['patched thr', ['-s', '-g', '-p', '-t']], + ['patched thr end', ['-s', '-g', '-p', '-t', '-l']]] + test( + 'gldispatch ' + k[0], + exe_gldispatch, + args : k[1], + suite : ['gldispatch'], + ) +endforeach + +test( + 'testgldispatchthread', + executable( + 'testgldispatchthread', + ['testgldispatchthread.c'], + include_directories : [inc_include], + dependencies : [idep_gldispatch, dep_threads], + ), + suite : ['gldispatch'], +) + +_env_ld = 'LD_LIBRARY_PATH=@0@/'.format(dummy_build_dir) + +if with_glx + env_glx = [ + '__GLX_FORCE_VENDOR_LIBRARY_0=dummy', + _env_ld, + ] + + test( + 'glxcreatecontext', + executable( + 'glxcreatecontext', + ['testglxcreatecontext.c', 'test_utils.c'], + include_directories : [inc_include], + link_with : libOpenGL, + dependencies : [idep_glx, dep_x11], + ), + env : env_glx, + suite : ['glx'], + ) + + exe_glxmakecurrent = executable( + 'glxmakecurrent', + ['testglxmakecurrent.c', 'test_utils.c'], + include_directories : [inc_include], + link_with : [libOpenGL], + dependencies : [ + dep_dl, dep_x11, idep_glvnd_pthread, idep_trace, idep_utils_misc, + idep_glx, + ], + ) + + foreach t : [['basic', ['-t', '1', '-i', '1'], env_glx], + ['loop', ['-t', '1', '-i', '250'], env_glx], + ['threads', ['-t', '5', '-i', '20000'], [env_glx, 'LD_PRELOAD=libpthread.so.0']], + ] + test( + 'glxmakecurrent (@0@)'.format(t[0]), + exe_glxmakecurrent, + args : t[1], + env : t[2], + suite : ['glx'], + ) + endforeach + + test( + 'glxmakecurrent (oldlink)', + executable( + 'glxmakecurrent_oldlink', + ['testglxmakecurrent.c', 'test_utils.c'], + include_directories : [inc_include], + link_with : [libGL], + dependencies : [ + dep_dl, dep_x11, idep_glvnd_pthread, idep_trace, idep_utils_misc, + ], + ), + args : ['-t', '1', '-i', '1'], + env : env_glx, + suite : ['glx'], + ) + + exe_glxgetprocaddress = executable( + 'glxgetprocaddress', + ['testglxgetprocaddress.c'], + include_directories : [inc_include], + dependencies : [dep_x11, idep_glx, idep_gldispatch], + ) + + test( + 'glxgetprocess', + exe_glxgetprocaddress, + env : env_glx, + suite : ['glx'], + ) + + test( + 'glxgetprocess_genentry', + exe_glxgetprocaddress, + env : env_glx, + suite : ['glx'], + ) + + test( + 'glxgetprocaddress_genentry', + executable( + 'testglxgetprocaddress_genentry', + ['testglxgetprocaddress_genentry.c'], + include_directories : [inc_include], + dependencies : [dep_x11, idep_glx], + ), + env : env_glx, + suite : ['glx'], + ) + + test( + 'glxgetclientstr', + executable( + 'glxgetclientstr', + ['testglxgetclientstr.c'], + include_directories : [inc_include], + link_with : libOpenGL, + dependencies : [dep_x11, idep_glx, idep_trace, idep_utils_misc], + ), + env : env_glx, + suite : ['glx'], + ) + + test( + 'glxgetqueryversion', + executable( + 'glxqueryversion', + ['testglxqueryversion.c'], + include_directories : [inc_include], + link_with : libOpenGL, + dependencies : [dep_x11, idep_glx], + ), + env : env_glx, + suite : ['glx'], + ) +endif + +if get_option('egl') + env_egl = [ + '__EGL_VENDOR_LIBRARY_DIRS=@0@'.format(join_paths(meson.current_source_dir(), 'json')), + _env_ld, + ] + + foreach t : [['egldisplay', [], []], + ['egldevice', [], []], + ['eglgetprocaddress', [], []], + ['eglmakecurrent', [libOpenGL], [idep_utils_misc]], + ['eglerror', [libOpenGL], []], + ['egldebug', [], []]] + test( + t[0], + executable( + t[0], + ['test@0@.c'.format(t[0]), 'egl_test_utils.c'], + include_directories : [inc_include], + link_with : [libEGL, t[1]], + dependencies : [t[2]], + ), + env : env_egl, + suite : ['egl'], + ) + endforeach +endif +