mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
Add compile time definition for module path and remove rpath
This commit is contained in:
parent
2e113fcfaf
commit
a4cebd6b37
@ -9,6 +9,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Provide default
|
||||
|
||||
// Categories for modules.
|
||||
enum tc_module_category {
|
||||
TC_CATEGORY_ASSIGNABLE,
|
||||
@ -16,9 +18,10 @@ enum tc_module_category {
|
||||
TC_CATEGORY_INTERFACE
|
||||
};
|
||||
|
||||
// REPLACE THIS WITH SOMETHING MORE ROBUST
|
||||
// Default path for modules
|
||||
#define TC_MODULE_PATH "/usr/lib/tuxclocker"
|
||||
// Default module path in case not defined
|
||||
#ifndef TC_MODULE_PATH
|
||||
#define TC_MODULE_PATH "/usr/lib/tuxclocker/modules"
|
||||
#endif
|
||||
|
||||
// Env variable name to load modules from in addition
|
||||
#define TC_MODULE_PATH_ENV "TC_MODULE_PATH"
|
||||
|
@ -9,18 +9,22 @@ tc_module_t *tc_module_find(enum tc_module_category category, const char *name)
|
||||
char mod_abs_path[128];
|
||||
|
||||
// Find the folder where the module should reside
|
||||
// TC_MODULE_PATH should be defined as an absolute path
|
||||
switch (category) {
|
||||
case TC_CATEGORY_ASSIGNABLE:
|
||||
snprintf(mod_abs_path, 128, "%s/%s", "assignable", name);
|
||||
snprintf(mod_abs_path, 128, "%s/%s/%s", TC_MODULE_PATH, "assignable", name);
|
||||
break;
|
||||
case TC_CATEGORY_INTERFACE:
|
||||
snprintf(mod_abs_path, 128, "%s/%s", "interface", name);
|
||||
snprintf(mod_abs_path, 128, "%s/%s/%s", TC_MODULE_PATH, "interface", name);
|
||||
// snprintf(mod_abs_path, 128, "/usr/lib/tuxclocker/modules/interface/%s", name);
|
||||
//snprintf(mod_abs_path, 128, "%s", name);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
void *handle = tc_dlopen(mod_abs_path);
|
||||
if (handle == NULL) {
|
||||
printf("%s\n", tc_dlerror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -30,5 +34,7 @@ tc_module_t *tc_module_find(enum tc_module_category category, const char *name)
|
||||
}
|
||||
|
||||
tc_module_t **tc_module_find_all_from_category(enum tc_module_category category, uint16_t *count) {
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
posix_bin = executable('tuxclocker',
|
||||
'tuxclocker.c',
|
||||
include_directories : incdir,
|
||||
link_with : libtuxclocker)
|
||||
link_with : libtuxclocker,
|
||||
install : true)
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Load an interface here
|
||||
tc_module_t *mod = tc_module_find(TC_CATEGORY_INTERFACE, "/qt/libqt.so");
|
||||
tc_module_t *mod = tc_module_find(TC_CATEGORY_INTERFACE, "libqt.so");
|
||||
|
||||
if (mod != NULL) {
|
||||
printf("successful load for %s\n", mod->name);
|
||||
|
@ -4,9 +4,9 @@ libtuxclocker_posix_sources = ['lib/posix/module.c']
|
||||
|
||||
libtuxclocker_posix_libs = [cc.find_library('dl')]
|
||||
|
||||
# Posix library uses runpath for specifying module directory root
|
||||
|
||||
posix_rpath = get_option('libdir' ) + '/tuxclocker/modules'
|
||||
# Compile time definition for module path
|
||||
module_path_def_template = '-DTC_MODULE_PATH="@0@/@1@/tuxclocker/modules"'
|
||||
module_path_def = module_path_def_template.format(get_option('prefix'), get_option('libdir'))
|
||||
|
||||
libtuxclocker = shared_library('libtuxclocker',
|
||||
['lib/tc_assignable.c',
|
||||
@ -14,8 +14,8 @@ libtuxclocker = shared_library('libtuxclocker',
|
||||
libtuxclocker_posix_sources],
|
||||
include_directories : incdir,
|
||||
dependencies : libtuxclocker_posix_libs,
|
||||
install_rpath : posix_rpath,
|
||||
link_args : '-Wl,--enable-new-dtags')
|
||||
c_args : module_path_def,
|
||||
install : true)
|
||||
|
||||
subdir('modules')
|
||||
subdir('main')
|
||||
|
@ -19,4 +19,6 @@ shared_library('qt',
|
||||
moc_files,
|
||||
include_directories : [incdir, local_qt_incdirs],
|
||||
dependencies : qt5_dep,
|
||||
link_with : libtuxclocker)
|
||||
link_with : libtuxclocker,
|
||||
install_dir : get_option('libdir') / 'tuxclocker' / 'modules' / 'interface',
|
||||
install : true)
|
||||
|
@ -11,7 +11,7 @@ AssignableWidget::AssignableWidget(QWidget *parent) : QWidget(parent) {
|
||||
m_mainLayout->addWidget(m_splitter);
|
||||
|
||||
m_assignableTreeView = new QTreeView;
|
||||
genAssignableTree(m_assignableTreeView);
|
||||
//genAssignableTree(m_assignableTreeView);
|
||||
m_splitter->addWidget(m_assignableTreeView);
|
||||
|
||||
m_assignableEditor = new AssignableEditor;
|
||||
|
Loading…
Reference in New Issue
Block a user