Skip to content

Commit 397ec27

Browse files
oleavrhsorbo
andcommitted
[build] Add Meson build system
Co-authored-by: Håvard Sørbø <[email protected]>
1 parent e4add5a commit 397ec27

File tree

20 files changed

+2119
-0
lines changed

20 files changed

+2119
-0
lines changed

include/cppgc/internal/meson.build

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cppgc_internal_headers = [
2+
'write-barrier.h',
3+
'gc-info.h',
4+
'persistent-node.h',
5+
'name-trait.h',
6+
'pointer-policies.h',
7+
'logging.h',
8+
'api-constants.h',
9+
'atomic-entry-flag.h',
10+
'member-storage.h',
11+
'compiler-specific.h',
12+
'finalizer-trait.h',
13+
'caged-heap-local-data.h',
14+
'base-page-handle.h',
15+
'caged-heap.h',
16+
]
17+
18+
install_headers(cppgc_internal_headers, subdir: install_header_subdir / 'cppgc' / 'internal')

include/cppgc/meson.build

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cppgc_headers = [
2+
'testing.h',
3+
'cross-thread-persistent.h',
4+
'name-provider.h',
5+
'persistent.h',
6+
'prefinalizer.h',
7+
'allocation.h',
8+
'process-heap-statistics.h',
9+
'ephemeron-pair.h',
10+
'custom-space.h',
11+
'type-traits.h',
12+
'heap-state.h',
13+
'default-platform.h',
14+
'heap-statistics.h',
15+
'heap-handle.h',
16+
'visitor.h',
17+
'garbage-collected.h',
18+
'trace-trait.h',
19+
'object-size-trait.h',
20+
'common.h',
21+
'heap-consistency.h',
22+
'macros.h',
23+
'heap.h',
24+
'sentinel-pointer.h',
25+
'liveness-broker.h',
26+
'member.h',
27+
'platform.h',
28+
'source-location.h',
29+
'explicit-management.h',
30+
]
31+
32+
install_headers(cppgc_headers, subdir: install_header_subdir / 'cppgc')
33+
34+
subdir('internal')

include/libplatform/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
libplatform_headers = [
2+
'libplatform-export.h',
3+
'libplatform.h',
4+
'v8-tracing.h',
5+
]
6+
7+
install_headers(libplatform_headers, subdir: install_header_subdir / 'libplatform')

include/meson.build

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
install_header_subdir = 'v8-' + api_version
2+
3+
v8_inspector_js_protocol = files('js_protocol.pdl')
4+
5+
v8_headers = [
6+
'v8-array-buffer.h',
7+
'v8-callbacks.h',
8+
'v8-container.h',
9+
'v8-context.h',
10+
'v8-cppgc.h',
11+
'v8-data.h',
12+
'v8-date.h',
13+
'v8-debug.h',
14+
'v8-embedder-heap.h',
15+
'v8-embedder-state-scope.h',
16+
'v8-exception.h',
17+
'v8-extension.h',
18+
'v8-external.h',
19+
'v8-fast-api-calls.h',
20+
'v8-forward.h',
21+
'v8-function-callback.h',
22+
'v8-function.h',
23+
'v8-initialization.h',
24+
'v8-inspector-protocol.h',
25+
'v8-inspector.h',
26+
'v8-internal.h',
27+
'v8-isolate.h',
28+
'v8-json.h',
29+
'v8-local-handle.h',
30+
'v8-locker.h',
31+
'v8-maybe.h',
32+
'v8-memory-span.h',
33+
'v8-message.h',
34+
'v8-metrics.h',
35+
'v8-microtask-queue.h',
36+
'v8-microtask.h',
37+
'v8-object.h',
38+
'v8-persistent-handle.h',
39+
'v8-platform.h',
40+
'v8-primitive-object.h',
41+
'v8-primitive.h',
42+
'v8-profiler.h',
43+
'v8-promise.h',
44+
'v8-proxy.h',
45+
'v8-regexp.h',
46+
'v8-script.h',
47+
'v8-snapshot.h',
48+
'v8-statistics.h',
49+
'v8-template.h',
50+
'v8-traced-handle.h',
51+
'v8-typed-array.h',
52+
'v8-unwinder-state.h',
53+
'v8-unwinder.h',
54+
'v8-util.h',
55+
'v8-value-serializer-version.h',
56+
'v8-value-serializer.h',
57+
'v8-value.h',
58+
'v8-version-string.h',
59+
'v8-version.h',
60+
'v8-wasm-trap-handler-posix.h',
61+
'v8-wasm-trap-handler-win.h',
62+
'v8-wasm.h',
63+
'v8-weak-callback-info.h',
64+
'v8.h',
65+
'v8config.h',
66+
]
67+
68+
install_headers(v8_headers, subdir: install_header_subdir)
69+
70+
subdir('cppgc')
71+
subdir('libplatform')

meson.build

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
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

Comments
 (0)