meson: use gnome.mkenums_simple() to generate enumtypes files

Means we no longer need our custom scripts, nor template files.
This commit is contained in:
Alessandro Decina 2017-07-20 17:47:55 +10:00 committed by Tim-Philipp Müller
parent 00727d2437
commit f49134095c
8 changed files with 21 additions and 211 deletions

View 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

View 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],

View file

@ -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)

View file

@ -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)

View 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,

View 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,

View file

@ -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)

View 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' ])