3rdparty: opus: wscript: implement looking for C99 VLA or alloca
This commit is contained in:
parent
6ae62e3bb1
commit
08bc4ccec4
1 changed files with 30 additions and 1 deletions
31
3rdparty/opus/wscript
vendored
31
3rdparty/opus/wscript
vendored
|
@ -3,6 +3,26 @@
|
||||||
|
|
||||||
import os
|
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):
|
def options(opt):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -11,6 +31,15 @@ def configure(conf):
|
||||||
conf.fatal('Can\'t find opus submodule. Run `git submodule update --init --recursive`.')
|
conf.fatal('Can\'t find opus submodule. Run `git submodule update --init --recursive`.')
|
||||||
return
|
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: ARM/x86 intrinsics detection
|
||||||
# TODO: maybe call autotools/cmake/meson instead?
|
# TODO: maybe call autotools/cmake/meson instead?
|
||||||
|
|
||||||
|
@ -27,7 +56,7 @@ def build(bld):
|
||||||
'opus/celt/opus_custom_demo.c'
|
'opus/celt/opus_custom_demo.c'
|
||||||
])
|
])
|
||||||
includes = ['opus/include/', 'opus/celt/', 'opus/silk/', 'opus/silk/float/']
|
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(
|
bld.stlib(
|
||||||
source = sources,
|
source = sources,
|
||||||
|
|
Loading…
Add table
Reference in a new issue