shithub: dav1d

Download patch

ref: 1bcc5ecd8a0a06be8eb964213ceae83f5d1e6d92
parent: 791c4697219b27ab79fb4536725a0a7d58c014d3
author: Janne Grunau <janne-vlc@jannau.net>
date: Sat Aug 22 08:19:24 EDT 2020

tests: test stand alone API header compilation

Errors on C11 features like anonymous strucs/unions.

--- a/include/dav1d/meson.build
+++ b/include/dav1d/meson.build
@@ -31,11 +31,15 @@
                                   output: 'version.h',
                                   configuration: version_h_data)
 
+dav1d_api_headers = files(
+    'common.h',
+    'data.h',
+    'dav1d.h',
+    'headers.h',
+    'picture.h',
+    )
+
 # install headers
-install_headers('common.h',
-                'data.h',
-                'dav1d.h',
-                'headers.h',
-                'picture.h',
+install_headers(dav1d_api_headers,
                 version_h_target,
                 subdir : 'dav1d')
--- /dev/null
+++ b/tests/header_test.c.in
@@ -1,0 +1,33 @@
+/*
+ * Copyright © 2018, VideoLAN and dav1d authors
+ * Copyright © 2018, Two Orioles, LLC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ *    list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <dav1d/INPUT>
+
+int main()
+{
+    return 0;
+}
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -101,6 +101,36 @@
     test('checkasm', checkasm, is_parallel: false)
 endif
 
+c99_extension_flag = cc.first_supported_argument(
+    '-Werror=c11-extensions',
+    '-Werror=c99-c11-compat',
+    '-Wc11-extensions',
+    '-Wc99-c11-compat',
+)
+
+# dav1d_api_headers
+foreach header : dav1d_api_headers
+    header_file = '@0@'.format(header).split('/')[-1]
+    target = header_file + '_test'
+
+    header_test_source = custom_target(target,
+        output : target + '.c',
+        input : 'header_test.c.in',
+        capture : true,
+        command : ['sed', '-e', 's/INPUT/' + header_file + '/', '@INPUT@']
+    )
+
+    header_test_exe = executable(target,
+        header_test_source,
+        include_directories: dav1d_inc_dirs,
+        c_args: [c99_extension_flag],
+        build_by_default: true
+    )
+
+    test(target, header_test_exe)
+endforeach
+
+
 # fuzzing binaries
 if meson.version().version_compare('>=0.49')
     subdir('libfuzzer')