Work around linker missing objects when building tests

Since we rely on a global object ctor to add a display output to the
list, it is not referenced from anywhere else, so does not get linked in
when building tests since most objects are pulled from a static library.

Another option would be to use --whole-archive to link to it.
This commit is contained in:
François Revol 2021-10-26 02:09:35 +02:00
parent 5b22723a3b
commit 7cf80d5948
6 changed files with 18 additions and 0 deletions

View File

@ -43,6 +43,7 @@ namespace {
conky::display_output_console console_output("console");
} // namespace
void init_console_output() {}
namespace priv {} // namespace priv

View File

@ -49,6 +49,7 @@ namespace {
conky::display_output_file file_output("file");
} // namespace
extern void init_file_output() {}
namespace priv {} // namespace priv

View File

@ -47,6 +47,7 @@ conky::disabled_display_output http_output_disabled("http", "BUILD_HTTP");
#endif
} // namespace
extern void init_http_output() {}
// TODO: cleanup namespace
// namespace priv {

View File

@ -52,6 +52,7 @@ conky::disabled_display_output ncurses_output_disabled("ncurses",
#endif
} // namespace
extern void init_ncurses_output() {}
// namespace priv {

View File

@ -50,6 +50,13 @@ display_outputs_t *display_outputs;
} // namespace
// HACK: force the linker to link all the objects in with test enabled
extern void init_console_output();
extern void init_ncurses_output();
extern void init_file_output();
extern void init_http_output();
extern void init_x11_output();
/*
* The selected and active display output.
*/
@ -99,6 +106,12 @@ disabled_display_output::disabled_display_output(const std::string &name,
}
bool initialize_display_outputs() {
init_console_output();
init_ncurses_output();
init_file_output();
init_http_output();
init_x11_output();
std::vector<display_output_base *> outputs;
outputs.reserve(display_outputs->size());

View File

@ -193,6 +193,7 @@ conky::disabled_display_output x11_output_disabled("x11", "BUILD_X11");
#endif
} // namespace
extern void init_x11_output() {}
namespace priv {} // namespace priv