This is a new function exporting macro that intends to make writing unit
tests in the Weston test suite easier.
A test needs to access a private function to be able to verify its
behavior. Previously we have used things like putting such functions in
a separate .c file and then building that file into the corresponding
test. That is a bit awkward and can lead to proliferation of arbitrary
.c files for no good reason. It may also require pre-processor magic,
and sometimes copying chunks of code causing a risk of deviating the
code being tested from the code actually used.
This patch proposes another approach: a private export from a DSO.
Except, private exports do not really exist, and this is just a normal
export with a specific C macro, and omitting the function from public
headers.
Once exported, a test program can link the DSO during build, be that a
shared library or even a plugin, use the private header declaring the
function, and simply call the function in the test.
The declaration of WESTON_EXPORT_FOR_TESTS is in shared/helpers.h so
that it is available to all components equally while still not being in
a public header. Other places that were considered:
- include/libweston/libweston.h is a public header, but external users
should not know about the macro.
- libweston/libweston-private.h is too private and not available to all
components, particularly color-lcms plugin.
- libweston/backend.h is not appropriate for color-lcms plugin either.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>