From f49134095cf87008f8230201f4da85c53e5f75dd Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Thu, 20 Jul 2017 17:47:55 +1000 Subject: [PATCH] meson: use gnome.mkenums_simple() to generate enumtypes files Means we no longer need our custom scripts, nor template files. --- Makefile.am | 3 -- ext/srtp/meson.build | 17 +++----- ext/srtp/srtp_mkenum.py | 55 ------------------------ gst-libs/gst/interfaces/build_mkenum.py | 55 ------------------------ gst-libs/gst/interfaces/meson.build | 21 ++++----- gst-libs/gst/mpegts/meson.build | 22 +++------- gst-libs/gst/mpegts/mpegts_enum.py | 57 ------------------------- meson.build | 2 +- 8 files changed, 21 insertions(+), 211 deletions(-) delete mode 100755 ext/srtp/srtp_mkenum.py delete mode 100755 gst-libs/gst/interfaces/build_mkenum.py delete mode 100755 gst-libs/gst/mpegts/mpegts_enum.py diff --git a/Makefile.am b/Makefile.am index 0783edf780..8e33980f4a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/ext/srtp/meson.build b/ext/srtp/meson.build index 844faae6fd..830c2cf86a 100644 --- a/ext/srtp/meson.build +++ b/ext/srtp/meson.build @@ -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 index 402e946272..0000000000 --- a/ext/srtp/srtp_mkenum.py +++ /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 \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 index a7883928ed..0000000000 --- a/gst-libs/gst/interfaces/build_mkenum.py +++ /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 \n#include \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) diff --git a/gst-libs/gst/interfaces/meson.build b/gst-libs/gst/interfaces/meson.build index 35290f7319..0ff83fea94 100644 --- a/gst-libs/gst/interfaces/meson.build +++ b/gst-libs/gst/interfaces/meson.build @@ -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 ', + 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, diff --git a/gst-libs/gst/mpegts/meson.build b/gst-libs/gst/mpegts/meson.build index 2ee4209262..e1638bbebc 100644 --- a/gst-libs/gst/mpegts/meson.build +++ b/gst-libs/gst/mpegts/meson.build @@ -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 ', + 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 index 320bb88720..0000000000 --- a/gst-libs/gst/mpegts/mpegts_enum.py +++ /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 \n#include \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) diff --git a/meson.build b/meson.build index e84f73d74e..dec37d0db7 100644 --- a/meson.build +++ b/meson.build @@ -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' ])