2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-12-22 17:01:14 +01:00

3rdparty: opus: wscript: implement looking for C99 VLA or alloca

This commit is contained in:
Alibek Omarov 2024-11-07 10:15:19 +03:00
parent 6ae62e3bb1
commit 08bc4ccec4

31
3rdparty/opus/wscript vendored
View File

@ -3,6 +3,26 @@
import os
FRAGMENT_VLA='''int main (int argc, char **argv) {
char a[argc];
a[sizeof( a ) - 1] = 0;
int N;
return a[0];
}'''
FRAGMENT_ALLOCA_H='''#include <alloca.h>
int main (void) {
int foo=10;
int * array = alloca(foo);
}'''
FRAGMENT_STDLIB_H='''#include <malloc.h>
#include <stdlib.h>
int main (void) {
int foo=10;
int * array = alloca(foo);
}'''
def options(opt):
pass
@ -11,6 +31,15 @@ def configure(conf):
conf.fatal('Can\'t find opus submodule. Run `git submodule update --init --recursive`.')
return
# Check for C99 variable-size arrays, or alloca() as fallback
if conf.check_cc(fragment=FRAGMENT_VLA, msg = 'Checking for C99 VLA support', mandatory = False):
conf.define('VAR_ARRAYS', 1)
elif conf.check_cc(fragment=FRAGMENT_ALLOCA_H, msg = 'Checking for alloca in alloca.h header', mandatory = False):
conf.define('USE_ALLOCA', 1)
conf.define('HAVE_ALLOCA_H', 1)
elif conf.check_cc(fragmenmt=FRAGMENT_STDLIB_H, msg = 'Checking for alloca.h in stdlib.h', mandatory = False):
conf.define('USE_ALLOCA', 1)
# TODO: ARM/x86 intrinsics detection
# TODO: maybe call autotools/cmake/meson instead?
@ -27,7 +56,7 @@ def build(bld):
'opus/celt/opus_custom_demo.c'
])
includes = ['opus/include/', 'opus/celt/', 'opus/silk/', 'opus/silk/float/']
defines = ['USE_ALLOCA', 'OPUS_BUILD', 'FLOAT_APPROX', 'PACKAGE_VERSION="1.4.0"', 'CUSTOM_MODES']
defines = ['OPUS_BUILD', 'FLOAT_APPROX', 'PACKAGE_VERSION="1.4.0"', 'CUSTOM_MODES']
bld.stlib(
source = sources,