meson: use gnome.mkenums_simple() to generate enumtypes files
authorAlessandro Decina <alessandro.d@gmail.com>
Thu, 20 Jul 2017 07:47:55 +0000 (17:47 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 22 Mar 2018 14:34:05 +0000 (14:34 +0000)
Means we no longer need our custom scripts, nor template files.

Makefile.am
ext/srtp/meson.build
ext/srtp/srtp_mkenum.py [deleted file]
gst-libs/gst/interfaces/build_mkenum.py [deleted file]
gst-libs/gst/interfaces/meson.build
gst-libs/gst/mpegts/meson.build
gst-libs/gst/mpegts/mpegts_enum.py [deleted file]
meson.build

index 0783edf..8e33980 100644 (file)
@@ -14,10 +14,7 @@ EXTRA_DIST = \
        ChangeLog gst-plugins-bad.doap autogen.sh \
        $(shell find "$(top_srcdir)" -type f -name meson.build ! -path "$(top_srcdir)/$(PACKAGE_TARNAME)-*" ) \
        meson_options.txt \
-       gst-libs/gst/interfaces/build_mkenum.py \
-       gst-libs/gst/mpegts/mpegts_enum.py \
        gst-libs/gst/webrtc/webrtc_mkenum.py \
-       ext/srtp/srtp_mkenum.py \
        ext/vulkan/vkconfig.h.meson
 
 DISTCLEANFILES = _stdint.h
index 844faae..830c2cf 100644 (file)
@@ -17,20 +17,13 @@ else
 endif
 
 if srtp_dep.found()
-  mkenums = find_program('srtp_mkenum.py')
-  gstsrtp_h = custom_target('gstsrtpenum_h',
-    output : 'gstsrtp-enumtypes.h',
-    input : 'gstsrtpenums.h',
-    command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
-
-  gstsrtp_c = custom_target('gstsrtpenum_c',
-    output : 'gstsrtp-enumtypes.c',
-    input : 'gstsrtpenums.h',
-    depends : [gstsrtp_h],
-    command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
+  gstsrtp_enums = gnome.mkenums_simple('gstsrtp-enumtypes',
+    sources : ['gstsrtpenums.h'],
+    decorator : 'G_GNUC_INTERNAL',
+    install_header: false)
 
   gstsrtp = library('gstsrtp',
-    srtp_sources, gstsrtp_c, gstsrtp_h,
+    srtp_sources, gstsrtp_enums,
     c_args : gst_plugins_bad_args + srtp_cargs,
     link_args : noseh_link_args,
     include_directories : [configinc],
diff --git a/ext/srtp/srtp_mkenum.py b/ext/srtp/srtp_mkenum.py
deleted file mode 100755 (executable)
index 402e946..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python3
-
-# This is in its own file rather than inside meson.build
-# because a) mixing the two is ugly and b) trying to
-# make special characters such as \n go through all
-# backends is a fool's errand.
-
-import sys, os, shutil, subprocess
-
-h_array = ['--fhead',
-           "#ifndef __GST_SRTP_ENUM_TYPES_H__\n#define __GST_SRTP_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n",
-           '--fprod',
-           "\n/* enumerations from \"@filename@\" */\n",
-           '--vhead',
-           'GType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n',
-           '--ftail',
-           'G_END_DECLS\n\n#endif /* __GST_SRTP_ENUM_TYPES_H__ */',
-           ]
-
-c_array = ['--fhead',
-           "#include \"gstsrtp-enumtypes.h\"\n\n#include \"gstsrtpenums.h\"",
-           '--fprod',
-           "\n/* enumerations from \"@filename@\" */",
-           '--vhead',
-           "GType\n@enum_name@_get_type (void)\n{\n  static volatile gsize g_define_type_id__volatile = 0;\n  if (g_once_init_enter (&g_define_type_id__volatile)) {\n    static const G@Type@Value values[] = {",
-           '--vprod',
-           "      { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" },",
-           '--vtail',
-           "      { 0, NULL, NULL }\n    };\n    GType g_define_type_id = g_@type@_register_static (\"@EnumName@\", values);\n    g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n  }\n  return g_define_type_id__volatile;\n}\n",
-           ]
-
-cmd = []
-argn = 1
-# Find the full command needed to run glib-mkenums
-# On UNIX-like, this is just the full path to glib-mkenums
-# On Windows, this is the full path to interpreter + full path to glib-mkenums
-for arg in sys.argv[1:]:
-    cmd.append(arg)
-    argn += 1
-    if arg.endswith('glib-mkenums'):
-        break
-ofilename = sys.argv[argn]
-headers = sys.argv[argn + 1:]
-
-if ofilename.endswith('.h'):
-    arg_array = h_array
-else:
-    arg_array = c_array
-
-cmd_array = cmd + arg_array + headers
-pc = subprocess.Popen(cmd_array, stdout=subprocess.PIPE)
-(stdo, _) = pc.communicate()
-if pc.returncode != 0:
-    sys.exit(pc.returncode)
-open(ofilename, 'wb').write(stdo)
diff --git a/gst-libs/gst/interfaces/build_mkenum.py b/gst-libs/gst/interfaces/build_mkenum.py
deleted file mode 100755 (executable)
index a788392..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python3
-
-# This is in its own file rather than inside meson.build
-# because a) mixing the two is ugly and b) trying to
-# make special characters such as \n go through all
-# backends is a fool's errand.
-
-import sys, os, shutil, subprocess
-
-h_array = ['--fhead',
-           "#ifndef __GST_PHOTO_ENUM_TYPES_H__\n#define __GST_PHOTO_ENUM_TYPES_H__\n\n#include <gst/gst.h>\n#include <gst/interfaces/photography-prelude.h>\nG_BEGIN_DECLS\n",
-           '--fprod',
-           "\n/* enumerations from \"@filename@\" */\n",
-           '--vhead',
-           "GST_PHOTOGRAPHY_API GType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n",
-           '--ftail',
-           "G_END_DECLS\n\n#endif /* __GST_PHOTO_ENUM_TYPES_H__ */"]
-
-c_array = [
-    '--fhead',
-    "#include \"photography-enumtypes.h\"\n#include\"photography.h\"\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)\n",
-    '--fprod',
-    "\n/* enumerations from \"@filename@\" */",
-    '--vhead',
-    "GType\n@enum_name@_get_type (void)\n{\n  static gsize id = 0;\n  static const G@Type@Value values[] = {",
-    '--vprod',
-    "    { C_@TYPE@(@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" },",
-    '--vtail',
-    "    { 0, NULL, NULL }\n  };\n\n  if (g_once_init_enter (&id)) {\n    GType tmp = g_@type@_register_static (\"@EnumName@\", values);\n    g_once_init_leave (&id, tmp);\n  }\n\n  return (GType) id;\n}"
-    ]
-
-cmd = []
-argn = 1
-# Find the full command needed to run glib-mkenums
-# On UNIX-like, this is just the full path to glib-mkenums
-# On Windows, this is the full path to interpreter + full path to glib-mkenums
-for arg in sys.argv[1:]:
-    cmd.append(arg)
-    argn += 1
-    if arg.endswith('glib-mkenums'):
-        break
-ofilename = sys.argv[argn]
-headers = sys.argv[argn + 1:]
-
-if ofilename.endswith('.h'):
-    arg_array = h_array
-else:
-    arg_array = c_array
-
-cmd_array = cmd + arg_array + headers
-pc = subprocess.Popen(cmd_array, stdout=subprocess.PIPE)
-(stdo, _) = pc.communicate()
-if pc.returncode != 0:
-    sys.exit(pc.returncode)
-open(ofilename, 'wb').write(stdo)
index 35290f7..0ff83fe 100644 (file)
@@ -2,19 +2,14 @@ photography_sources = ['photography.c']
 photo_headers = ['photography.h', 'photography-prelude.h']
 install_headers(photo_headers, subdir : 'gstreamer-1.0/gst/interfaces')
 
-mkenums = find_program('build_mkenum.py')
-
-photoenum_h = custom_target('photoenum_h',
-  output : 'photography-enumtypes.h',
-  input : photo_headers,
-  install : true,
-  install_dir : 'include/gstreamer-1.0/gst/interfaces',
-  command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
-
-photoenum_c = custom_target('photoenum_c',
-  output : 'photography-enumtypes.c',
-  input : photo_headers,
-  command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
+photo_enums = gnome.mkenums_simple('photography-enumtypes',
+  sources : photo_headers,
+  header_prefix : '#include <gst/interfaces/photography-prelude.h>',
+  decorator: 'GST_PHOTOGRAPHY_API',
+  install_header: true,
+  install_dir : 'include/gstreamer-1.0/gst/interfaces/')
+photoenum_c = photo_enums[0]
+photoenum_h = photo_enums[1]
 
 gstphotography = library('gstphotography-' + api_version,
   photography_sources, photoenum_h, photoenum_c,
index 2ee4209..e1638bb 100644 (file)
@@ -18,23 +18,15 @@ mpegts_headers = [
 ]
 install_headers(mpegts_headers, subdir : 'gstreamer-1.0/gst/mpegts')
 
-mkenums = find_program('mpegts_enum.py')
-
-mpegts_h = custom_target('mpegtsenum_h',
-  output : 'gstmpegts-enumtypes.h',
-  input : mpegts_headers,
-  install : true,
-  install_dir : 'include/gstreamer-1.0/gst/mpegts',
-  command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
-gen_sources = [mpegts_h]
-
-mpegts_c = custom_target('mpegtsenum_c',
-  output : 'gstmpegts-enumtypes.c',
-  input : mpegts_headers,
-  command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
+mpegts_enums = gnome.mkenums_simple('gstmpegts-enumtypes',
+  sources : mpegts_headers,
+  header_prefix : '#include <gst/mpegts/mpegts-prelude.h>',
+  decorator : 'GST_MPEGTS_API',
+  install_header: true,
+  install_dir : 'include/gstreamer-1.0/gst/mpegts/')
 
 gstmpegts = library('gstmpegts-' + api_version,
-  mpegts_sources, mpegts_h, mpegts_c,
+  mpegts_sources, mpegts_enums,
   c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API'],
   include_directories : [configinc, libsinc],
   version : libversion,
diff --git a/gst-libs/gst/mpegts/mpegts_enum.py b/gst-libs/gst/mpegts/mpegts_enum.py
deleted file mode 100755 (executable)
index 320bb88..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env python3
-
-# This is in its own file rather than inside meson.build
-# because a) mixing the two is ugly and b) trying to
-# make special characters such as \n go through all
-# backends is a fool's errand.
-
-import sys, os, subprocess
-
-cmd = []
-argn = 1
-# Find the full command needed to run glib-mkenums
-# On UNIX-like, this is just the full path to glib-mkenums
-# On Windows, this is the full path to interpreter + full path to glib-mkenums
-for arg in sys.argv[1:]:
-    cmd.append(arg)
-    argn += 1
-    if arg.endswith('glib-mkenums'):
-        break
-ofilename = sys.argv[argn]
-headers = sys.argv[argn + 1:]
-
-inc = '\n'.join(['#include"%s"' % os.path.basename(i) for i in headers])
-
-h_array = ['--fhead',
-           "#ifndef __GST_MPEGTS_ENUM_TYPES_H__\n#define __GST_MPEGTS_ENUM_TYPES_H__\n\n#include <gst/gst.h>\n#include <gst/mpegts/mpegts-prelude.h>\nG_BEGIN_DECLS\n",
-           '--fprod',
-           "\n/* enumerations from \"@filename@\" */\n",
-           '--vhead',
-           "GST_MPEGTS_API GType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n",
-           '--ftail',
-           "G_END_DECLS\n\n#endif /* __GST_MPEGTS_ENUM_TYPES_H__ */"]
-
-c_array = [
-    '--fhead',
-    "#include \"gstmpegts-enumtypes.h\"\n%s\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)\n" % inc,
-    '--fprod',
-    "\n/* enumerations from \"@filename@\" */",
-    '--vhead',
-    "GType\n@enum_name@_get_type (void)\n{\n  static gsize id = 0;\n  static const G@Type@Value values[] = {",
-    '--vprod',
-    "    { C_@TYPE@(@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" },",
-    '--vtail',
-    "    { 0, NULL, NULL }\n  };\n\n  if (g_once_init_enter (&id)) {\n    GType tmp = g_@type@_register_static (\"@EnumName@\", values);\n    g_once_init_leave (&id, tmp);\n  }\n\n  return (GType) id;\n}"
-    ]
-
-if ofilename.endswith('.h'):
-    arg_array = h_array
-else:
-    arg_array = c_array
-
-cmd_array = cmd + arg_array + headers
-pc = subprocess.Popen(cmd_array, stdout=subprocess.PIPE)
-(stdo, _) = pc.communicate()
-if pc.returncode != 0:
-    sys.exit(pc.returncode)
-open(ofilename, 'wb').write(stdo)
index e84f73d..dec37d0 100644 (file)
@@ -1,6 +1,6 @@
 project('gst-plugins-bad', 'c', 'cpp',
   version : '1.15.0.1',
-  meson_version : '>= 0.40.1',
+  meson_version : '>= 0.42',
   default_options : [ 'warning_level=1',
                       'buildtype=debugoptimized' ])