-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
172 lines (146 loc) · 6.63 KB
/
Copy pathmeson.build
File metadata and controls
172 lines (146 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
project('FelBaker', 'cpp',
version: '1.0.0',
default_options: [
'cpp_std=c++20',
'buildtype=release',
'optimization=3',
'b_lto=true',
'b_ndebug=if-release',
'warning_level=3',
],
license: 'GPL-3.0-or-later',
meson_version: '>=1.10.0',
)
vs_version = 'R73' # cicd-vs-version
libdovi_version = '3.3.2'
summary({
'VapourSynth ': vs_version,
'libdovi ': libdovi_version + ' (static)',
}, section: 'Built against')
#──────────────────────────────────────────────────────────────────────────────
# Compiler & CPU optimization
#──────────────────────────────────────────────────────────────────────────────
cpu_flags = {
'x86_64_gcc_max' : ['-march=x86-64-v4', 'x86-64-v4'],
'x86_64_gcc_generic' : ['-march=x86-64-v3', 'x86-64-v3'],
'x86_64_gcc_native' : ['-march=native', 'native'],
'x86_64_msvc_max' : ['/arch:AVX512', 'x86-64-v4'],
'x86_64_msvc_generic' : ['/arch:AVX2', 'x86-64-v3'],
'aarch64_darwin_max' : ['-mcpu=apple-m4', 'apple-m4'],
'aarch64_darwin_generic' : ['-mcpu=apple-m1', 'apple-m1'],
'aarch64_darwin_native' : ['-mcpu=native', 'native'],
'aarch64_gcc_max' : ['-march=armv9.2-a', 'cortex-x925', '-mtune=cortex-x925'],
'aarch64_gcc_generic' : ['-march=armv8.2-a', 'oryon-1', '-mtune=oryon-1'],
'aarch64_gcc_native' : ['-mcpu=native', 'native'],
'aarch64_msvc_max' : ['/arch:armv9.2', 'oryon-1'],
'aarch64_msvc_generic' : ['/arch:armv8.2', 'native'],
}
cpp = meson.get_compiler('cpp')
host_system = host_machine.system()
host_cpu = host_machine.cpu_family()
syntax = host_system == 'darwin' and host_cpu == 'aarch64' ? 'darwin' : cpp.get_argument_syntax()
cpu_tier = get_option('cpu_tier')
cpu_args = [
'-ffast-math', '-fno-plt', '-fno-semantic-interposition', '-fno-rtti',
'/fp:fast', '/Oi', '/Ot',
]
link_args = []
rust_target_cpu = ''
cpu_key = host_cpu + '_' + syntax + '_' + cpu_tier
if cpu_tier == 'native' and syntax == 'msvc'
error('❌ MSVC does not support "native" architecture detection. Please use -Dcpu_tier=generic or -Dcpu_tier=max')
elif cpu_key in cpu_flags
cpu_args += cpu_flags[cpu_key][0]
rust_target_cpu = cpu_flags[cpu_key][1]
if cpu_flags[cpu_key].length() > 2
cpu_args += cpu_flags[cpu_key][2]
endif
else
warning('⚠️ Unsupported or unknown CPU architecture: ' + host_cpu + '. No specific optimization flags applied.')
endif
if host_machine.system() == 'windows' and cpp.get_id().contains('clang')
link_args += '-fuse-ld=lld'
if get_option('win_deterministic')
link_args += '-Wl,/Brepro'
endif
endif
if get_option('win_deterministic') and syntax == 'msvc'
cpu_args += '/experimental:deterministic'
cpu_args += '/deterministic'
link_args += '/Brepro'
endif
add_project_arguments(cpp.get_supported_arguments(cpu_args), language: 'cpp')
add_project_link_arguments(cpp.get_supported_link_arguments(link_args), language: 'cpp')
#──────────────────────────────────────────────────────────────────────────────
# libdovi (Rust dependency via cargo-c)
#──────────────────────────────────────────────────────────────────────────────
cargo = find_program('cargo', required: true)
cargo_c_check = run_command(cargo, 'cinstall', '--version', check: false)
if cargo_c_check.returncode() != 0
error('❌ cargo-c is required. Install with: cargo install cargo-c')
endif
libdovi_src = meson.current_source_dir() / 'external' / 'dovi_tool' / 'dolby_vision'
libdovi_cargo = libdovi_src / 'Cargo.toml'
libdovi_dir = 'libdovi'
libdovi_build = meson.current_build_dir() / libdovi_dir
libdovi_lib = host_system == 'windows' ? 'dovi.lib' : 'libdovi.a'
rust_flags = ['-C embed-bitcode=yes', '-C lto=fat', '-C codegen-units=1']
if rust_target_cpu != ''
rust_flags += '-C target-cpu=' + rust_target_cpu
endif
libdovi_target = custom_target('libdovi',
output: 'libdovi_marker',
command: [
cargo, 'cinstall', '--release',
'--destdir', meson.current_build_dir(),
'--prefix', '.',
'--libdir', libdovi_dir,
'--includedir', '.',
'--manifest-path', libdovi_cargo,
'--library-type', 'staticlib',
],
env: environment({'RUSTFLAGS': ' '.join(rust_flags)}),
build_always_stale: true,
console: true,
)
libdovi_dep = declare_dependency(
sources: libdovi_target,
compile_args: [(cpp.get_id() == 'msvc' ? '/I' : '-I') + libdovi_build],
link_args: [libdovi_build / libdovi_lib],
)
libdovi_deps = [libdovi_dep]
if host_system == 'windows'
libdovi_deps += cpp.find_library('ntdll')
endif
run_target('cargo-clean',
command: ['cargo', 'clean', '--manifest-path', libdovi_cargo]
)
#──────────────────────────────────────────────────────────────────────────────
# FelBaker plugin
#──────────────────────────────────────────────────────────────────────────────
includes = include_directories('src')
includes_external = include_directories('external' / 'vapoursynth')
felbaker_sources = files(
'src/FelBaker.cpp',
'src/RpuProcessor.cpp',
'src/Spline16Resampler.cpp',
'src/VapourSynthEntry.cpp',
)
install = get_option('install_plugin')
install_dir = get_option('install_dir')
if install and install_dir == ''
vs_dep = dependency('vapoursynth', required: false)
install_dir = vs_dep.found() ? vs_dep.get_variable(pkgconfig: 'libdir') / 'vapoursynth' : get_option('libdir')
endif
felbaker_plugin = shared_library('felbaker',
felbaker_sources,
include_directories: [includes, includes_external],
dependencies: libdovi_deps,
implicit_include_directories: false,
gnu_symbol_visibility: 'hidden',
install: install,
install_dir: install_dir,
)
if get_option('tests')
subdir('test')
endif