Compare commits

..

No commits in common. "3b6837b886ebe2767710fdf642db9aa738c51283" and "c186d3cdb3032fc5777ceb9e17d3445296d9821f" have entirely different histories.

10 changed files with 20 additions and 64 deletions

View File

@ -30,7 +30,6 @@ pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0) pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(CAIRO REQUIRED cairo) pkg_check_modules(CAIRO REQUIRED cairo)
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_subdirectory(plugins) add_subdirectory(plugins)
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter) add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
@ -49,6 +48,7 @@ add_subdirectory(doxygen)
add_subdirectory(translations) add_subdirectory(translations)
add_subdirectory(version) add_subdirectory(version)
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS}) link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
add_definitions(${GLIB2_CFLAGS_OTHER}) add_definitions(${GLIB2_CFLAGS_OTHER})

View File

@ -104,9 +104,7 @@ static int create_renderers(char **renderers,
fprintf(stderr, _("Please specify shared object for external renderer. Will ignore this renderer.\n")); fprintf(stderr, _("Please specify shared object for external renderer. Will ignore this renderer.\n"));
continue; continue;
} }
output_renderer = GDS_RENDER_OUTPUT_RENDERER( output_renderer = GDS_RENDER_OUTPUT_RENDERER(external_renderer_new_with_so(ext_params->so_path));
external_renderer_new_with_so_and_param(ext_params->so_path,
ext_params->cli_params));
} else { } else {
continue; continue;
} }

View File

@ -9,7 +9,6 @@
* Property Name | Description * Property Name | Description
* -----------------|---------------------------------------------------------------- * -----------------|----------------------------------------------------------------
* shared-object-path | Path to the shared object used for rendering * shared-object-path | Path to the shared object used for rendering
* param-string | Command line parameters passed to external renderer's init function
* *
* All these properties have to be set for rendering. * All these properties have to be set for rendering.
* *

View File

@ -41,11 +41,6 @@
*/ */
#define EXTERNAL_LIBRARY_FORK_REQUEST exported_fork_request #define EXTERNAL_LIBRARY_FORK_REQUEST exported_fork_request
/**
* @brief Define for declaring the exported functions
*/
#define FUNC_DECL(FUNC) FUNC
/** @} */ /** @} */
#endif /* __EXTERNAL_RENDERER_INTERFACES_H__ */ #endif /* __EXTERNAL_RENDERER_INTERFACES_H__ */

View File

@ -50,10 +50,9 @@ ExternalRenderer *external_renderer_new();
/** /**
* @brief Create new ExternalRenderer object with specified shared object path * @brief Create new ExternalRenderer object with specified shared object path
* @param so_path Path to shared object, the rendering function is searched in * @param so_path Path to shared object, the rendering function is searched in
* @param param_string Command line parameter string passed to external renderer
* @return New object. * @return New object.
*/ */
ExternalRenderer *external_renderer_new_with_so_and_param(const char *so_path, const char *param_string); ExternalRenderer *external_renderer_new_with_so(const char *so_path);
G_END_DECLS G_END_DECLS

View File

@ -40,12 +40,10 @@
struct _ExternalRenderer { struct _ExternalRenderer {
GdsOutputRenderer parent; GdsOutputRenderer parent;
char *shared_object_path; char *shared_object_path;
char *cli_param_string;
}; };
enum { enum {
PROP_SO_PATH = 1, /**< @brief Shared object path property */ PROP_SO_PATH = 1, /**< @brief Shared object path property */
PROP_PARAM_STRING, /** @brief Shared object renderer parameter string from CLI */
N_PROPERTIES /**< @brief Used to get property count */ N_PROPERTIES /**< @brief Used to get property count */
}; };
@ -58,11 +56,10 @@ G_DEFINE_TYPE(ExternalRenderer, external_renderer, GDS_RENDER_TYPE_OUTPUT_RENDER
* @param output_file Destination file * @param output_file Destination file
* @param scale the scaling value to scale the output cell down by. * @param scale the scaling value to scale the output cell down by.
* @param so_path Path to shared object * @param so_path Path to shared object
* @param params Parameters passed to EXTERNAL_LIBRARY_INIT_FUNCTION
* @return 0 if successful * @return 0 if successful
*/ */
static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_info_list, static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_info_list,
const char *output_file, double scale, const char *so_path, const char *params) const char *output_file, double scale, const char *so_path)
{ {
int (*so_render_func)(struct gds_cell *, GList *, const char *, double) = NULL; int (*so_render_func)(struct gds_cell *, GList *, const char *, double) = NULL;
int (*so_init_func)(const char *, const char *) = NULL; int (*so_init_func)(const char *, const char *) = NULL;
@ -123,15 +120,14 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
if (fork_pid != 0) if (fork_pid != 0)
goto end_forked; goto end_forked;
ret = so_init_func(params, _app_version_string); // TODO: Get parameters form command line and pass here
ret = so_init_func(NULL, _app_version_string);
if (!ret) if (!ret)
ret = so_render_func(toplevel_cell, layer_info_list, output_file, scale); ret = so_render_func(toplevel_cell, layer_info_list, output_file, scale);
/* If we are in a separate process, terminate here */
if (forking_req) if (forking_req)
exit(ret); exit(ret);
/* The forked paths end here */
end_forked: end_forked:
if (forking_req) { if (forking_req) {
waitpid(fork_pid, &forked_status, 0); waitpid(fork_pid, &forked_status, 0);
@ -162,8 +158,7 @@ static int external_renderer_render_output(GdsOutputRenderer *renderer,
if (settings) if (settings)
layer_infos = layer_settings_get_layer_info_list(settings); layer_infos = layer_settings_get_layer_info_list(settings);
ret = external_renderer_render_cell(cell, layer_infos, output_file, scale, ext_renderer->shared_object_path, ret = external_renderer_render_cell(cell, layer_infos, output_file, scale, ext_renderer->shared_object_path);
ext_renderer->cli_param_string);
if (settings) if (settings)
g_object_unref(settings); g_object_unref(settings);
@ -180,9 +175,6 @@ static void external_renderer_get_property(GObject *obj, guint property_id, GVal
case PROP_SO_PATH: case PROP_SO_PATH:
g_value_set_string(value, self->shared_object_path); g_value_set_string(value, self->shared_object_path);
break; break;
case PROP_PARAM_STRING:
g_value_set_string(value, self->cli_param_string);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec);
break; break;
@ -201,11 +193,6 @@ static void external_renderer_set_property(GObject *obj, guint property_id, cons
g_free(self->shared_object_path); g_free(self->shared_object_path);
self->shared_object_path = g_value_dup_string(value); self->shared_object_path = g_value_dup_string(value);
break; break;
case PROP_PARAM_STRING:
if (self->cli_param_string)
g_free(self->cli_param_string);
self->cli_param_string = g_value_dup_string(value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec);
break; break;
@ -214,9 +201,7 @@ static void external_renderer_set_property(GObject *obj, guint property_id, cons
static void external_renderer_dispose(GObject *self_obj) static void external_renderer_dispose(GObject *self_obj)
{ {
ExternalRenderer *self; ExternalRenderer *self = GDS_RENDER_EXTERNAL_RENDERER(self_obj);
self = GDS_RENDER_EXTERNAL_RENDERER(self_obj);
if (self->shared_object_path) { if (self->shared_object_path) {
g_free(self->shared_object_path); g_free(self->shared_object_path);
@ -251,19 +236,12 @@ static void external_renderer_class_init(ExternalRendererClass *klass)
"Path to the shared object to search rendering function in.", "Path to the shared object to search rendering function in.",
NULL, NULL,
G_PARAM_READWRITE); G_PARAM_READWRITE);
external_renderer_properties[PROP_PARAM_STRING] =
g_param_spec_string("param-string",
"Shared object renderer parameter string",
"Command line arguments passed to the external shared object renderer",
NULL,
G_PARAM_READWRITE);
g_object_class_install_properties(oclass, N_PROPERTIES, external_renderer_properties); g_object_class_install_properties(oclass, N_PROPERTIES, external_renderer_properties);
} }
static void external_renderer_init(ExternalRenderer *self) static void external_renderer_init(ExternalRenderer *self)
{ {
self->shared_object_path = NULL; self->shared_object_path = NULL;
self->cli_param_string = NULL;
} }
ExternalRenderer *external_renderer_new() ExternalRenderer *external_renderer_new()
@ -271,10 +249,9 @@ ExternalRenderer *external_renderer_new()
return g_object_new(GDS_RENDER_TYPE_EXTERNAL_RENDERER, NULL); return g_object_new(GDS_RENDER_TYPE_EXTERNAL_RENDERER, NULL);
} }
ExternalRenderer *external_renderer_new_with_so_and_param(const char *so_path, const char *param_string) ExternalRenderer *external_renderer_new_with_so(const char *so_path)
{ {
return g_object_new(GDS_RENDER_TYPE_EXTERNAL_RENDERER, "shared-object-path", so_path, return g_object_new(GDS_RENDER_TYPE_EXTERNAL_RENDERER, "shared-object-path", so_path, NULL);
"param-string", param_string,NULL);
} }
/** @} */ /** @} */

View File

@ -1,2 +1,2 @@
add_subdirectory(plugin-example) add_subdirectory(python-renderer)
add_custom_target(plugins DEPENDS pluginexample) add_custom_target(plugins DEPENDS pythonrenderer)

View File

@ -1,19 +0,0 @@
#include <stdio.h>
#include <glib.h>
#include <gds-render/gds-utils/gds-types.h>
#include <gds-render/output-renderers/external-renderer-interfaces.h>
int FUNC_DECL(EXTERNAL_LIBRARY_RENDER_FUNCTION)(struct gds_cell *toplevel, GList *layer_info_list, const char *output_file_name, double scale)
{
if (!toplevel)
return -1000;
printf("Rendering %s\n", toplevel->name);
return 0;
}
int FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const char *version)
{
printf("Init with params: %s\ngds-render version: %s\n", params, version);
return 0;
}

View File

@ -1,4 +1,4 @@
project(pluginexample) project(pythonrenderer)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_search_module(PYTHON REQUIRED python3) pkg_search_module(PYTHON REQUIRED python3)

View File

@ -0,0 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
int a(void)
{
return 0;
}