Compare commits

...

51 Commits

Author SHA1 Message Date
Mario Hüttel b959f8282a Add Glist wrapper to python renderer 2020-07-04 00:44:46 +02:00
Mario Hüttel 22efe4f8ca Merge branch 'dev' into python-renderer 2020-07-04 00:00:16 +02:00
Mario Hüttel 391789b812 Merge branch 'master' into python-renderer 2020-04-24 01:07:25 +02:00
Mario Hüttel 98483da759 Merge branch 'dev' into python-renderer 2020-04-24 01:06:23 +02:00
Mario Hüttel aafcb162b7 Merge branch 'dev' into python-renderer 2020-04-24 01:03:05 +02:00
Mario Hüttel 1fac7d7721 Merge branch 'dev' into python-renderer 2020-04-19 03:00:22 +02:00
Mario Hüttel b30aaa4c4e Merge branch 'dev' into python-renderer 2020-04-19 00:52:22 +02:00
Mario Hüttel fb6e3a29af Merge branch 'dev' into python-renderer 2020-04-19 00:41:08 +02:00
Mario Hüttel f03dd0ab19 Add log message to finalize function of example renderer 2020-04-18 03:30:44 +02:00
Mario Hüttel b6a2f29a2f Merge branch 'dev' into python-renderer 2020-04-16 22:48:05 +02:00
Mario Hüttel 921b55b962 Merge branch 'master' into python-renderer 2020-04-03 20:55:46 +02:00
Mario Hüttel 4d3f0ccb94 Merge branch 'master' into python-renderer 2020-04-02 00:48:15 +02:00
Mario Hüttel 7526597251 Merge branch 'master' into python-renderer 2020-02-10 23:06:40 +01:00
Mario Hüttel 1278af202a Merge branch 'dev' into python-renderer 2019-12-12 20:56:00 +01:00
Mario Hüttel b63da7bf09 Merge branch 'dev' into python-renderer 2019-12-07 19:08:05 +01:00
Mario Hüttel 23ba7c0136 Fix typo 2019-11-28 18:24:26 +01:00
Mario Hüttel 7721a40912 Merge branch 'dev' into python-renderer 2019-11-28 17:59:22 +01:00
Mario Hüttel 7297800a99 Merge branch 'dev' into python-renderer 2019-11-25 20:57:17 +01:00
Mario Hüttel 943007685c Merge branch 'dev' into python-renderer 2019-11-19 01:34:12 +01:00
Mario Hüttel 7d6faf8db7 Merge branch 'dev' into python-renderer 2019-11-18 22:31:06 +01:00
Mario Hüttel 9eed1ac33d Add header for foced fork variable. Don't know what it is good for yet. But why not... 2019-11-18 22:20:18 +01:00
Mario Hüttel 246695610c plugins: python renderer: Fix broken code due to merge. Functions of plugins now have to be exported explicitly. 2019-11-18 22:07:58 +01:00
Mario Hüttel bd4d91807b Merge branch 'dev' into python-renderer 2019-11-18 22:00:45 +01:00
Mario Hüttel 2aa1fffa8e plugins: python renderer: Add fork request to python renderer library, so it wont destory the base application 2019-11-18 21:43:49 +01:00
Mario Hüttel 447d583103 plugins: python renderer: Add color output to cmake 2019-11-18 21:29:42 +01:00
Mario Hüttel 394efb79cf Merge branch 'python-renderer' of git.shimatta.de:mhu/gds-render into python-renderer 2019-11-18 20:29:01 +01:00
Mario Hüttel 2420b80c9e plugins: python renderer: Add GdsPoint object type definition to gds_render module. This is still playing around as I don't really know what I'm doing at the moment. 2019-11-18 20:28:43 +01:00
Mario Hüttel 02f221b926 Merge branch 'master' into python-renderer 2019-11-17 22:32:01 +01:00
Mario Hüttel dd2f21c5cd Fix remaining licence headers 2019-11-17 17:30:08 +01:00
Mario Hüttel b27676e0a4 plugins: python renderer: Make python scripts work from all directories 2019-11-17 17:12:15 +01:00
Mario Hüttel b610b1593a Fix author in doxygen tag 2019-11-17 16:25:03 +01:00
Mario Hüttel 95f6b31e4b python renderer: Try out function parameters 2019-11-17 16:18:03 +01:00
Mario Hüttel a4d84cff43 Fix license header 2019-11-17 15:52:28 +01:00
Mario Hüttel aa7f5b4745 plugins: python-renderer: Implement first gds_render built-in module with a get_number function 2019-11-17 15:42:17 +01:00
Mario Hüttel 71b500e030 Merge branch 'dev' into python-renderer 2019-11-17 14:49:13 +01:00
Mario Hüttel d69d4f3f7e plugins: python-renderer: Add gds-render-module 2019-11-17 14:44:21 +01:00
Mario Hüttel a60fe6543e plugins: python-renderer: Remove unneeded file exists function 2019-11-17 14:15:35 +01:00
Mario Hüttel dc32499ad7 plugins: python-renderer: Fix missing closing bracket in doxygen group 2019-11-17 14:13:43 +01:00
Mario Hüttel 322439145e plugins: python-renderer: Add license and doxygen 2019-11-17 14:13:06 +01:00
Mario Hüttel 231248e404 Remove empty line 2019-11-17 14:11:16 +01:00
Mario Hüttel 88d912f59d Merge branch 'dev' into python-renderer 2019-11-17 14:10:55 +01:00
Mario Hüttel f454ca7e71 Merge branch 'dev' into python-renderer 2019-11-17 01:52:17 +01:00
Mario Hüttel 045b9dce30 plugins: python renderer: Dereference function after calling 2019-11-17 01:13:49 +01:00
Mario Hüttel 112a5ac74c plugins: python renderer: Implement first draft that loads a python module and calls a test function. This will be changed later 2019-11-17 00:53:24 +01:00
Mario Hüttel 6b5101ecec plugins: python renderer: Load module 2019-11-17 00:02:42 +01:00
Mario Hüttel 583e5581c0 Find python path correctly 2019-11-17 00:01:55 +01:00
Mario Hüttel 519d2296ad Add more error handling to command line interface to handle empty layer mapping spec 2019-11-16 23:42:48 +01:00
Mario Hüttel 02720ec37b plugins: python-renderer: add finalize function 2019-11-16 22:53:10 +01:00
Mario Hüttel cf2947d2d5 Add finalize function as exported function to external renderer and use it in the main app after rendering 2019-11-16 22:44:41 +01:00
Mario Hüttel c7ceef7d66 Merge branch 'dev' into python-renderer 2019-11-16 16:03:05 +01:00
Mario Hüttel ebce4a2669 Add python renderer to plugins 2019-11-16 14:54:58 +01:00
54 changed files with 674 additions and 53 deletions

View File

@ -38,7 +38,7 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/translations/output\")
message("${BoldMagenta}${CMAKE_CURRENT_BINARY_DIR}/translations/output used as data dir${ColorReset}")
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Global locale directory used. Make sure files in /usr/share/locale are available")
message("${BoldCyan}Global locale directory used. Make sure files in /usr/share/locale are available${ColorReset}")
add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"/usr/share\")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
@ -146,6 +146,7 @@ int command_line_convert_gds(const char *gds_name,
double scale)
{
int ret = -1;
int render_ret;
GList *libs = NULL;
int res;
GList *renderer_list = NULL;
@ -163,7 +164,14 @@ int command_line_convert_gds(const char *gds_name,
/* Load layer_settings */
layer_sett = layer_settings_new();
layer_settings_load_from_csv(layer_sett, layer_file);
if (!layer_sett)
goto return_value;
ret = layer_settings_load_from_csv(layer_sett, layer_file);
if (ret) {
fprintf(stderr, _("Loading layer mapping file failed.\n"));
goto ret_destroy_layer_mapping;
}
/* Create renderers */
if (create_renderers(renderers, output_file_names, tex_layers, tex_standalone,
@ -221,7 +229,9 @@ int command_line_convert_gds(const char *gds_name,
/* Execute all rendererer instances */
for (list_iter = renderer_list; list_iter; list_iter = list_iter->next) {
current_renderer = GDS_RENDER_OUTPUT_RENDERER(list_iter->data);
gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
render_ret = gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
if (render_ret)
fprintf(stderr, "Rendering failed with error code: %d\n", render_ret);
}
ret_destroy_library_list:
@ -231,6 +241,7 @@ ret_clear_renderers:
g_object_unref(list_iter->data);
ret_destroy_layer_mapping:
g_object_unref(layer_sett);
return_value:
return ret;
}

View File

@ -22,5 +22,6 @@
* @ref EXTERNAL_LIBRARY_RENDER_FUNCTION | int EXTERNAL_LIBRARY_RENDER_FUNCTION(struct gds_cell *toplevel, GList *layer_info_list, const char *output_file_name, double scale) | Render cell to output file
* @ref EXTERNAL_LIBRARY_INIT_FUNCTION | int EXTERNAL_LIBRARY_INIT_FUNCTION(const char *option_string, const char *version_string) | Init function. Executed before rendering. This is given the command line parameters specified for the external renderer and the version string of the currently running gds-render program.
* @ref EXTERNAL_LIBRARY_FORK_REQUEST | int EXTERNAL_LIBRARY_FORK_REQUEST; | The pure presence of this integer results in the execution inside a subprocess of hte whole shared object's code
* @ref EXTERNAL_LIBRARY_FINALIZE_FUNCTION | int EXTERNAL_LIBRARY_FINALIZE_FUNCTION(void) | Called after rendering
*
*/

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file cairo-renderer.h

View File

@ -37,6 +37,11 @@
*/
#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.
*
@ -56,6 +61,15 @@
*/
#define EXTERNAL_LIBRARY_INIT_FUNCTION exported_init
/**
* @brief Function name expected to be found in external library for finalizing.
*
* @code
* int EXTERNAL_LIBRARY_FINALIZE_FUNCTION(void);
* @endcode
*/
#define EXTERNAL_LIBRARY_FINALIZE_FUNCTION exported_finalize
/**
* @brief Global integer specified by an external renderer to signal, that the init and render functions shall be executed in a subprocess
*
@ -67,10 +81,29 @@
/**
* @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
* This not only helps with the declaration but also makes the symbols visible, so they can be called from outside the library
*/
#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 from outside the library
*/
#define EXPORTED_VAR_DECL(VAR) EXPORT_VAR VAR
/**
* @brief Define for declaring variables based on a define expansion
* @note If you want to declare an exported variable use @ref EXPORTED_VAR_DECL
*/
#define VAR_DECL(VAR) VAR
/**
* @brief Define for declaring functions based on a define expansion
* @note If you want to declare an exported function use @ref EXPORTED_FUNC_DECL
*/
#define FUNC_DECL(FUNC) FUNC
/** @} */
#endif /* __EXTERNAL_RENDERER_INTERFACES_H__ */

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

2
main.c
View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file cairo-renderer.c

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
@ -67,6 +67,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
{
int (*so_render_func)(struct gds_cell *, GList *, const char *, double) = NULL;
int (*so_init_func)(const char *, const char *) = NULL;
int (*so_finalize_func)(void) = NULL;
void *so_handle = NULL;
char *error_msg;
int forking_req;
@ -94,7 +95,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
so_render_func = (int (*)(struct gds_cell *, GList *, const char *, double))
dlsym(so_handle, xstr(EXTERNAL_LIBRARY_RENDER_FUNCTION));
error_msg = dlerror();
if (error_msg != NULL) {
if (error_msg) {
fprintf(stderr, _("Rendering function not found in library:\n%s\n"), error_msg);
goto ret_close_so_handle;
}
@ -102,8 +103,16 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
/* Load the init function */
so_init_func = (int (*)(const char *, const char *))dlsym(so_handle, xstr(EXTERNAL_LIBRARY_INIT_FUNCTION));
error_msg = dlerror();
if (error_msg != NULL) {
fprintf(stderr, _("Init function not found in library:\n%s\n"), error_msg);
if (error_msg) {
fprintf(stderr, _("Rendering function not found in library:\n%s\n"), error_msg);
goto ret_close_so_handle;
}
/* Load the finalize function */
so_finalize_func = (int (*)(void))dlsym(so_handle, xstr(EXTERNAL_LIBRARY_FINALIZE_FUNCTION));
error_msg = dlerror();
if (error_msg) {
fprintf(stderr, "Finalize function not found in library:\n%s\n", error_msg);
goto ret_close_so_handle;
}
@ -128,6 +137,9 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
if (!ret)
ret = so_render_func(toplevel_cell, layer_info_list, output_file, scale);
/* Finalize the external renderer */
ret |= so_finalize_func();
/* If we are in a separate process, terminate here */
if (forking_req)
exit(ret);

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

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

View File

@ -1,12 +1,11 @@
project(pluginexample)
cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig REQUIRED)
pkg_search_module(PYTHON REQUIRED python3)
aux_source_directory(src SOURCES)
include_directories(${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
link_libraries(${PYTHON_LDFLAGS} version)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
link_libraries(version)
add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL ${SOURCES})
add_dependencies(${PROJECT_NAME} version)

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**
@ -25,7 +25,6 @@
* @{
*/
#include <stdio.h>
#include <glib.h>
#include <gds-render/gds-utils/gds-types.h>
@ -46,4 +45,10 @@ int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const
return 0;
}
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
{
printf("Finalize function called.\n");
return 0;
}
/** @} */

View File

@ -0,0 +1,34 @@
project(pythonrenderer)
cmake_minimum_required(VERSION 2.8.8)
find_package(PythonLibs)
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(ColorBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()
aux_source_directory(src SOURCES)
include_directories(${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
link_libraries(${PYTHON_LIBRARIES} version)
message("${BoldCyan}Python version found: ${PYTHONLIBS_VERSION_STRING}${ColorReset}")
add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL ${SOURCES})
add_dependencies(${PROJECT_NAME} version)

View File

@ -0,0 +1,43 @@
/*
* 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 force-fork.h
* @brief Header file force fork variabel definition.
*
* This file makes the force fork variable accessible.
* Actually this is kind of useless. However, here it is :)
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#ifndef __PYTHON_PLUGIN_FORCE_FORK_H__
#define __PYTHON_PLUGIN_FORCE_FORK_H__
/**
* @addtogroup python-plugin
* @{
*/
#include <gds-render/output-renderers/external-renderer-interfaces.h>
extern const int VAR_DECL(EXTERNAL_LIBRARY_FORK_REQUEST);
/** @} */
#endif /* __PYTHON_PLUGIN_FORCE_FORK_H__ */

View File

@ -0,0 +1,49 @@
/*
* 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 gds-render-module.h
* @brief Header file for the gds-render python module implementation
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#ifndef __GDS_RENDER_MODULE_H__
#define __GDS_RENDER_MODULE_H__
/**
* @addtogroup python-renderer
* @{
*/
#include <Python.h>
/**
* @brief The gds_render python module name as string
*/
#define GDS_RENDER_MOD_NAME "gds_render"
/**
* @brief Set up the gds_render python module
* @return New module reference
*/
PyObject *init_gds_render_module();
/** @} */
#endif /* __GDS_RENDER_MODULE_H__ */

View File

@ -0,0 +1,50 @@
/*
* GDSII-Converter Python Plugin
* Copyright (C) 2020 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/glist.c
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @defgroup python-plugin-glist GList wrapper for python
* @ingroup python-plugin
* This is a wrapping class for GLists
* @addtogroup python-plugin-glist
* @{
*/
#ifndef __GLIST_H__
#define __GLIST_H__
#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif
#include <Python.h>
#include <glib.h>
extern PyTypeObject GListType;
typedef struct _GListObject GListObject;
void glist_set_head_ptr(GListObject *self, GList *head);
#endif /* __GLIST_H__ */
/** @} */

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>
*/
#include <python-renderer/force-fork.h>
/**
* @addtogroup python-plugin
* @{
*/
/* 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

@ -0,0 +1,100 @@
/*
* 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 gds-render-module.c
* @brief Gds-render python module implementation
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#include <python-renderer/gds-render-module.h>
#include <gds-render/gds-utils/gds-types.h>
#include <python-renderer/glist.h>
static PyObject *test(PyObject *self, PyObject *args)
{
long int i;
if(!PyArg_ParseTuple(args, "l:get_number", &i))
return NULL;
i *= i;
return PyLong_FromLong(i);
}
static PyMethodDef gds_render_methods[] = {
{"get_number", test, METH_VARARGS, "Return the number of arguments received by the process."},
{NULL, NULL, 0, NULL}
};
static PyModuleDef gds_render_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = GDS_RENDER_MOD_NAME,
.m_doc = "GDS Render Base App Module",
.m_size = -1,
.m_methods = gds_render_methods,
NULL, NULL, NULL, NULL
};
static int gds_render_module_check_types_ready()
{
if (!PyType_Ready(&GListType))
return -1;
return 0;
}
static int gds_render_module_add_types(PyObject *module)
{
int err;
Py_INCREF(&GListType);
err = PyModule_AddObject(module, "GdsPoint", (PyObject *)&GListType);
if (err < 0) {
goto decref_glist;
}
return 0;
decref_glist:
Py_DECREF(&GListType);
return -1;
}
PyObject *init_gds_render_module(void)
{
int err;
PyObject *gds_render_module;
if (gds_render_module_check_types_ready())
return NULL;
gds_render_module = PyModule_Create(&gds_render_module_def);
err = gds_render_module_add_types(gds_render_module);
if (err) {
Py_DECREF(gds_render_module);
gds_render_module = NULL;
goto return_module;
}
return_module:
return gds_render_module;
}

View File

@ -0,0 +1,72 @@
/*
* GDSII-Converter Python Plugin
* Copyright (C) 2020 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/glist.c
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @defgroup python-plugin-glist GList wrapper for python
* @ingroup python-plugin
* This is a wrapping class for GLists
* This wrpper acts as a read only access to the lists
*
* @addtogroup python-plugin-glist
* @{
*/
#include <python-renderer/glist.h>
struct _GListObject {
PyObject_HEAD
GList *head;
size_t len;
};
static PyObject *glist_to_list(GListObject *self, PyObject *Py_UNUSED(ignored))
{
return Py_BuildValue("");
}
static PyMethodDef glist_methods[] = {
{"tolist", (PyCFunction)glist_to_list, METH_NOARGS, "Convert GList to editable list"}
};
void glist_set_head_ptr(GListObject *self, GList *head)
{
if (!self || !head)
return;
self->head = head;
self->len = g_list_length(self->head);
}
PyTypeObject GListType = {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "gds_render.GList",
.tp_doc = "Read only GList",
.tp_basicsize = sizeof(GListObject),
.tp_itemsize = 0,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_new = PyType_GenericNew,
.tp_methods = glist_methods
};
/** @} */

View File

@ -0,0 +1,173 @@
/*
* 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/plugin-main.c
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @defgroup python-plugin Python Plugin for External Renderer
* @ingroup plugins
* This is a plugin for calling an external python script as renderer
* @addtogroup python-plugin
* @{
*/
#include <stdio.h>
#include <libgen.h>
#include <glib.h>
#include <unistd.h>
#include <Python.h>
#include <gds-render/gds-utils/gds-types.h>
#include <gds-render/output-renderers/external-renderer-interfaces.h>
#include <python-renderer/gds-render-module.h>
/**
* @brief Global variable for loaded module. This is not very nice.
* @warning This has to be changed, if this api wants to be re-entrant.
*/
static PyObject *p_module = NULL;
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;
PyObject *p_return_value;
if (!toplevel)
return -1000;
if (!p_module)
return -2000;
printf("Rendering %s\n", toplevel->name);
p_render_func = PyObject_GetAttrString(p_module, "test_func");
if (!p_render_func && !PyCallable_Check(p_render_func)) {
if (PyErr_Occurred())
PyErr_Print();
else
fprintf(stderr, "Function not found in python module\n");
ret = -1;
goto return_value;
}
p_return_value = PyObject_CallObject(p_render_func, NULL);
if (p_return_value) {
printf("Result of call: %ld\n", PyLong_AsLong(p_return_value));
Py_DECREF(p_return_value);
}
Py_XDECREF(p_render_func);
return_value:
return ret;
}
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const char *version)
{
int ret = 0;
PyObject *p_name;
PyObject *p_sys_path;
PyObject *p_mod_dir_string;
PyObject *gds_render_module;
char file_path[PATH_MAX];
char *file_path_for_dir;
char *file_path_for_base;
char *dir_name;
char *base_name;
if (!params || !version)
return -1000;
printf("Init with params: %s\ngds-render version: %s\n", params, version);
ret = PyImport_AppendInittab("gds_render", &init_gds_render_module);
if (ret) {
ret = -1;
fprintf(stderr, "Registration of gds_render python module failed\n");
goto return_value;
}
Py_Initialize();
if (!realpath(params, file_path)) {
ret = -2;
fprintf(stderr, "Invalid file name.\n");
goto return_value;
}
file_path_for_dir = strdup(file_path);
if (!file_path_for_dir) {
ret = -3;
goto return_value;
}
file_path_for_base = strdup(file_path);
if (!file_path_for_base) {
ret = -3;
free (file_path_for_dir);
goto return_value;
}
dir_name = dirname(file_path_for_dir);
base_name = basename(file_path_for_base);
printf("Dir name : %s\n BAse name: %s\n", dir_name, base_name);
p_sys_path = PySys_GetObject("path");
p_mod_dir_string = PyUnicode_FromString(dir_name);
PyList_Append(p_sys_path, p_mod_dir_string);
Py_DECREF(p_mod_dir_string);
p_name = PyUnicode_DecodeFSDefault(strtok(base_name, "."));
p_module = PyImport_Import(p_name);
Py_DECREF(p_name);
if (!p_module) {
PyErr_Print();
fprintf(stderr, "Failed to load %s\n", params);
ret = -1;
goto return_value;
}
free(file_path_for_dir);
free(file_path_for_base);
return_value:
return ret;
}
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
{
int ret;
printf("Finalizing\n");
if (p_module)
Py_DECREF(p_module);
ret = Py_FinalizeEx();
return ret;
}
/** @} */

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/*

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/**

View File

@ -14,7 +14,7 @@
* 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/>.
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/
/*