From e2ee2b56f90788e6969a8aa8f3402edfcbde2cb0 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 17 Feb 2022 14:37:03 +0200 Subject: [PATCH] tests: make vertex-clip use WESTON_EXPORT_FOR_TESTS This is probably the simplest case to demonstrate how to use WESTON_EXPORT_FOR_TESTS. Previously, vertex-clip test re-built vertex-clipping.c for itself. Now it directly links in gl-renderer.so instead as that is where vexter-clipping.c gets built into for actual use. This probably will not work for any installed program, but luckily tests are never installed, so Meson makes sure the DSO is found. Unfortunately we cannot remove the definition of dep_vertex_clipping yet, because clients/cliptest.c needs it. This makes vertex-clip test depend on GL-renderer, but that is where the code is really used. Signed-off-by: Pekka Paalanen --- libweston/vertex-clipping.c | 7 ++++--- tests/meson.build | 13 +++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libweston/vertex-clipping.c b/libweston/vertex-clipping.c index a71e7336..3a05c7bd 100644 --- a/libweston/vertex-clipping.c +++ b/libweston/vertex-clipping.c @@ -26,9 +26,10 @@ #include #include +#include "shared/helpers.h" #include "vertex-clipping.h" -float +WESTON_EXPORT_FOR_TESTS float float_difference(float a, float b) { /* http://www.altdevblogaday.com/2012/02/22/comparing-floating-point-numbers-2012-edition/ */ @@ -282,7 +283,7 @@ clip_polygon_bottom(struct clip_context *ctx, const struct polygon8 *src, #define min(a, b) (((a) > (b)) ? (b) : (a)) #define clip(x, a, b) min(max(x, a), b) -int +WESTON_EXPORT_FOR_TESTS int clip_simple(struct clip_context *ctx, struct polygon8 *surf, float *ex, @@ -296,7 +297,7 @@ clip_simple(struct clip_context *ctx, return surf->n; } -int +WESTON_EXPORT_FOR_TESTS int clip_transformed(struct clip_context *ctx, struct polygon8 *surf, float *ex, diff --git a/tests/meson.build b/tests/meson.build index 222091cd..5b1f0418 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -204,10 +204,6 @@ tests = [ input_timestamps_unstable_v1_protocol_c, ], }, - { - 'name': 'vertex-clip', - 'dep_objs': dep_vertex_clipping, - }, { 'name': 'viewporter', }, { 'name': 'viewporter-shot', }, { @@ -227,6 +223,14 @@ tests = [ }, ] +if get_option('renderer-gl') + tests += { + 'name': 'vertex-clip', + 'link_with': plugin_gl, + } + +endif + if get_option('color-management-lcms') dep_lcms2 = dependency('lcms2', version: '>= 2.9', required: false) if not dep_lcms2.found() @@ -338,6 +342,7 @@ foreach t : tests build_by_default: true, include_directories: common_inc, dependencies: t_deps, + link_with: t.get('link_with', []), install: false, )