Compare commits

..

6 Commits

5 changed files with 66 additions and 9 deletions

View File

@ -13,6 +13,16 @@
* @{
*/
/**
* @brief This define is used to export a function from a shared object
*/
#define EXPORT_FUNC __attribute__((visibility("default")))
/**
* @brief This define is used to export a variable symbol from a shared object
*/
#define EXPORT_VAR EXPORT_FUNC
/**
* @brief Function name expected to be found in external library for rendering.
*
@ -46,14 +56,22 @@
*
* The pure presence of this symbol name causes forking. The content of this variable is don't care.
* @note Use this if you mess with the internal structures of gds-render
*
*/
#define EXTERNAL_LIBRARY_FORK_REQUEST exported_fork_request
/**
* @brief Define for declaring the exported functions
* @brief Define for declaring the exported functions.
*
* This not only helps with the declaration but also makes the symbols visible, so they can be called form outside the library
*/
#define FUNC_DECL(FUNC) FUNC
#define EXPORTED_FUNC_DECL(FUNC) EXPORT_FUNC FUNC
/**
* @brief Define for declaring exported variables
*
* This not only helps with the declaration but also makes the symbols visible, so they can be accessed form outside the library
*/
#define EXPORTED_VAR_DECL(VAR) EXPORT_VAR VAR
/** @} */

View File

@ -9,3 +9,5 @@ link_libraries(version)
add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL ${SOURCES})
add_dependencies(${PROJECT_NAME} version)
set_target_properties(${PROJECT_NAME} PROPERTIES C_VISIBILITY_PRESET hidden)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)

View File

@ -30,7 +30,7 @@
#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)
int EXPORTED_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;
@ -39,13 +39,13 @@ int FUNC_DECL(EXTERNAL_LIBRARY_RENDER_FUNCTION)(struct gds_cell *toplevel, GList
return 0;
}
int FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const char *version)
int EXPORTED_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;
}
int FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
{
return 0;
}

View File

@ -0,0 +1,37 @@
/*
* GDSII-Converter Python Plugin
* Copyright (C) 2019 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of GDSII-Converter.
*
* GDSII-Converter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* GDSII-Converter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file python-renderer/force-fork.c
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @addtogroup python-plugin
* @{
*/
#include <gds-render/output-renderers/external-renderer-interfaces.h>
/* The precense of this variable tells the gds-render application to execute this plugin in a separate process
* The variable's value is don't care
*/
const int EXPORTED_VAR_DECL(EXTERNAL_LIBRARY_FORK_REQUEST) = 1;
/** @} */

View File

@ -47,7 +47,7 @@
*/
static PyObject *p_module = NULL;
int FUNC_DECL(EXTERNAL_LIBRARY_RENDER_FUNCTION)(struct gds_cell *toplevel, GList *layer_info_list, const char *output_file_name, double scale)
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_RENDER_FUNCTION)(struct gds_cell *toplevel, GList *layer_info_list, const char *output_file_name, double scale)
{
int ret = 0;
PyObject *p_render_func;
@ -83,7 +83,7 @@ return_value:
return ret;
}
int FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const char *version)
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const char *version)
{
int ret = 0;
PyObject *p_name;
@ -157,7 +157,7 @@ return_value:
return ret;
}
int FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
{
int ret;