[gimp/meson: 51/128] De-duplicate code for calling gimp_mkenums.



commit 9a4196f647ef9dc4141aeca9e676e6c3ff08b48c
Author: Félix Piédallu <felix piedallu me>
Date:   Sat Dec 30 16:00:05 2017 +0100

    De-duplicate code for calling gimp_mkenums.

 app/config/meson.build     |   36 +-------------------
 app/core/meson.build       |   36 +-------------------
 app/display/meson.build    |   36 +-------------------
 app/gegl/meson.build       |   37 +--------------------
 app/meson.build            |   11 ++++++
 app/operations/meson.build |   37 +--------------------
 app/paint/meson.build      |   37 +--------------------
 app/plug-in/meson.build    |   37 +--------------------
 app/text/meson.build       |   37 +--------------------
 app/tools/meson.build      |   37 +--------------------
 app/widgets/meson.build    |   37 +--------------------
 libgimp/meson.build        |   43 ++++-------------------
 libgimpbase/meson.build    |   78 +++++++-------------------------------------
 libgimpconfig/meson.build  |   39 +++------------------
 libgimpwidgets/meson.build |   39 +++------------------
 meson.build                |   32 +++++++++++++++++-
 16 files changed, 84 insertions(+), 525 deletions(-)
---
diff --git a/app/config/meson.build b/app/config/meson.build
index 70c0acd..7b99780 100644
--- a/app/config/meson.build
+++ b/app/config/meson.build
@@ -2,41 +2,7 @@
 appconfigenums = custom_target('config-enums.c',
   input : [ 'config-enums.h', ],
   output: [ 'config-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "config-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/core/meson.build b/app/core/meson.build
index 39718fb..3b91567 100644
--- a/app/core/meson.build
+++ b/app/core/meson.build
@@ -2,41 +2,7 @@
 appcoreenums = custom_target('core-enums',
   input : [ 'core-enums.h', ],
   output: [ 'core-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core-enums.h"\n'+
-              '#include "gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/display/meson.build b/app/display/meson.build
index c7542d8..3941063 100644
--- a/app/display/meson.build
+++ b/app/display/meson.build
@@ -2,41 +2,7 @@
 appdisplayenums = custom_target('display-enums.c',
   input : [ 'display-enums.h', ],
   output: [ 'display-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "display-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/gegl/meson.build b/app/gegl/meson.build
index 6017dae..a7a99fb 100644
--- a/app/gegl/meson.build
+++ b/app/gegl/meson.build
@@ -2,42 +2,7 @@
 appgeglenums = custom_target('gimp-gegl-enums.c',
   input : [ 'gimp-gegl-enums.h', ],
   output: [ 'gimp-gegl-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core/core-enums.h"\n'+
-              '#include "gimp-gegl-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/meson.build b/app/meson.build
index 2d9ba7a..1a4bd26 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -22,6 +22,17 @@ gitversion_h = vcs_tag(
   fallback: '',
 )
 
+app_mkenums_custom_target_command = [
+  gimp_mkenums,
+  '--fhead','#include "config.h"\n'
+          + '#include <gio/gio.h>\n'
+          + '#include "libgimpbase/gimpbase.h"\n'
+          + '#include "core/core-enums.h"\n'
+          + '#include "@INPUT@"\n'
+          + '#include "gimp-intl.h"\n',
+  gimp_mkenums_custom_target_commonargs,
+]
+
 subdir('actions')
 subdir('core')
 subdir('dialogs')
diff --git a/app/operations/meson.build b/app/operations/meson.build
index 6412a93..ed6869d 100644
--- a/app/operations/meson.build
+++ b/app/operations/meson.build
@@ -2,42 +2,7 @@
 appoperationsenums = custom_target('operations-enums.c',
   input : [ 'operations-enums.h', ],
   output: [ 'operations-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core/core-enums.h"\n'+
-              '#include "operations-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/paint/meson.build b/app/paint/meson.build
index 121e7e4..1da759a 100644
--- a/app/paint/meson.build
+++ b/app/paint/meson.build
@@ -2,42 +2,7 @@
 apppaintenums = custom_target('paint-enums.c',
   input : [ 'paint-enums.h', ],
   output: [ 'paint-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core/core-enums.h"\n'+
-              '#include "paint-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/plug-in/meson.build b/app/plug-in/meson.build
index f272af9..14686cc 100644
--- a/app/plug-in/meson.build
+++ b/app/plug-in/meson.build
@@ -2,42 +2,7 @@
 apppluginenums = custom_target('plug-in-enums.c',
   input : [ 'plug-in-enums.h', ],
   output: [ 'plug-in-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core/core-enums.h"\n'+
-              '#include "plug-in-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/text/meson.build b/app/text/meson.build
index 7115413..48b71c3 100644
--- a/app/text/meson.build
+++ b/app/text/meson.build
@@ -2,42 +2,7 @@
 apptextenums = custom_target('text-enums.c',
   input : [ 'text-enums.h', ],
   output: [ 'text-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core/core-enums.h"\n'+
-              '#include "text-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/tools/meson.build b/app/tools/meson.build
index 33dd3d5..de7bb7e 100644
--- a/app/tools/meson.build
+++ b/app/tools/meson.build
@@ -2,42 +2,7 @@
 apptoolsenums = custom_target('tools-enums.c',
   input : [ 'tools-enums.h', ],
   output: [ 'tools-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core/core-enums.h"\n'+
-              '#include "tools-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/app/widgets/meson.build b/app/widgets/meson.build
index 9400423..908c056 100644
--- a/app/widgets/meson.build
+++ b/app/widgets/meson.build
@@ -2,42 +2,7 @@
 appwidgetsenums = custom_target('widgets-enums.c',
   input : [ 'widgets-enums.h', ],
   output: [ 'widgets-enums.c', ],
-  command: [
-    gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "core/core-enums.h"\n'+
-              '#include "widgets-enums.h"\n'+
-              '#include"gimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
-  ],
+  command: app_mkenums_custom_target_command,
   capture: true,
 )
 
diff --git a/libgimp/meson.build b/libgimp/meson.build
index 86d9089..9555544 100644
--- a/libgimp/meson.build
+++ b/libgimp/meson.build
@@ -4,41 +4,14 @@ gimpenums_notail = custom_target('gimpenums.c.notail',
   output: [ 'gimpenums.c.notail', ],
   command: [
     gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#undef GIMP_DISABLE_DEPRECATED\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "libgimpbase/gimpbase-private.h"\n'+
-              '#include "libgimpconfig/gimpconfigenums.h"\n'+
-              '#include "gimpenums.h"\n',
-    '--fprod','/* enumerations from "@filename@" */',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
+    '--fhead','#include "config.h"\n'
+            + '#include <gio/gio.h>\n'
+            + '#undef GIMP_DISABLE_DEPRECATED\n'
+            + '#include "libgimpbase/gimpbase.h"\n'
+            + '#include "libgimpbase/gimpbase-private.h"\n'
+            + '#include "libgimpconfig/gimpconfigenums.h"\n'
+            + '#include "gimpenums.h"\n',
+    gimp_mkenums_custom_target_commonargs,
   ],
   capture: true,
 )
diff --git a/libgimpbase/meson.build b/libgimpbase/meson.build
index ee47106..d0e384c 100644
--- a/libgimpbase/meson.build
+++ b/libgimpbase/meson.build
@@ -17,39 +17,12 @@ gimpbaseenums = custom_target('gimpbaseenums.c',
   output: [ 'gimpbaseenums.c', ],
   command: [
     gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <glib-object.h>\n'+
-              '#undef GIMP_DISABLE_DEPRECATED\n'+
-              '#include "gimpbasetypes.h"\n'+
-              '#include "libgimp/libgimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
+    '--fhead','#include "config.h"\n'
+            + '#include <glib-object.h>\n'
+            + '#undef GIMP_DISABLE_DEPRECATED\n'
+            + '#include "gimpbasetypes.h"\n'
+            + '#include "libgimp/libgimp-intl.h"\n',
+    gimp_mkenums_custom_target_commonargs,
   ],
   capture: true,
 )
@@ -58,39 +31,12 @@ gimpcompatenums = custom_target('gimpcompatenums.c',
   output: [ 'gimpcompatenums.c', ],
   command: [
     gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <glib-object.h>\n'+
-              '#include "gimpbasetypes.h"\n'+
-              '#include "gimpcompatenums.h"\n'+
-              '#include "libgimp/libgimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
+    '--fhead','#include "config.h"\n'
+            + '#include <glib-object.h>\n'
+            + '#include "gimpbasetypes.h"\n'
+            + '#include "@INPUT@"\n'
+            + '#include "libgimp/libgimp-intl.h"\n',
+    gimp_mkenums_custom_target_commonargs,
   ],
   capture: true,
 )
diff --git a/libgimpconfig/meson.build b/libgimpconfig/meson.build
index c9fbb55..c3d9306 100644
--- a/libgimpconfig/meson.build
+++ b/libgimpconfig/meson.build
@@ -4,39 +4,12 @@ gimpconfigenums = custom_target('gimpconfigenums.c',
   output: [ 'gimpconfigenums.c', ],
   command: [
     gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "gimpconfigenums.h"\n'+
-              '#include "libgimp/libgimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
+    '--fhead','#include "config.h"\n'
+            + '#include <gio/gio.h>\n'
+            + '#include "libgimpbase/gimpbase.h"\n'
+            + '#include "@INPUT@"\n'
+            + '#include "libgimp/libgimp-intl.h"\n',
+    gimp_mkenums_custom_target_commonargs,
   ],
   capture: true,
 )
diff --git a/libgimpwidgets/meson.build b/libgimpwidgets/meson.build
index 9b554d2..1ee1d2f 100644
--- a/libgimpwidgets/meson.build
+++ b/libgimpwidgets/meson.build
@@ -4,39 +4,12 @@ gimpwidgetsenums = custom_target('gimpwidgetsenums.c',
   output: [ 'gimpwidgetsenums.c', ],
   command: [
     gimp_mkenums,
-    '--fhead','#include "config.h"\n'+
-              '#include <gio/gio.h>\n'+
-              '#include "libgimpbase/gimpbase.h"\n'+
-              '#include "gimpwidgetsenums.h"\n'+
-              '#include "libgimp/libgimp-intl.h"\n',
-    '--fprod','/* enumerations from "@basename@" */\n',
-    '--vhead','GType\n'+
-              '@enum_name@_get_type (void)\n'+
-              '{\n'+
-              '  static const G@Type@Value values[] =\n'+
-              '  {',
-    '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
-    '--vtail','    { 0, NULL, NULL }\n'+
-              '  };\n',
-    '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
-              '  {',
-    '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
-    '--dtail','    { 0, NULL, NULL }\n'+
-              '  };\n'+
-              '\n'+
-              '  static GType type = 0;\n'+
-              '\n'+
-              '  if (G_UNLIKELY (! type))\n'+
-              '    {\n'+
-              '      type = g_@type@_register_static ("@EnumName@", values);\n'+
-              '      gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");\n'+
-              '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
-              '      gimp_@type@_set_value_descriptions (type, descs);\n'+
-              '    }\n'+
-              '\n'+
-              '  return type;\n'+
-              '}\n',
-    '@INPUT@',
+    '--fhead','#include "config.h"\n'
+            + '#include <gio/gio.h>\n'
+            + '#include "libgimpbase/gimpbase.h"\n'
+            + '#include "@INPUT@"\n'
+            + '#include "libgimp/libgimp-intl.h"\n',
+    gimp_mkenums_custom_target_commonargs,
   ],
   capture: true,
 )
diff --git a/meson.build b/meson.build
index 8cccaf6..40912d7 100644
--- a/meson.build
+++ b/meson.build
@@ -689,10 +689,40 @@ defcheck            = find_program(join_paths('tools', 'defcheck.py'))
 extract_vector_icon = find_program(join_paths('tools', 'extract-vector-icon.sh'))
 generate_changelog  = find_program(join_paths('tools', 'generate_changelog.sh'))
 generate_news       = find_program(join_paths('tools', 'generate-news'))
-gimp_mkenums        = find_program(join_paths('tools', 'gimp-mkenums'))
 gimppath2svg        = find_program(join_paths('tools', 'gimppath2svg.py'))
 module_dependencies = find_program(join_paths('tools', 'module-dependencies.py'))
 
+gimp_mkenums        = find_program(join_paths('tools', 'gimp-mkenums'))
+gimp_mkenums_custom_target_commonargs = [
+  '--fprod','/* enumerations from "@basename@" */\n',
+  '--vhead','GType\n'+
+            '@enum_name@_get_type (void)\n'+
+            '{\n'+
+            '  static const G@Type@Value values[] =\n'+
+            '  {',
+  '--vprod','    { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
+  '--vtail','    { 0, NULL, NULL }\n'+
+            '  };\n',
+  '--dhead','  static const Gimp@Type@Desc descs[] =\n'+
+            '  {',
+  '--dprod','    { @VALUENAME@, @valuedesc@, @valuehelp@ },',
+  '--dtail','    { 0, NULL, NULL }\n'+
+            '  };\n'+
+            '\n'+
+            '  static GType type = 0;\n'+
+            '\n'+
+            '  if (G_UNLIKELY (! type))\n'+
+            '    {\n'+
+            '      type = g_@type@_register_static ("@EnumName@", values);\n'+
+            '      gimp_type_set_translation_context (type, "@enumnick@");\n'+
+            '      gimp_@type@_set_value_descriptions (type, descs);\n'+
+            '    }\n'+
+            '\n'+
+            '  return type;\n'+
+            '}\n',
+  '@INPUT@',
+]
+
 
 ################################################################################
 # Localisation


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]