allow plugins to be compiled into the f00bar main binary

This commit is contained in:
Daniel Eklöf 2019-01-14 20:57:03 +01:00
parent 00679dbeeb
commit 0d591fe5a1
25 changed files with 400 additions and 72 deletions

View file

@ -5,72 +5,80 @@ target_compile_options(module-sdk INTERFACE ${CAIRO_CFLAGS_OTHER})
target_include_directories(module-sdk INTERFACE ${CAIRO_INCLUDE_DIRS})
target_link_libraries(module-sdk INTERFACE ${CMAKE_THREAD_LIBS_INIT})
set(CMAKE_SHARED_MODULE_PREFIX module_)
if (CORE_PLUGINS_AS_SHARED_LIBRARIES)
set(lib_type MODULE)
else ()
set(lib_type STATIC)
endif ()
set(CMAKE_SHARED_${lib_type}_PREFIX module_)
pkg_check_modules(ALSA REQUIRED alsa)
add_library(alsa MODULE alsa.c)
add_library(alsa ${lib_type} alsa.c)
target_compile_options(alsa PRIVATE ${ALSA_CFLAGS_OTHER})
target_include_directories(alsa PRIVATE ${ALSA_INCLUDE_DIRS})
target_link_libraries(alsa module-sdk ${ALSA_LIBRARIES})
pkg_check_modules(UDEV REQUIRED libudev)
add_library(backlight MODULE backlight.c)
add_library(backlight ${lib_type} backlight.c)
target_compile_options(backlight PRIVATE ${UDEV_CFLAGS_OTHER})
target_include_directories(backlight PRIVATE ${UDEV_INCLUDE_DIRS})
target_link_libraries(backlight module-sdk ${UDEV_LIBRARIES})
add_library(battery MODULE battery.c)
add_library(battery ${lib_type} battery.c)
target_compile_options(battery PRIVATE ${UDEV_CFLAGS_OTHER})
target_include_directories(battery PRIVATE ${UDEV_INCLUDE_DIRS})
target_link_libraries(battery module-sdk ${UDEV_LIBRARIES})
add_library(clock MODULE clock.c)
add_library(clock ${lib_type} clock.c)
target_link_libraries(clock module-sdk)
pkg_check_modules(JSON REQUIRED json-c)
add_library(i3 MODULE i3.c)
add_library(i3 ${lib_type} i3.c)
target_compile_options(i3 PRIVATE ${JSON_CFLAGS_OTHER})
target_include_directories(i3 PRIVATE ${JSON_INCLUDE_DIRS})
target_link_libraries(i3 module-sdk dynlist ${JSON_LIBRARIES})
add_library(label MODULE label.c)
add_library(label ${lib_type} label.c)
target_link_libraries(label module-sdk)
pkg_check_modules(MPD REQUIRED libmpdclient)
add_library(mpd MODULE mpd.c)
add_library(mpd ${lib_type} mpd.c)
target_compile_options(mpd PRIVATE ${MPD_CFLAGS_OTHER})
target_include_directories(mpd PRIVATE ${MPD_INCLUDE_DIRS})
target_link_libraries(mpd module-sdk ${MPD_LIBRARIES})
add_library(network MODULE network.c)
add_library(network ${lib_type} network.c)
target_link_libraries(network module-sdk)
add_library(removables MODULE removables.c)
add_library(removables ${lib_type} removables.c)
target_compile_options(removables PRIVATE ${UDEV_CFLAGS_OTHER})
target_include_directories(removables PRIVATE ${UDEV_INCLUDE_DIRS})
target_link_libraries(removables module-sdk dynlist ${UDEV_LIBRARIES})
pkg_check_modules(XCB_XKB REQUIRED xcb-xkb)
add_library(xkb MODULE xkb.c)
add_library(xkb ${lib_type} xkb.c)
target_compile_options(xkb PRIVATE ${XCB_XKB_CFLAGS_OTHER})
target_include_directories(xkb PRIVATE ${XCB_XKB_INCLUDE_DIRS})
target_link_libraries(xkb module-sdk ${XCB_XKB_LIBRARIES})
add_library(xwindow MODULE xwindow.c)
add_library(xwindow ${lib_type} xwindow.c)
target_link_libraries(xwindow module-sdk)
install(
TARGETS
alsa
backlight
battery
clock
i3
label
mpd
network
removables
xkb
xwindow
if (CORE_PLUGINS_AS_SHARED_LIBRARIES)
install(
TARGETS
alsa
backlight
battery
clock
i3
label
mpd
network
removables
xkb
xwindow
DESTINATION lib/f00bar)
DESTINATION lib/f00bar)
endif ()

View file

@ -268,7 +268,7 @@ alsa_new(const char *card, const char *mixer, struct particle *label)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
alsa_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *card = yml_get_value(node, "card");
const struct yml_node *mixer = yml_get_value(node, "mixer");
@ -281,7 +281,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
alsa_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"card", true, &conf_verify_string},
@ -293,3 +293,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("alsa_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("alsa_from_conf")));
#endif

View file

@ -220,7 +220,7 @@ backlight_new(const char *device, struct particle *label)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
backlight_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *name = yml_get_value(node, "name");
const struct yml_node *c = yml_get_value(node, "content");
@ -230,7 +230,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
backlight_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"name", true, &conf_verify_string},
@ -241,3 +241,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("backlight_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("backlight_from_conf")));
#endif

View file

@ -350,7 +350,7 @@ battery_new(const char *battery, struct particle *label, int poll_interval_secs)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
battery_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *name = yml_get_value(node, "name");
@ -363,7 +363,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
battery_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"name", true, &conf_verify_string},
@ -375,3 +375,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("battery_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("battery_from_conf")));
#endif

View file

@ -95,7 +95,7 @@ clock_new(struct particle *label, const char *date_format, const char *time_form
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
clock_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *date_format = yml_get_value(node, "date-format");
@ -108,7 +108,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
clock_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"date-format", false, &conf_verify_string},
@ -120,3 +120,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("clock_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("clock_from_conf")));
#endif

View file

@ -641,7 +641,7 @@ i3_new(struct i3_workspaces workspaces[], size_t workspace_count,
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
i3_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
@ -698,7 +698,7 @@ verify_content(keychain_t *chain, const struct yml_node *node)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
i3_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"spacing", false, &conf_verify_int},
@ -711,3 +711,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("i3_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("i3_from_conf")));
#endif

View file

@ -48,14 +48,14 @@ label_new(struct particle *label)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
label_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return label_new(conf_to_particle(c, inherited));
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
label_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"content", true, &conf_verify_particle},
@ -65,3 +65,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("label_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("label_from_conf")));
#endif

View file

@ -477,7 +477,7 @@ mpd_new(const char *host, uint16_t port, struct particle *label)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
mpd_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *host = yml_get_value(node, "host");
const struct yml_node *port = yml_get_value(node, "port");
@ -490,7 +490,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
mpd_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"host", true, &conf_verify_string},
@ -502,3 +502,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("mpd_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("mpd_from_conf")));
#endif

View file

@ -532,7 +532,7 @@ network_new(const char *iface, struct particle *label)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
network_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *name = yml_get_value(node, "name");
const struct yml_node *content = yml_get_value(node, "content");
@ -542,7 +542,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
network_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"name", true, &conf_verify_string},
@ -553,3 +553,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("network_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("network_from_conf")));
#endif

View file

@ -559,7 +559,7 @@ removables_new(struct particle *label, int left_spacing, int right_spacing)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
removables_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *content = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
@ -575,7 +575,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
removables_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"spacing", false, &conf_verify_int},
@ -588,3 +588,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("removables_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("removables_from_conf")));
#endif

View file

@ -469,14 +469,14 @@ xkb_new(struct particle *label)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
xkb_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return xkb_new(conf_to_particle(c, inherited));
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
xkb_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"content", true, &conf_verify_particle},
@ -486,3 +486,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("xkb_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("xkb_from_conf")));
#endif

View file

@ -313,14 +313,14 @@ xwindow_new(struct particle *label)
}
struct module *
from_conf(const struct yml_node *node, struct conf_inherit inherited)
xwindow_from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return xwindow_new(conf_to_particle(c, inherited));
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
xwindow_verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"content", true, &conf_verify_particle},
@ -330,3 +330,12 @@ verify_conf(keychain_t *chain, const struct yml_node *node)
return conf_verify_dict(chain, node, attrs);
}
#if defined(CORE_PLUGINS_AS_SHARED_LIBRARIES)
bool verify_conf(keychain_t *chain, const struct yml_node *node)
__attribute__((weak, alias("xwindow_verify_conf")));
struct deco *from_conf(const struct yml_node *node, struct conf_inherit inherited)
__attribute__((weak, alias("xwindow_from_conf")));
#endif