Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wayland: Build own version of core protocol
Since we are loading shared objects dynamically, build our own version of the
core protocol symbols, so that we in the future can include protocol
extensions.
  • Loading branch information
jadahl committed Jun 23, 2016
1 parent 736a624 commit 19d3500
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 7 deletions.
1 change: 1 addition & 0 deletions .hgignore
Expand Up @@ -8,6 +8,7 @@ Makefile
sdl-config
SDL2.spec
build
gen
Build

# for Xcode
Expand Down
11 changes: 9 additions & 2 deletions Makefile.in
Expand Up @@ -3,6 +3,7 @@
top_builddir = .
srcdir = @srcdir@
objects = build
gen = gen
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
Expand Down Expand Up @@ -31,6 +32,8 @@ WINDRES = @WINDRES@

TARGET = libSDL2.la
OBJECTS = @OBJECTS@
GEN_HEADERS = @GEN_HEADERS@
GEN_OBJECTS = @GEN_OBJECTS@
VERSION_OBJECTS = @VERSION_OBJECTS@

SDLMAIN_TARGET = libSDL2main.a
Expand All @@ -39,6 +42,8 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
SDLTEST_TARGET = libSDL2_test.a
SDLTEST_OBJECTS = @SDLTEST_OBJECTS@

WAYLAND_SCANNER = @WAYLAND_SCANNER@

SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.in debian docs include Makefile.* sdl2-config.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test VisualC.html VisualC VisualC-WinRT Xcode Xcode-iOS
GEN_DIST = SDL2.spec

Expand All @@ -48,6 +53,7 @@ RUN_CMD_CC = @echo " CC " $@;
RUN_CMD_CXX = @echo " CXX " $@;
RUN_CMD_LTLINK = @echo " LTLINK" $@;
RUN_CMD_RANLIB = @echo " RANLIB" $@;
RUN_CMD_GEN = @echo " GEN " $@;
LIBTOOL += --quiet
endif

Expand Down Expand Up @@ -137,8 +143,8 @@ update-revision:

.PHONY: all update-revision install install-bin install-hdrs install-lib install-data uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data clean distclean dist $(OBJECTS:.lo=.d)

$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
$(RUN_CMD_LTLINK)$(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
$(objects)/$(TARGET): $(GEN_HEADERS) $(GEN_OBJECTS) $(OBJECTS) $(VERSION_OBJECTS)
$(RUN_CMD_LTLINK)$(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(OBJECTS) $(GEN_OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)

$(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
$(RUN_CMD_AR)$(AR) cru $@ $(SDLMAIN_OBJECTS)
Expand Down Expand Up @@ -200,6 +206,7 @@ uninstall-data:

clean:
rm -rf $(objects)
rm -rf $(gen)
if test -f test/Makefile; then (cd test; $(MAKE) $@); fi

distclean: clean
Expand Down
42 changes: 40 additions & 2 deletions configure
Expand Up @@ -630,13 +630,16 @@ ac_includes_default="\
#endif"

ac_subst_vars='LTLIBOBJS
WAYLAND_SCANNER
EXTRA_LDFLAGS
BUILD_LDFLAGS
EXTRA_CFLAGS
BUILD_CFLAGS
SDLTEST_OBJECTS
SDLMAIN_OBJECTS
VERSION_OBJECTS
GEN_OBJECTS
GEN_HEADERS
OBJECTS
INCLUDE
ac_aux_dir
Expand Down Expand Up @@ -18804,9 +18807,11 @@ $as_echo_n "checking for Wayland support... " >&6; }
if test x$PKG_CONFIG != xno && \
test x$video_opengl_egl = xyes && \
test x$video_opengles_v2 = xyes; then
if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
if $PKG_CONFIG --exists wayland-client wayland-scanner wayland-egl wayland-cursor egl xkbcommon ; then
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
WAYLAND_CORE_PROTOCOL_DIR=`$PKG_CONFIG --variable=pkgdatadir wayland-client`
video_wayland=yes
fi
fi
Expand All @@ -18823,7 +18828,7 @@ $as_echo "#define SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1" >>confdefs.h

fi
SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
# Check whether --enable-wayland-shared was given.
if test "${enable_wayland_shared+set}" = set; then :
enableval=$enable_wayland_shared;
Expand Down Expand Up @@ -23728,6 +23733,33 @@ if test x$SDLMAIN_SOURCES = x; then
fi
SDLTEST_SOURCES="$srcdir/src/test/*.c"

if test x$video_wayland = xyes; then
WAYLAND_CORE_PROTOCOL_SOURCE='$(gen)/wayland-protocol.c'
WAYLAND_CORE_PROTOCOL_HEADER='$(gen)/wayland-client-protocol.h'
GEN_SOURCES="$GEN_SOURCES $WAYLAND_CORE_PROTOCOL_SOURCE"
GEN_HEADERS="$GEN_HEADERS $WAYLAND_CORE_PROTOCOL_HEADER"

WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS="
$WAYLAND_CORE_PROTOCOL_SOURCE: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) code \$< \$@"

WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS="
$WAYLAND_CORE_PROTOCOL_HEADER: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) client-header \$< \$@"

WAYLAND_CORE_PROTOCOL_OBJECT="
\$(objects)/`echo $WAYLAND_CORE_PROTOCOL_SOURCE | sed 's/\$(gen)\/\(.*\).c$/\1.lo/'`: $WAYLAND_CORE_PROTOCOL_SOURCE
\$(RUN_CMD_CC)\$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \$< -o \$@"

WAYLAND_PROTOCOLS_DEPENDS="
$WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS
$WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS
$WAYLAND_CORE_PROTOCOL_OBJECT
"
fi

OBJECTS=`echo $SOURCES`
DEPENDS=`echo $SOURCES | tr ' ' '\n'`
for EXT in asm cc m c S; do
Expand All @@ -23737,6 +23769,8 @@ for EXT in asm cc m c S; do
\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
done

GEN_OBJECTS=`echo "$GEN_SOURCES" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'`

VERSION_OBJECTS=`echo $VERSION_SOURCES`
VERSION_DEPENDS=`echo $VERSION_SOURCES`
VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.rc,$(objects)/\1.o,g'`
Expand Down Expand Up @@ -23838,6 +23872,9 @@ fi






cat >Makefile.rules <<__EOF__

# Build rules for objects
Expand All @@ -23849,6 +23886,7 @@ $DEPENDS
$VERSION_DEPENDS
$SDLMAIN_DEPENDS
$SDLTEST_DEPENDS
$WAYLAND_PROTOCOLS_DEPENDS
__EOF__

ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc"
Expand Down
39 changes: 37 additions & 2 deletions configure.in
Expand Up @@ -1201,9 +1201,11 @@ AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for
if test x$PKG_CONFIG != xno && \
test x$video_opengl_egl = xyes && \
test x$video_opengles_v2 = xyes; then
if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
if $PKG_CONFIG --exists wayland-client wayland-scanner wayland-egl wayland-cursor egl xkbcommon ; then
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
WAYLAND_CORE_PROTOCOL_DIR=`$PKG_CONFIG --variable=pkgdatadir wayland-client`
video_wayland=yes
fi
fi
Expand All @@ -1215,7 +1217,7 @@ AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for
AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
fi
SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
AC_ARG_ENABLE(wayland-shared,
AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
, enable_wayland_shared=maybe)
Expand Down Expand Up @@ -3481,6 +3483,33 @@ if test x$SDLMAIN_SOURCES = x; then
fi
SDLTEST_SOURCES="$srcdir/src/test/*.c"

if test x$video_wayland = xyes; then
WAYLAND_CORE_PROTOCOL_SOURCE='$(gen)/wayland-protocol.c'
WAYLAND_CORE_PROTOCOL_HEADER='$(gen)/wayland-client-protocol.h'
GEN_SOURCES="$GEN_SOURCES $WAYLAND_CORE_PROTOCOL_SOURCE"
GEN_HEADERS="$GEN_HEADERS $WAYLAND_CORE_PROTOCOL_HEADER"

WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS="
$WAYLAND_CORE_PROTOCOL_SOURCE: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) code \$< \$@"

WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS="
$WAYLAND_CORE_PROTOCOL_HEADER: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) client-header \$< \$@"

WAYLAND_CORE_PROTOCOL_OBJECT="
\$(objects)/`echo $WAYLAND_CORE_PROTOCOL_SOURCE | sed 's/\$(gen)\/\(.*\).c$/\1.lo/'`: $WAYLAND_CORE_PROTOCOL_SOURCE
\$(RUN_CMD_CC)\$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \$< -o \$@"

WAYLAND_PROTOCOLS_DEPENDS="
$WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS
$WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS
$WAYLAND_CORE_PROTOCOL_OBJECT
"
fi

OBJECTS=`echo $SOURCES`
DEPENDS=`echo $SOURCES | tr ' ' '\n'`
for EXT in asm cc m c S; do
Expand All @@ -3490,6 +3519,8 @@ for EXT in asm cc m c S; do
\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
done

GEN_OBJECTS=`echo "$GEN_SOURCES" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`

VERSION_OBJECTS=`echo $VERSION_SOURCES`
VERSION_DEPENDS=`echo $VERSION_SOURCES`
VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
Expand Down Expand Up @@ -3567,6 +3598,8 @@ dnl Expand the sources and objects needed to build the library
AC_SUBST(ac_aux_dir)
AC_SUBST(INCLUDE)
AC_SUBST(OBJECTS)
AC_SUBST(GEN_HEADERS)
AC_SUBST(GEN_OBJECTS)
AC_SUBST(VERSION_OBJECTS)
AC_SUBST(SDLMAIN_OBJECTS)
AC_SUBST(SDLTEST_OBJECTS)
Expand All @@ -3575,6 +3608,7 @@ AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(BUILD_LDFLAGS)
AC_SUBST(EXTRA_LDFLAGS)
AC_SUBST(WINDRES)
AC_SUBST(WAYLAND_SCANNER)

cat >Makefile.rules <<__EOF__

Expand All @@ -3587,6 +3621,7 @@ $DEPENDS
$VERSION_DEPENDS
$SDLMAIN_DEPENDS
$SDLTEST_DEPENDS
$WAYLAND_PROTOCOLS_DEPENDS
__EOF__

AC_CONFIG_FILES([
Expand Down
3 changes: 2 additions & 1 deletion src/video/wayland/SDL_waylanddyn.h
Expand Up @@ -94,7 +94,8 @@ void SDL_WAYLAND_UnloadSymbols(void);

#endif /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */

#include "wayland-client.h"
#include "wayland-client-core.h"
#include "wayland-client-protocol.h"
#include "wayland-egl.h"

#endif /* !defined _SDL_waylanddyn_h */
Expand Down

0 comments on commit 19d3500

Please sign in to comment.