|
| 1 | +project('v8', 'c', 'cpp', |
| 2 | + version: '10.6.122', |
| 3 | + default_options: [ |
| 4 | + 'cpp_std=gnu++17', |
| 5 | + 'cpp_eh=none', |
| 6 | + 'cpp_rtti=false', |
| 7 | + ], |
| 8 | +) |
| 9 | + |
| 10 | +api_version = '10.0' |
| 11 | + |
| 12 | +cc = meson.get_compiler('c') |
| 13 | +cc_native = meson.get_compiler('c', native: true) |
| 14 | + |
| 15 | +cpp = meson.get_compiler('cpp') |
| 16 | +cpp_options = [ |
| 17 | + 'cpp_std=gnu++17', |
| 18 | + 'cpp_eh=none', |
| 19 | + 'cpp_rtti=false', |
| 20 | +] |
| 21 | + |
| 22 | +build_os = build_machine.system() |
| 23 | +host_os = host_machine.system() |
| 24 | + |
| 25 | +target_conditionals_prefix = '#include <TargetConditionals.h>' |
| 26 | +is_macos_src = target_conditionals_prefix + ''' |
| 27 | +#if !TARGET_OS_OSX |
| 28 | +# error Not macOS |
| 29 | +#endif |
| 30 | +''' |
| 31 | +is_ios_src = target_conditionals_prefix + ''' |
| 32 | +#if !TARGET_OS_IOS |
| 33 | +# error Not iOS |
| 34 | +#endif |
| 35 | +''' |
| 36 | + |
| 37 | +if build_os == 'windows' |
| 38 | + build_os = 'win' |
| 39 | +elif build_os == 'darwin' |
| 40 | + if cc_native.compiles(is_macos_src, name: 'compiling on macOS') |
| 41 | + build_os = 'macos' |
| 42 | + elif cc_native.compiles(is_ios_src, name: 'compiling on iOS') |
| 43 | + build_os = 'ios' |
| 44 | + endif |
| 45 | +elif build_os == 'linux' and cc_native.has_header('android/api-level.h') |
| 46 | + build_os = 'android' |
| 47 | +endif |
| 48 | +if host_os == 'windows' |
| 49 | + host_os = 'win' |
| 50 | +elif host_os == 'darwin' |
| 51 | + if cc.compiles(is_macos_src, name: 'compiling for macOS') |
| 52 | + host_os = 'macos' |
| 53 | + elif cc.compiles(is_ios_src, name: 'compiling for iOS') |
| 54 | + host_os = 'ios' |
| 55 | + endif |
| 56 | +elif host_os == 'linux' and cc.has_header('android/api-level.h') |
| 57 | + host_os = 'android' |
| 58 | +endif |
| 59 | +host_os_nick = (host_os == 'macos') ? 'mac' : host_os |
| 60 | + |
| 61 | +v8_arch_from_cpu_family = { |
| 62 | + 'x86': 'ia32', |
| 63 | + 'x86_64': 'x64', |
| 64 | + 'arm': 'arm', |
| 65 | + 'aarch64': 'arm64', |
| 66 | +} |
| 67 | +build_arch = v8_arch_from_cpu_family[build_machine.cpu_family()] |
| 68 | +host_arch = v8_arch_from_cpu_family[host_machine.cpu_family()] |
| 69 | +host_is_64bit = cc.sizeof('void *') == 8 |
| 70 | + |
| 71 | +if host_os in ['macos', 'ios'] and host_arch == 'arm64' |
| 72 | + have_ptrauth_src = '''#ifdef __clang__ |
| 73 | +# if __has_feature (ptrauth_calls) |
| 74 | +# define HAVE_PTRAUTH 1 |
| 75 | +# endif |
| 76 | +#endif |
| 77 | +
|
| 78 | +#ifndef HAVE_PTRAUTH |
| 79 | +# error Pointer authentication not supported |
| 80 | +#endif |
| 81 | +''' |
| 82 | + have_ptrauth = cc.compiles(have_ptrauth_src, name: 'pointer authentication') |
| 83 | +else |
| 84 | + have_ptrauth = false |
| 85 | +endif |
| 86 | + |
| 87 | +zlib_dep = dependency('zlib') |
| 88 | +zlib_native_dep = dependency('zlib', native: true) |
| 89 | + |
| 90 | +extra_libs_private = [] |
| 91 | +if host_os == 'android' |
| 92 | + extra_libs_private += '-llog' |
| 93 | +endif |
| 94 | + |
| 95 | +public_incdirs = include_directories('include') |
| 96 | +internal_incdirs = include_directories( |
| 97 | + '.', |
| 98 | + 'src', |
| 99 | + 'include', |
| 100 | +) |
| 101 | + |
| 102 | +config_args = [ |
| 103 | + '-DV8_HAVE_TARGET_OS', |
| 104 | + '-DV8_TARGET_OS_' + host_os.to_upper(), |
| 105 | + '-DV8_TARGET_ARCH_' + host_arch.to_upper(), |
| 106 | + '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64', |
| 107 | + '-DV8_ATOMIC_OBJECT_FIELD_WRITES', |
| 108 | + '-DV8_ENABLE_LAZY_SOURCE_POSITIONS', |
| 109 | + '-DV8_WIN64_UNWINDING_INFO', |
| 110 | + '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH', |
| 111 | + '-DV8_ALLOCATION_FOLDING', |
| 112 | + '-DV8_ALLOCATION_SITE_TRACKING', |
| 113 | + '-DV8_DEPRECATION_WARNINGS', |
| 114 | + '-DV8_IMMINENT_DEPRECATION_WARNINGS', |
| 115 | + '-DV8_RUNTIME_CALL_STATS', |
| 116 | + '-DV8_DISABLE_TESTS', |
| 117 | + '-DDYNAMIC_ANNOTATIONS_ENABLED=0', |
| 118 | + '-DOFFICIAL_BUILD', |
| 119 | + '-DUSE_SYSTEM_ZLIB', |
| 120 | + '-DNVALGRIND', |
| 121 | +] |
| 122 | + |
| 123 | +embedder_string = get_option('embedder_string') |
| 124 | +if embedder_string != '' |
| 125 | + config_args += f'-DV8_EMBEDDER_STRING="@embedder_string@"' |
| 126 | +endif |
| 127 | + |
| 128 | +if have_ptrauth |
| 129 | + config_args += '-DV8_TARGET_PTRAUTH' |
| 130 | +endif |
| 131 | + |
| 132 | +enable_advanced_bigint_algorithms = get_option('advanced_bigint_algorithms').allowed() |
| 133 | +if enable_advanced_bigint_algorithms |
| 134 | + config_args += '-DV8_ADVANCED_BIGINT_ALGORITHMS' |
| 135 | +endif |
| 136 | + |
| 137 | +if get_option('pointer_compression').auto() |
| 138 | + enable_pointer_compression = host_is_64bit |
| 139 | +else |
| 140 | + enable_pointer_compression = get_option('pointer_compression').allowed() |
| 141 | +endif |
| 142 | +if enable_pointer_compression |
| 143 | + config_args += '-DCPPGC_POINTER_COMPRESSION' |
| 144 | +endif |
| 145 | + |
| 146 | +if get_option('shared_ro_heap').auto() |
| 147 | + enable_shared_ro_heap = enable_pointer_compression |
| 148 | +else |
| 149 | + enable_shared_ro_heap = get_option('shared_ro_heap').allowed() |
| 150 | +endif |
| 151 | +if enable_shared_ro_heap |
| 152 | + config_args += '-DV8_SHARED_RO_HEAP' |
| 153 | +endif |
| 154 | + |
| 155 | +caged_heap_supported = host_is_64bit |
| 156 | +if get_option('caged_heap').auto() |
| 157 | + enable_caged_heap = caged_heap_supported |
| 158 | +elif get_option('caged_heap').enabled() |
| 159 | + if not caged_heap_supported |
| 160 | + error('CppGC caged heap requires 64bit platforms') |
| 161 | + endif |
| 162 | + enable_caged_heap = true |
| 163 | +else |
| 164 | + enable_caged_heap = false |
| 165 | +endif |
| 166 | +if enable_caged_heap |
| 167 | + config_args += [ |
| 168 | + '-DCPPGC_CAGED_HEAP', |
| 169 | + '-DCPPGC_YOUNG_GENERATION', |
| 170 | + ] |
| 171 | +endif |
| 172 | + |
| 173 | +enable_i18n = get_option('i18n').allowed() |
| 174 | + |
| 175 | +if get_option('maglev').auto() |
| 176 | + enable_maglev = host_arch == 'x64' and enable_pointer_compression |
| 177 | +else |
| 178 | + enable_maglev = get_option('maglev').allowed() |
| 179 | +endif |
| 180 | + |
| 181 | +enable_wasm = get_option('wasm').allowed() |
| 182 | +if enable_wasm |
| 183 | + config_args += '-DV8_ENABLE_WEBASSEMBLY' |
| 184 | +endif |
| 185 | + |
| 186 | +if get_option('system_instrumentation').auto() |
| 187 | + enable_system_instrumentation = host_os in ['win', 'macos'] |
| 188 | +else |
| 189 | + enable_system_instrumentation = get_option('system_instrumentation').allowed() |
| 190 | +endif |
| 191 | +if enable_system_instrumentation |
| 192 | + config_args += '-DV8_ENABLE_SYSTEM_INSTRUMENTATION' |
| 193 | +endif |
| 194 | + |
| 195 | +add_project_arguments( |
| 196 | + config_args + cpp.get_supported_arguments([ |
| 197 | + '-Wno-non-virtual-dtor', |
| 198 | + ]), |
| 199 | + language: 'cpp' |
| 200 | +) |
| 201 | +add_project_arguments( |
| 202 | + config_args + cpp.get_supported_arguments([ |
| 203 | + '-Wno-non-virtual-dtor', |
| 204 | + ]), |
| 205 | + language: 'cpp', |
| 206 | + native: true |
| 207 | +) |
| 208 | + |
| 209 | +run_codegen = files('tools' / 'meson-run-codegen.py') |
| 210 | + |
| 211 | +subdir('include') |
| 212 | +subdir('third_party') |
| 213 | +subdir('src') |
0 commit comments