Commit 1f50456d authored by Jehan's avatar Jehan
Browse files

operations: gegl:introspect to use the new is_available() class method.

"gegl:introspect" depends on the external "dot" tool availability. If
absent, we should hide the operation.

We still search for `dot` on the main configure step, but now only for
informative purpose (and outputting the result on the configuration
summary). It does not block anymore the build and the operation is
always built, whether or not dot is found at configure time.
parent 7c8c298c
Pipeline #238799 passed with stages
in 6 minutes and 35 seconds
......@@ -136,7 +136,7 @@ add_project_arguments(cpp.get_supported_arguments(cflags_cpp), language: 'cpp')
# Utilities
bash = find_program('bash')
dot = os_win32 ? find_program('dot.exe') : find_program('dot')
dot = os_win32 ? find_program('dot.exe', required: false) : find_program('dot', required: false)
perl = find_program('perl5', 'perl', required: false)
asciidoc = find_program('asciidoc', required: false)
......@@ -378,6 +378,7 @@ message('\n'.join(['',
'',
'Optional dependencies:',
' asciidoc: @0@'.format(asciidoc.found()),
' dot: @0@'.format(dot.found()),
' enscript: @0@'.format(enscript.found()),
' mrg: @0@'.format(mrg.found()),
' Ruby: @0@'.format(ruby.found()),
......
......@@ -43,9 +43,12 @@ gegl_introspect_load_cache (GeglProperties *op_introspect)
gchar *png_filename = NULL;
gchar *dot_filename = NULL;
gchar *dot_cmd = NULL;
gchar *dot;
gint fd;
if (op_introspect->user_data || op_introspect->node == NULL)
dot = g_find_program_in_path ("dot");
if (! dot || op_introspect->user_data || op_introspect->node == NULL)
return;
/* Construct temp filenames */
......@@ -67,7 +70,7 @@ gegl_introspect_load_cache (GeglProperties *op_introspect)
close (fd);
/* Process the .dot to a .png */
dot_cmd = g_strdup_printf ("%s -o %s -Tpng %s", DOT, png_filename, dot_filename);
dot_cmd = g_strdup_printf ("%s -o %s -Tpng %s", dot, png_filename, dot_filename);
if (system (dot_cmd) != 0)
{
g_warning ("Error executing GraphViz dot program");
......@@ -103,6 +106,7 @@ gegl_introspect_load_cache (GeglProperties *op_introspect)
unlink (png_filename);
/* Cleanup */
g_free (dot);
g_free (dot_string);
g_free (dot_cmd);
g_free (dot_filename);
......@@ -167,6 +171,19 @@ gegl_introspect_process (GeglOperation *operation,
return TRUE;
}
static gboolean
gegl_introspect_is_available (void)
{
gchar *dot;
gboolean found = FALSE;
dot = g_find_program_in_path ("dot");
found = (dot != NULL);
g_free (dot);
return found;
}
static void
gegl_op_class_init (GeglOpClass *klass)
{
......@@ -180,6 +197,7 @@ gegl_op_class_init (GeglOpClass *klass)
operation_class->process = gegl_introspect_process;
operation_class->get_bounding_box = gegl_introspect_get_bounding_box;
operation_class->is_available = gegl_introspect_is_available;
gegl_operation_class_set_keys (operation_class,
"name" , "gegl:introspect",
......
......@@ -140,7 +140,7 @@ gegl_common = shared_library('gegl-common',
gegl_lib,
],
c_args: [
'-DGEGL_OP_BUNDLE', '-DDOT="' + (os_win32 ? 'dot.exe' : dot.path()) + '"'
'-DGEGL_OP_BUNDLE',
],
name_prefix: '',
install: true,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment