Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 1 | ############################################################################# |
| 2 | # |
| 3 | # Copyright (C) 2019 Collabora Ltd |
| 4 | # |
| 5 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | # copy of this software and associated documentation files (the "Software"), |
| 7 | # to deal in the Software without restriction, including without limitation |
| 8 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | # and/or sell copies of the Software, and to permit persons to whom the |
| 10 | # Software is furnished to do so, subject to the following conditions: |
| 11 | # |
| 12 | # The above copyright notice and this permission notice shall be included |
| 13 | # in all copies or substantial portions of the Software. |
| 14 | # |
| 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 19 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 20 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 21 | # OTHER DEALINGS IN THE SOFTWARE. |
| 22 | # |
| 23 | |
| 24 | project( |
| 25 | 'virglrenderer', 'c', |
Gert Wollny | 2cd0803 | 2020-11-13 17:37:29 +0100 | [diff] [blame] | 26 | version: '0.9.0', |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 27 | license : 'MIT', |
| 28 | meson_version : '>= 0.46', |
Lepton Wu | a97a391 | 2019-10-21 19:22:14 -0700 | [diff] [blame] | 29 | default_options : ['buildtype=release', 'b_ndebug=if-release', |
| 30 | 'warning_level=3', 'c_std=gnu11'] |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 31 | ) |
| 32 | |
Gert Wollny | 471185e | 2019-12-06 10:04:06 +0100 | [diff] [blame] | 33 | # To change only before doing a release: |
| 34 | # |
| 35 | # 1. Incrememnt the revision |
| 36 | # 2. If the interface was changed in an compatible way increment the |
| 37 | # interface age |
| 38 | # 3. If the ABI has changed in an incompatible way increment the binary_age |
| 39 | # and set revision and interface_age to zero |
| 40 | |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 41 | binary_age = 1 |
Gert Wollny | 2cd0803 | 2020-11-13 17:37:29 +0100 | [diff] [blame] | 42 | interface_age = 5 |
| 43 | revision = 3 |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 44 | |
| 45 | cc = meson.get_compiler('c') |
| 46 | |
| 47 | add_project_arguments('-DHAVE_CONFIG_H=1', language : 'c') |
| 48 | add_project_arguments('-D_GNU_SOURCE=1', language : 'c') |
Chia-I Wu | 491afdc | 2020-07-07 20:27:12 -0700 | [diff] [blame] | 49 | add_project_arguments('-DVIRGL_RENDERER_UNSTABLE_APIS', language : 'c') |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 50 | |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 51 | warnings = [ |
| 52 | '-Werror=implicit-function-declaration', |
| 53 | '-Werror=missing-prototypes', |
| 54 | '-Wmissing-prototypes', |
Chia-I Wu | 82d05bf | 2020-04-23 12:51:09 -0700 | [diff] [blame] | 55 | '-Werror=int-to-pointer-cast', |
| 56 | '-Wno-overlength-strings', |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 57 | ] |
| 58 | |
| 59 | foreach w : warnings |
| 60 | if cc.has_argument(w) |
| 61 | add_project_arguments(w, language : 'c') |
| 62 | endif |
| 63 | endforeach |
| 64 | |
Gert Wollny | 1e581b6 | 2019-12-23 16:48:52 +0100 | [diff] [blame] | 65 | flags = [ |
| 66 | '-fvisibility=hidden', |
| 67 | ] |
| 68 | |
| 69 | foreach f : flags |
| 70 | if cc.has_argument(f) |
| 71 | add_project_arguments(f, language : 'c') |
| 72 | endif |
| 73 | endforeach |
| 74 | |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 75 | prog_python = import('python').find_installation('python3') |
| 76 | |
| 77 | libdrm_dep = dependency('libdrm', version : '>=2.4.50') |
| 78 | thread_dep = dependency('threads') |
Gurchetan Singh | 256ef78 | 2019-12-03 17:41:40 -0800 | [diff] [blame] | 79 | epoxy_dep = dependency('epoxy', version: '>= 1.5.4') |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 80 | m_dep = cc.find_library('m') |
| 81 | |
| 82 | conf_data = configuration_data() |
| 83 | conf_data.set('VERSION', '0.8.1') |
| 84 | |
Gert Wollny | 19d65e8 | 2020-11-09 17:17:49 +0100 | [diff] [blame] | 85 | with_tracing = get_option('tracing') |
| 86 | |
| 87 | if with_tracing != 'none' |
Gert Wollny | fab5e73 | 2021-01-29 16:14:52 +0100 | [diff] [blame] | 88 | if not cc.compiles('void f(void* v){} int main () { void *dummy __attribute__((cleanup (f))) = 0;}') |
Gert Wollny | 19d65e8 | 2020-11-09 17:17:49 +0100 | [diff] [blame] | 89 | error('Tracing requires compiler support for __attribute__((cleanup))') |
| 90 | endif |
| 91 | |
| 92 | endif |
| 93 | |
John Bates | e64afcf | 2021-02-04 11:04:40 -0800 | [diff] [blame] | 94 | if with_tracing == 'percetto' |
| 95 | # percetto uses C++ internally, so we need to link with C++. |
| 96 | # TODO: remove -lstdc++ when percetto is a shared library. |
| 97 | add_project_link_arguments('-lstdc++', language : 'c') |
| 98 | percetto_dep = dependency('percetto', version : '>=0.0.8') |
| 99 | conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERCETTO') |
| 100 | endif |
| 101 | |
Gert Wollny | 19d65e8 | 2020-11-09 17:17:49 +0100 | [diff] [blame] | 102 | if with_tracing == 'perfetto' |
| 103 | vperfetto_min_dep = dependency('vperfetto_min') |
| 104 | conf_data.set('ENABLE_TRACING', 'TRACE_WITH_PERFETTO') |
| 105 | endif |
| 106 | |
Gert Wollny | 024a0d9 | 2020-11-11 10:58:01 +0100 | [diff] [blame] | 107 | if with_tracing == 'stderr' |
| 108 | conf_data.set('ENABLE_TRACING', 'TRACE_WITH_STDERR') |
| 109 | endif |
| 110 | |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 111 | if cc.has_header('sys/uio.h') |
| 112 | conf_data.set('HAVE_SYS_UIO_H', 1) |
| 113 | endif |
| 114 | |
| 115 | if cc.has_header('dlfcn.h') |
| 116 | conf_data.set('HAVE_DLFCN_H', 1) |
| 117 | endif |
| 118 | |
| 119 | if cc.has_header('pthread.h') |
| 120 | conf_data.set('HAVE_PTHREAD', 1) |
| 121 | endif |
| 122 | |
| 123 | if cc.has_header('sys/eventfd.h') |
| 124 | conf_data.set('HAVE_EVENTFD_H', 1) |
| 125 | endif |
| 126 | |
Nathan Owens | 9c3b8f4 | 2019-12-27 09:27:12 -0600 | [diff] [blame] | 127 | if cc.has_header('sys/select.h') |
| 128 | conf_data.set('HAVE_SYS_SELECT_H', 1) |
| 129 | endif |
| 130 | |
Leo | c6f20d8 | 2019-11-28 13:31:49 +0100 | [diff] [blame] | 131 | if host_machine.endian() == 'little' |
| 132 | conf_data.set('PIPE_ARCH_LITTLE_ENDIAN', true) |
| 133 | elif host_machine.endian() == 'big' |
| 134 | conf_data.set('PIPE_ARCH_BIG_ENDIAN', true) |
| 135 | else |
| 136 | error('It wasn\'t possible to figure out the endianess of the machine') |
| 137 | endif |
| 138 | |
| 139 | pipe_arch = host_machine.cpu_family() |
| 140 | |
| 141 | if pipe_arch == 'x86' |
| 142 | conf_data.set('PIPE_ARCH_X86', true) |
| 143 | elif pipe_arch == 'x86_64' |
| 144 | conf_data.set('PIPE_ARCH_X86_64', true) |
| 145 | elif pipe_arch == 'ppc' |
| 146 | conf_data.set('PIPE_ARCH_PPC', true) |
| 147 | elif pipe_arch == 'ppc64' |
| 148 | conf_data.set('PIPE_ARCH_PPC_64', true) |
| 149 | elif pipe_arch == 's390x' |
| 150 | conf_data.set('PIPE_ARCH_S390', true) |
| 151 | elif pipe_arch == 'arm' |
| 152 | conf_data.set('PIPE_ARCH_ARM', true) |
| 153 | elif pipe_arch == 'aarch64' |
| 154 | conf_data.set('PIPE_ARCH_AARCH64', true) |
| 155 | else |
| 156 | warning('Arch used is not supported') |
| 157 | endif |
| 158 | |
Gurchetan Singh | f3e4907 | 2020-01-03 09:31:55 -0800 | [diff] [blame] | 159 | if get_option('buildtype') == 'debug' |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 160 | add_global_arguments('-DDEBUG=1', language : 'c') |
| 161 | endif |
| 162 | |
| 163 | platforms = get_option('platforms') |
| 164 | |
| 165 | require_egl = platforms.contains('egl') |
| 166 | require_glx = platforms.contains('glx') |
| 167 | auto_egl_glx = platforms.contains('auto') |
| 168 | |
| 169 | with_egl = require_egl or auto_egl_glx |
| 170 | with_glx = require_glx or auto_egl_glx |
| 171 | |
| 172 | have_egl = false |
| 173 | have_glx = false |
| 174 | |
Gurchetan Singh | 1fcd27d | 2020-03-25 17:02:34 -0700 | [diff] [blame] | 175 | with_minigbm_allocation = get_option('minigbm_allocation') |
| 176 | if with_minigbm_allocation |
| 177 | conf_data.set('ENABLE_MINIGBM_ALLOCATION', 1) |
Lepton Wu | c162f33 | 2019-12-10 06:06:07 +0000 | [diff] [blame] | 178 | _gbm_ver = '18.0.0' |
| 179 | else |
| 180 | _gbm_ver = '0.0.0' |
| 181 | endif |
| 182 | |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 183 | if with_egl |
Jason Macnak | 9e6b3e3 | 2019-12-27 21:31:53 -0800 | [diff] [blame] | 184 | if cc.has_header('epoxy/egl.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_egl') == '1' |
Lepton Wu | c162f33 | 2019-12-10 06:06:07 +0000 | [diff] [blame] | 185 | gbm_dep = dependency('gbm', version: '>= ' + _gbm_ver, required: require_egl) |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 186 | have_egl = gbm_dep.found() |
| 187 | conf_data.set('HAVE_EPOXY_EGL_H', 1) |
| 188 | else |
| 189 | assert(not require_egl, |
| 190 | 'egl was explicitely requested but it is not supported by epoxy') |
| 191 | endif |
| 192 | endif |
| 193 | |
| 194 | if with_glx |
Jason Macnak | 9e6b3e3 | 2019-12-27 21:31:53 -0800 | [diff] [blame] | 195 | if cc.has_header('epoxy/glx.h', dependencies: epoxy_dep) and epoxy_dep.get_pkgconfig_variable('epoxy_has_glx') == '1' |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 196 | glx_dep = dependency('x11', required: require_glx) |
| 197 | have_glx = glx_dep.found() |
| 198 | conf_data.set('HAVE_EPOXY_GLX_H', 1) |
| 199 | else |
| 200 | assert(not require_glx, |
| 201 | 'glx was explicitely requested but it is not supported by epoxy') |
| 202 | endif |
| 203 | endif |
| 204 | |
Chia-I Wu | 6e12fa6 | 2020-03-24 17:07:11 -0700 | [diff] [blame] | 205 | with_venus = get_option('venus-experimental') |
Chia-I Wu | d67cfcb | 2021-06-14 11:30:33 -0700 | [diff] [blame] | 206 | with_venus_validate = get_option('venus-validate') |
Chia-I Wu | 6e12fa6 | 2020-03-24 17:07:11 -0700 | [diff] [blame] | 207 | if with_venus |
| 208 | venus_dep = dependency('vulkan') |
| 209 | conf_data.set('ENABLE_VENUS', 1) |
Chia-I Wu | d67cfcb | 2021-06-14 11:30:33 -0700 | [diff] [blame] | 210 | |
| 211 | if with_venus_validate |
| 212 | conf_data.set('ENABLE_VENUS_VALIDATE', 1) |
| 213 | endif |
Chia-I Wu | 6e12fa6 | 2020-03-24 17:07:11 -0700 | [diff] [blame] | 214 | endif |
| 215 | |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 216 | if cc.compiles('void __attribute__((hidden)) func() {}') |
| 217 | conf_data.set('HAVE_FUNC_ATTRIBUTE_VISIBILITY', 1) |
| 218 | endif |
| 219 | |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 220 | configure_file(input : 'config.h.meson', |
| 221 | output : 'config.h', |
| 222 | configuration : conf_data) |
| 223 | |
| 224 | pkgconf_data = configuration_data() |
| 225 | pkgconf_data.set('PACKAGE_VERSION', meson.project_version()) |
| 226 | pkgconf_data.set('prefix', get_option('prefix')) |
| 227 | pkgconf_data.set('exec_prefix', '${prefix}') |
| 228 | pkgconf_data.set('libdir', '${prefix}/' + get_option('libdir')) |
| 229 | pkgconf_data.set('includedir', '${prefix}/' + get_option('includedir')) |
| 230 | |
| 231 | pkg_config = configure_file(input : 'virglrenderer.pc.in', |
| 232 | output : 'virglrenderer.pc', |
| 233 | configuration : pkgconf_data) |
| 234 | |
| 235 | install_data(pkg_config, |
| 236 | install_dir: get_option('libdir') + '/pkgconfig') |
| 237 | |
Leo | 5b87079 | 2019-11-28 13:32:14 +0100 | [diff] [blame] | 238 | inc_configuration = include_directories(['.', 'src']) |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 239 | |
| 240 | with_fuzzer = get_option('fuzzer') |
| 241 | with_tests = get_option('tests') |
| 242 | with_valgrind = get_option('valgrind') |
| 243 | |
| 244 | subdir('src') |
| 245 | subdir('vtest') |
| 246 | |
| 247 | if with_tests |
| 248 | subdir('tests') |
| 249 | endif |
| 250 | |
| 251 | lines = [ |
| 252 | '', |
| 253 | 'prefix: ' + get_option('prefix'), |
| 254 | 'libdir: ' + get_option('libdir'), |
| 255 | '', |
| 256 | 'c_args: ' + (' ').join(get_option('c_args')), |
| 257 | '', |
| 258 | ] |
| 259 | |
| 260 | lines += 'egl: ' + (have_egl ? 'yes' : 'no') |
| 261 | lines += 'glx: ' + (have_glx ? 'yes' : 'no') |
| 262 | lines += '' |
Gurchetan Singh | 1fcd27d | 2020-03-25 17:02:34 -0700 | [diff] [blame] | 263 | lines += 'minigbm_alloc: ' + (with_minigbm_allocation ? 'yes' : 'no' ) |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 264 | lines += '' |
Chia-I Wu | 6e12fa6 | 2020-03-24 17:07:11 -0700 | [diff] [blame] | 265 | lines += 'venus: ' + (with_venus ? 'yes' : 'no' ) |
| 266 | lines += '' |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 267 | lines += 'tests: ' + (with_tests ? 'yes' : 'no' ) |
| 268 | lines += 'fuzzer: ' + (with_fuzzer ? 'yes' : 'no' ) |
Gert Wollny | 19d65e8 | 2020-11-09 17:17:49 +0100 | [diff] [blame] | 269 | lines += 'tracing: ' + with_tracing |
Gert Wollny | 17c2368 | 2019-09-16 13:07:07 +0200 | [diff] [blame] | 270 | |
| 271 | indent = ' ' |
| 272 | summary = indent + ('\n' + indent).join(lines) |
| 273 | message('\n\nConfiguration summary:\n@0@\n'.format(summary)) |