-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
meson.build
214 lines (194 loc) · 7.03 KB
/
meson.build
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
project('openh264', ['c', 'cpp'],
version : '2.4.1',
meson_version : '>= 0.52',
default_options : [ 'warning_level=1',
'buildtype=debugoptimized' ])
major_version = '7'
cpp = meson.get_compiler('cpp')
inc = include_directories([
join_paths('codec', 'api', 'wels'),
join_paths('codec', 'common', 'inc'),
])
processing_inc = include_directories([
join_paths('codec', 'processing', 'interface'),
join_paths('codec', 'processing', 'src', 'common'),
join_paths('codec', 'processing', 'src', 'adaptivequantization'),
join_paths('codec', 'processing', 'src', 'downsample'),
join_paths('codec', 'processing', 'src', 'scrolldetection'),
join_paths('codec', 'processing', 'src', 'vaacalc'),
])
console_common_inc = include_directories([
join_paths('codec', 'console', 'common', 'inc')
])
decoder_inc = include_directories([
join_paths('codec', 'decoder', 'core', 'inc'),
join_paths('codec', 'decoder', 'plus', 'inc'),
])
encoder_inc = include_directories([
join_paths('codec', 'encoder', 'core', 'inc'),
join_paths('codec', 'encoder', 'plus', 'inc'),
])
system = host_machine.system()
cpu_family = host_machine.cpu_family()
supported_arguments = cpp.get_supported_arguments([
'-Wno-non-virtual-dtor',
'-Wno-class-memaccess',
'-Werror',
'-Wunused-but-set-variable',
'-Wno-strict-aliasing'])
add_project_arguments(supported_arguments, language: 'cpp')
deps = [dependency('threads')]
c_args = []
cpp_args = []
asm_args = []
asm_inc = []
casm_inc = []
cpp_lib = '-lstdc++'
libm_dep = cpp.find_library('m', required : false)
deps += [libm_dep]
if ['linux', 'android', 'ios', 'darwin'].contains(system)
asm_format32 = 'elf'
asm_format64 = 'elf64'
if ['ios', 'darwin'].contains(system)
asm_format32 = 'macho32'
asm_format64 = 'macho64'
endif
if cpu_family == 'x86'
asm_format = asm_format32
asm_args += ['-DX86_32', '-DHAVE_AVX2']
add_project_arguments('-DHAVE_AVX2', language: 'cpp')
add_project_arguments('-DHAVE_AVX2', '-DX86_ASM', '-DX86_32_ASM', language: 'c')
asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'x86', '')
elif cpu_family == 'x86_64'
asm_format = asm_format64
asm_args += ['-DUNIX64', '-DHAVE_AVX2']
add_project_arguments('-DHAVE_AVX2', language: 'cpp')
add_project_arguments('-DHAVE_AVX2', '-DX86_ASM', language: 'c')
asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'x86', '')
elif cpu_family == 'arm'
asm_format = asm_format32
add_project_arguments('-DHAVE_NEON', language: 'c')
add_project_arguments('-DHAVE_NEON', language: 'c')
casm_inc = include_directories(join_paths('codec', 'common', 'arm'))
elif cpu_family == 'aarch64'
asm_format = asm_format64
add_project_arguments('-DHAVE_NEON_AARCH64', language: 'c')
add_project_arguments('-DHAVE_NEON_AARCH64', language: 'cpp')
casm_inc = include_directories(join_paths('codec', 'common', 'arm64'))
elif cpu_family == 'loongarch32'
asm_format = asm_format32
add_project_arguments('-mlsx', '-DHAVE_LSX', '-mlasx', '-DHAVE_LASX', language: 'c')
add_project_arguments('-DHAVE_LSX', '-DHAVE_LASX', language: 'cpp')
casm_inc = include_directories(join_paths('codec', 'common', 'loongarch'))
elif cpu_family == 'loongarch64'
asm_format = asm_format64
add_project_arguments('-mlsx', '-DHAVE_LSX', '-mlasx', '-DHAVE_LASX', language: 'c')
add_project_arguments('-DHAVE_LSX', '-DHAVE_LASX', language: 'cpp')
casm_inc = include_directories(join_paths('codec', 'common', 'loongarch'))
elif cpu_family == 'riscv64'
# We dont't have riscv64-specific optimization for now.
asm_format = asm_format64
else
error('FIXME: unhandled CPU family @0@ for @1@'.format(cpu_family, system))
endif
if ['ios', 'darwin', 'android'].contains(system)
cpp_lib = '-lc++'
endif
elif system == 'windows'
if cpu_family == 'x86'
asm_format = 'win32'
asm_args += ['-DPREFIX', '-DX86_32']
asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'x86', '')
elif cpu_family == 'x86_64'
asm_format = 'win64'
asm_args += ['-DWIN64']
asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'x86', '')
elif cpu_family == 'arm'
if cpp.get_argument_syntax() == 'msvc'
asm_format = 'armasm'
asm_args += ['-nologo', '-DHAVE_NEON', '-ignore', '4509']
asm_cmds = ['armasm']
else
asm_format = 'clang'
asm_args += ['-DHAVE_NEON', '-mimplicit-it=always']
asm_cmds = cpp.cmd_array()
endif
asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'arm', '')
elif cpu_family == 'aarch64'
asm_format = 'armasm'
asm_args += ['-nologo', '-DHAVE_NEON_AARCH64']
asm_inc = join_paths(meson.current_source_dir(), 'codec', 'common', 'arm64', '')
else
error('FIXME: unhandled CPU family @0@ for Windows'.format(cpu_family))
endif
else
error('FIXME: Unhandled system @0@'.format(system))
endif
use_asm_gen = false
if cpu_family in ['x86', 'x86_64']
nasm = find_program('nasm')
use_asm_gen = true
asm_gen = generator(nasm,
output : '@[email protected]',
arguments : [
'-f', asm_format,
'-i', asm_inc,
'@INPUT@',
'-o', '@OUTPUT@'] + asm_args)
elif system == 'windows'
if cpu_family == 'arm'
# For ARM, gas-preprocessor is needed for converting the asm to be
# buildable as thumb even with Clang.
use_asm_gen = true
gasprep = find_program('gas-preprocessor.pl')
asm_gen = generator(gasprep,
output : '@[email protected]',
arguments : [
'-as-type', asm_format,
'-force-thumb',
'--'
] + asm_cmds + [
'-I' + asm_inc] + asm_args + [
'@INPUT@',
'-c', '-o', '@OUTPUT@'])
elif cpu_family == 'aarch64'
# For ARM64, Clang can build the assembly as-is without needing to use
# either gas-preprocessor or armasm64.
if cpp.get_argument_syntax() == 'msvc' and (cpp.get_id() != 'clang-cl' or meson.version().version_compare('<0.58.0'))
use_asm_gen = true
gasprep = find_program('gas-preprocessor.pl')
asm_gen = generator(gasprep,
output : '@[email protected]',
arguments : [
'-as-type', asm_format,
'-arch', 'aarch64',
'--',
'armasm64',
'-I' + asm_inc] + asm_args + [
'@INPUT@',
'-c', '-o', '@OUTPUT@'])
endif
else
# Windows only supports x86, x86_64, arm, arm64
error('unreachable code')
endif
endif
subdir ('codec')
subdir ('test')
libopenh264 = library('openh264',
link_whole: [libcommon, libprocessing, libencoder, libdecoder],
install: true,
soversion: major_version,
version: meson.project_version(),
vs_module_defs: 'openh264.def',
dependencies: deps)
openh264_dep = declare_dependency(
link_with: libopenh264,
include_directories: include_directories('codec/api'),
dependencies: deps)
pkg = import('pkgconfig')
pkg.generate(libopenh264,
description: 'OpenH264 is a codec library which supports H.264 encoding ' +
'and decoding. It is suitable for use in real time ' +
'applications such as WebRTC.',
)