mirror of
https://github.com/dyne/frei0r.git
synced 2025-12-05 22:29:59 +01:00
initial info extractor for tests
This commit is contained in:
15
test/Makefile
Normal file
15
test/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
INCLUDES ?= -I ../include
|
||||
|
||||
all: build scan-filters
|
||||
|
||||
scan-filters:
|
||||
@$(if $(wildcard ../build),,>&2 echo "Test needs a ../build" && exit 1)
|
||||
@find ../build/src -type f -name '*.so' -exec ./frei0r-info {} \; > tmp.json && echo "[" > frei0r-plugin-list.json && head -n -1 tmp.json >> frei0r-plugin-list.json && echo "}\n]" >> frei0r-plugin-list.json && rm tmp.json && >&2 echo "frei0r-plugin-list.json"
|
||||
|
||||
build:
|
||||
@${CC} -o frei0r-info -ggdb frei0r-info.c ${INCLUDES}
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f frei0r-info
|
||||
rm -f *.json
|
||||
48
test/frei0r-info.c
Normal file
48
test/frei0r-info.c
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <frei0r.h>
|
||||
|
||||
typedef void (*f0r_get_plugin_info_f)(f0r_plugin_info_t *info);
|
||||
/* typedef void (*f0r_get_param_info_f)(f0r_param_info_t *info, int param_index); */
|
||||
/* typedef void (*f0r_get_param_value_f)(f0r_instance_t instance, f0r_param_t param, int param_index); */
|
||||
|
||||
/* f0r_get_param_info_f get_param_info; */
|
||||
/* f0r_get_param_value_f get_param_value; */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
static void *dl_handle;
|
||||
static f0r_plugin_info_t pi;
|
||||
static f0r_get_plugin_info_f f0r_get_plugin_info;
|
||||
if(argc<2) exit(1);
|
||||
// load shared library
|
||||
dl_handle = dlopen(argv[1], RTLD_NOW|RTLD_LOCAL);
|
||||
if(!dl_handle) {
|
||||
fprintf(stderr,"error: %s\n",dlerror());
|
||||
exit(1);
|
||||
}
|
||||
// get plugin info
|
||||
f0r_get_plugin_info = dlsym(dl_handle,"f0r_get_plugin_info");
|
||||
f0r_get_plugin_info(&pi);
|
||||
fprintf(stdout,
|
||||
"{\n \"name\":\"%s\",\n \"type\":\"%s\",\n \"author\":\"%s\",\n"
|
||||
"\"explanation\":\"%s\",\n \"color_model\":\"%s\",\n"
|
||||
"\"frei0r_version\":\"%d\",\n \"version\":\"%d.%d\",\n \"num_params\":\"%d\"\n},\n",
|
||||
pi.name,
|
||||
pi.plugin_type == F0R_PLUGIN_TYPE_FILTER ? "filter" :
|
||||
pi.plugin_type == F0R_PLUGIN_TYPE_SOURCE ? "source" :
|
||||
pi.plugin_type == F0R_PLUGIN_TYPE_MIXER2 ? "mixer2" :
|
||||
pi.plugin_type == F0R_PLUGIN_TYPE_MIXER3 ? "mixer3" : "unknown",
|
||||
pi.author, pi.explanation,
|
||||
pi.color_model == F0R_COLOR_MODEL_BGRA8888 ? "bgra8888" :
|
||||
pi.color_model == F0R_COLOR_MODEL_RGBA8888 ? "rgba8888" :
|
||||
pi.color_model == F0R_COLOR_MODEL_PACKED32 ? "packed32" : "unknown",
|
||||
pi.frei0r_version, pi.major_version, pi.minor_version, pi.num_params);
|
||||
|
||||
dlclose(dl_handle);
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user