Skip to content

Commit

Permalink
gl/build: build with implicit_include_directories : false
Browse files Browse the repository at this point in the history
Fixes case-insensitive file systems confusing gst-libs/gst/gl/egl/egl.h
with EGL/egl.h when the source directory gst-libs/gst/gl is automatically
added to the compiler's search path.

Due to mesonbuild/meson#7582 we also need to
perform manual enumtype generation.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/814
  • Loading branch information
ystreet authored and tp-m committed Aug 27, 2020
1 parent 8cacd54 commit 1cc18ec
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 10 deletions.
55 changes: 55 additions & 0 deletions gst-libs/gst/gl/gl_mkenum.py
@@ -0,0 +1,55 @@
#!/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, subprocess

h_array = ['--fhead',
"#pragma once\n\n#include <gst/gst.h>\n#include <gst/gl/gstgl_fwd.h>\nG_BEGIN_DECLS\n",
'--fprod',
"\n/* enumerations from \"@basename@\" */\n",
'--vhead',
"GST_GL_API\nGType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n",
'--ftail',
"G_END_DECLS"
]

c_array = ['--fhead',
"#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n#include \"gl-enumtypes.h\"\n\n#include <gst/gl/gl.h>\n\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)",
'--fprod',
"\n/* enumerations from \"@basename@\" */",
'--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',
" { C_@TYPE@ (@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)
27 changes: 17 additions & 10 deletions gst-libs/gst/gl/meson.build
Expand Up @@ -973,15 +973,20 @@ if build_gstgl
install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
configuration : glconf)

gl_enums = gnome.mkenums_simple('gl-enumtypes',
sources : gir_gl_headers,
body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
header_prefix : '#include <gst/gl/gl-prelude.h>',
decorator : 'GST_GL_API',
install_header: true,
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl'))
gl_enumtypes_c = gl_enums[0]
gl_enumtypes_h = gl_enums[1]
glib_mkenums = find_program('glib-mkenums')
mkenums = find_program('gl_mkenum.py')
gl_enumtypes_h = custom_target('gstglenumtypes_h',
output : 'gl-enumtypes.h',
input : gir_gl_headers,
install : true,
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])

gl_enumtypes_c = custom_target('gstglenumtypes_c',
output : 'gl-enumtypes.c',
input : gir_gl_headers,
depends : [gl_enumtypes_h],
command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
gen_sources = [gl_enumtypes_h]

gstgl = library('gstgl-' + api_version,
Expand All @@ -995,7 +1000,9 @@ if build_gstgl
darwin_versions : osxversion,
install : true,
dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps])
gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
# don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
implicit_include_directories : true)

if build_gir
gl_gir = gnome.generate_gir(gstgl,
Expand Down

0 comments on commit 1cc18ec

Please sign in to comment.