From fee4d0eae1657a0d892ab59199ab9b8f58be8bd9 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 8 Jun 2021 11:19:33 +1000 Subject: [PATCH] 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.. --- spa/tests/gen-cpp-test.py | 24 ------------------------ spa/tests/meson.build | 17 +++-------------- 2 files changed, 3 insertions(+), 38 deletions(-) delete mode 100755 spa/tests/gen-cpp-test.py diff --git a/spa/tests/gen-cpp-test.py b/spa/tests/gen-cpp-test.py deleted file mode 100755 index a02c1a1d1..000000000 --- a/spa/tests/gen-cpp-test.py +++ /dev/null @@ -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))) diff --git a/spa/tests/meson.build b/spa/tests/meson.build index 288d843fc..dd261b0be 100644 --- a/spa/tests/meson.build +++ b/spa/tests/meson.build @@ -30,21 +30,9 @@ foreach a : test_apps endif 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 # 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) if find.found() spa_headers = run_command(find_program('find'), @@ -55,10 +43,11 @@ if find.found() '-printf', '%P\n') foreach spa_header : spa_headers.stdout().split('\n') if spa_header.endswith('.h') # skip empty lines + ext = have_cpp ? '.cpp' : '.c' c = configuration_data() c.set('INCLUDE', spa_header) 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) executable('spa-include-test-@0@'.format(spa_header.underscorify()), src,