mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
spa: switch the include header test to C++ by default
If we have a C++ compiler, compile all the #include tests with that - it'll pick up any issues that a C compiler will pick up anyway. This saves us from having a separate C++ compiler test and it'll test each header separately for C++ compatibility..
This commit is contained in:
parent
750cafd7d1
commit
fee4d0eae1
2 changed files with 3 additions and 38 deletions
|
|
@ -1,24 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
#
|
|
||||||
# Generates a simple .cpp file including all of the SPA headers.
|
|
||||||
#
|
|
||||||
# Usage: gen-cpp-test.py path/to/pipewire.git/spa/include/spa
|
|
||||||
|
|
||||||
template = """
|
|
||||||
@@INCLUDES@@
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
basedir = Path(sys.argv[1])
|
|
||||||
includes = [
|
|
||||||
"#include <{}>".format(f.relative_to(basedir.parent)) for f in sorted(basedir.rglob("*.h"))
|
|
||||||
]
|
|
||||||
|
|
||||||
print(template.replace("@@INCLUDES@@", "\n".join(includes)))
|
|
||||||
|
|
@ -30,21 +30,9 @@ foreach a : test_apps
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
if have_cpp
|
|
||||||
gen_cpp_test = find_program('gen-cpp-test.py')
|
|
||||||
src_test_cpp = custom_target('gen-cpp-test',
|
|
||||||
command: [gen_cpp_test, meson.source_root() / 'spa' / 'include' / 'spa'],
|
|
||||||
output: 'test-cpp.cpp',
|
|
||||||
capture: true)
|
|
||||||
# compilation test only
|
|
||||||
executable('spa-test-cpp', src_test_cpp,
|
|
||||||
include_directories : [spa_inc ],
|
|
||||||
dependencies : [],
|
|
||||||
install : false)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Generate a compilation test for each SPA header, excluding the type-info.h
|
# Generate a compilation test for each SPA header, excluding the type-info.h
|
||||||
# ones which have circular dependencies and take some effort to fix.
|
# ones which have circular dependencies and take some effort to fix.
|
||||||
|
# Do it for C++ if possible (picks up C++-specific errors), otherwise for C.
|
||||||
find = find_program('find', required: false)
|
find = find_program('find', required: false)
|
||||||
if find.found()
|
if find.found()
|
||||||
spa_headers = run_command(find_program('find'),
|
spa_headers = run_command(find_program('find'),
|
||||||
|
|
@ -55,10 +43,11 @@ if find.found()
|
||||||
'-printf', '%P\n')
|
'-printf', '%P\n')
|
||||||
foreach spa_header : spa_headers.stdout().split('\n')
|
foreach spa_header : spa_headers.stdout().split('\n')
|
||||||
if spa_header.endswith('.h') # skip empty lines
|
if spa_header.endswith('.h') # skip empty lines
|
||||||
|
ext = have_cpp ? '.cpp' : '.c'
|
||||||
c = configuration_data()
|
c = configuration_data()
|
||||||
c.set('INCLUDE', spa_header)
|
c.set('INCLUDE', spa_header)
|
||||||
src = configure_file(input: 'spa-include-test-template.c',
|
src = configure_file(input: 'spa-include-test-template.c',
|
||||||
output: 'spa-include-test-@0@.c'.format(spa_header.underscorify()),
|
output: 'spa-include-test-@0@.@1@'.format(spa_header.underscorify(), ext),
|
||||||
configuration: c)
|
configuration: c)
|
||||||
executable('spa-include-test-@0@'.format(spa_header.underscorify()),
|
executable('spa-include-test-@0@'.format(spa_header.underscorify()),
|
||||||
src,
|
src,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue