wayland: Build own version of core protocol
authorJonas Ådahl <jadahl@gmail.com>
Thu, 23 Jun 2016 18:39:05 +0800
changeset 10303b326f93e1bc5
parent 10302 729eff9ee77a
child 10304 ee83e0b4a36f
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.
.hgignore
Makefile.in
configure
configure.in
src/video/wayland/SDL_waylanddyn.h
     1.1 --- a/.hgignore	Thu Sep 01 01:22:58 2016 -0700
     1.2 +++ b/.hgignore	Thu Jun 23 18:39:05 2016 +0800
     1.3 @@ -8,6 +8,7 @@
     1.4  sdl-config
     1.5  SDL2.spec
     1.6  build
     1.7 +gen
     1.8  Build
     1.9  
    1.10  # for Xcode
     2.1 --- a/Makefile.in	Thu Sep 01 01:22:58 2016 -0700
     2.2 +++ b/Makefile.in	Thu Jun 23 18:39:05 2016 +0800
     2.3 @@ -3,6 +3,7 @@
     2.4  top_builddir = .
     2.5  srcdir  = @srcdir@
     2.6  objects = build
     2.7 +gen = gen
     2.8  prefix = @prefix@
     2.9  exec_prefix = @exec_prefix@
    2.10  bindir	= @bindir@
    2.11 @@ -31,6 +32,8 @@
    2.12  
    2.13  TARGET  = libSDL2.la
    2.14  OBJECTS = @OBJECTS@
    2.15 +GEN_HEADERS = @GEN_HEADERS@
    2.16 +GEN_OBJECTS = @GEN_OBJECTS@
    2.17  VERSION_OBJECTS = @VERSION_OBJECTS@
    2.18  
    2.19  SDLMAIN_TARGET = libSDL2main.a
    2.20 @@ -39,6 +42,8 @@
    2.21  SDLTEST_TARGET = libSDL2_test.a
    2.22  SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
    2.23  
    2.24 +WAYLAND_SCANNER = @WAYLAND_SCANNER@
    2.25 +
    2.26  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
    2.27  GEN_DIST = SDL2.spec
    2.28  
    2.29 @@ -48,6 +53,7 @@
    2.30  RUN_CMD_CXX    = @echo "  CXX   " $@;
    2.31  RUN_CMD_LTLINK = @echo "  LTLINK" $@;
    2.32  RUN_CMD_RANLIB = @echo "  RANLIB" $@;
    2.33 +RUN_CMD_GEN    = @echo "  GEN   " $@;
    2.34  LIBTOOL += --quiet
    2.35  endif
    2.36  
    2.37 @@ -137,8 +143,8 @@
    2.38  
    2.39  .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)
    2.40  
    2.41 -$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
    2.42 -	$(RUN_CMD_LTLINK)$(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
    2.43 +$(objects)/$(TARGET): $(GEN_HEADERS) $(GEN_OBJECTS) $(OBJECTS) $(VERSION_OBJECTS)
    2.44 +	$(RUN_CMD_LTLINK)$(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(OBJECTS) $(GEN_OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
    2.45  
    2.46  $(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
    2.47  	$(RUN_CMD_AR)$(AR) cru $@ $(SDLMAIN_OBJECTS)
    2.48 @@ -200,6 +206,7 @@
    2.49  
    2.50  clean:
    2.51  	rm -rf $(objects)
    2.52 +	rm -rf $(gen)
    2.53  	if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
    2.54  
    2.55  distclean: clean
     3.1 --- a/configure	Thu Sep 01 01:22:58 2016 -0700
     3.2 +++ b/configure	Thu Jun 23 18:39:05 2016 +0800
     3.3 @@ -630,6 +630,7 @@
     3.4  #endif"
     3.5  
     3.6  ac_subst_vars='LTLIBOBJS
     3.7 +WAYLAND_SCANNER
     3.8  EXTRA_LDFLAGS
     3.9  BUILD_LDFLAGS
    3.10  EXTRA_CFLAGS
    3.11 @@ -637,6 +638,8 @@
    3.12  SDLTEST_OBJECTS
    3.13  SDLMAIN_OBJECTS
    3.14  VERSION_OBJECTS
    3.15 +GEN_OBJECTS
    3.16 +GEN_HEADERS
    3.17  OBJECTS
    3.18  INCLUDE
    3.19  ac_aux_dir
    3.20 @@ -18804,9 +18807,11 @@
    3.21          if  test x$PKG_CONFIG != xno && \
    3.22              test x$video_opengl_egl = xyes && \
    3.23              test x$video_opengles_v2 = xyes; then
    3.24 -            if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
    3.25 +            if $PKG_CONFIG --exists wayland-client wayland-scanner wayland-egl wayland-cursor egl xkbcommon ; then
    3.26                  WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
    3.27                  WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
    3.28 +                WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
    3.29 +                WAYLAND_CORE_PROTOCOL_DIR=`$PKG_CONFIG --variable=pkgdatadir wayland-client`
    3.30                  video_wayland=yes
    3.31              fi
    3.32          fi
    3.33 @@ -18823,7 +18828,7 @@
    3.34  
    3.35              fi
    3.36              SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
    3.37 -            EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
    3.38 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
    3.39              # Check whether --enable-wayland-shared was given.
    3.40  if test "${enable_wayland_shared+set}" = set; then :
    3.41    enableval=$enable_wayland_shared;
    3.42 @@ -23728,6 +23733,33 @@
    3.43  fi
    3.44  SDLTEST_SOURCES="$srcdir/src/test/*.c"
    3.45  
    3.46 +if test x$video_wayland = xyes; then
    3.47 +    WAYLAND_CORE_PROTOCOL_SOURCE='$(gen)/wayland-protocol.c'
    3.48 +    WAYLAND_CORE_PROTOCOL_HEADER='$(gen)/wayland-client-protocol.h'
    3.49 +    GEN_SOURCES="$GEN_SOURCES $WAYLAND_CORE_PROTOCOL_SOURCE"
    3.50 +    GEN_HEADERS="$GEN_HEADERS $WAYLAND_CORE_PROTOCOL_HEADER"
    3.51 +
    3.52 +    WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS="
    3.53 +$WAYLAND_CORE_PROTOCOL_SOURCE: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
    3.54 +	\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
    3.55 +	\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) code \$< \$@"
    3.56 +
    3.57 +    WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS="
    3.58 +$WAYLAND_CORE_PROTOCOL_HEADER: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
    3.59 +	\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
    3.60 +	\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) client-header \$< \$@"
    3.61 +
    3.62 +    WAYLAND_CORE_PROTOCOL_OBJECT="
    3.63 +\$(objects)/`echo $WAYLAND_CORE_PROTOCOL_SOURCE | sed 's/\$(gen)\/\(.*\).c$/\1.lo/'`: $WAYLAND_CORE_PROTOCOL_SOURCE
    3.64 +	\$(RUN_CMD_CC)\$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \$< -o \$@"
    3.65 +
    3.66 +    WAYLAND_PROTOCOLS_DEPENDS="
    3.67 +$WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS
    3.68 +$WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS
    3.69 +$WAYLAND_CORE_PROTOCOL_OBJECT
    3.70 +"
    3.71 +fi
    3.72 +
    3.73  OBJECTS=`echo $SOURCES`
    3.74  DEPENDS=`echo $SOURCES | tr ' ' '\n'`
    3.75  for EXT in asm cc m c S; do
    3.76 @@ -23737,6 +23769,8 @@
    3.77  	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
    3.78  done
    3.79  
    3.80 +GEN_OBJECTS=`echo "$GEN_SOURCES" | sed 's,[^ ]*/\([^ ]*\)\.c,$(objects)/\1.lo,g'`
    3.81 +
    3.82  VERSION_OBJECTS=`echo $VERSION_SOURCES`
    3.83  VERSION_DEPENDS=`echo $VERSION_SOURCES`
    3.84  VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[^ ]*/\([^ ]*\)\.rc,$(objects)/\1.o,g'`
    3.85 @@ -23838,6 +23872,9 @@
    3.86  
    3.87  
    3.88  
    3.89 +
    3.90 +
    3.91 +
    3.92  cat >Makefile.rules <<__EOF__
    3.93  
    3.94  # Build rules for objects
    3.95 @@ -23849,6 +23886,7 @@
    3.96  $VERSION_DEPENDS
    3.97  $SDLMAIN_DEPENDS
    3.98  $SDLTEST_DEPENDS
    3.99 +$WAYLAND_PROTOCOLS_DEPENDS
   3.100  __EOF__
   3.101  
   3.102  ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc"
     4.1 --- a/configure.in	Thu Sep 01 01:22:58 2016 -0700
     4.2 +++ b/configure.in	Thu Jun 23 18:39:05 2016 +0800
     4.3 @@ -1201,9 +1201,11 @@
     4.4          if  test x$PKG_CONFIG != xno && \
     4.5              test x$video_opengl_egl = xyes && \
     4.6              test x$video_opengles_v2 = xyes; then
     4.7 -            if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
     4.8 +            if $PKG_CONFIG --exists wayland-client wayland-scanner wayland-egl wayland-cursor egl xkbcommon ; then
     4.9                  WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
    4.10                  WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
    4.11 +                WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
    4.12 +                WAYLAND_CORE_PROTOCOL_DIR=`$PKG_CONFIG --variable=pkgdatadir wayland-client`
    4.13                  video_wayland=yes
    4.14              fi
    4.15          fi
    4.16 @@ -1215,7 +1217,7 @@
    4.17                  AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
    4.18              fi
    4.19              SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
    4.20 -            EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
    4.21 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
    4.22              AC_ARG_ENABLE(wayland-shared,
    4.23  AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
    4.24                            , enable_wayland_shared=maybe)
    4.25 @@ -3481,6 +3483,33 @@
    4.26  fi
    4.27  SDLTEST_SOURCES="$srcdir/src/test/*.c"
    4.28  
    4.29 +if test x$video_wayland = xyes; then
    4.30 +    WAYLAND_CORE_PROTOCOL_SOURCE='$(gen)/wayland-protocol.c'
    4.31 +    WAYLAND_CORE_PROTOCOL_HEADER='$(gen)/wayland-client-protocol.h'
    4.32 +    GEN_SOURCES="$GEN_SOURCES $WAYLAND_CORE_PROTOCOL_SOURCE"
    4.33 +    GEN_HEADERS="$GEN_HEADERS $WAYLAND_CORE_PROTOCOL_HEADER"
    4.34 +
    4.35 +    WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS="
    4.36 +$WAYLAND_CORE_PROTOCOL_SOURCE: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
    4.37 +	\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
    4.38 +	\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) code \$< \$@"
    4.39 +
    4.40 +    WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS="
    4.41 +$WAYLAND_CORE_PROTOCOL_HEADER: $WAYLAND_CORE_PROTOCOL_DIR/wayland.xml
    4.42 +	\$(SHELL) \$(auxdir)/mkinstalldirs \$(gen)
    4.43 +	\$(RUN_CMD_GEN)\$(WAYLAND_SCANNER) client-header \$< \$@"
    4.44 +
    4.45 +    WAYLAND_CORE_PROTOCOL_OBJECT="
    4.46 +\$(objects)/`echo $WAYLAND_CORE_PROTOCOL_SOURCE | sed 's/\$(gen)\/\(.*\).c$/\1.lo/'`: $WAYLAND_CORE_PROTOCOL_SOURCE
    4.47 +	\$(RUN_CMD_CC)\$(LIBTOOL) --tag=CC --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \$< -o \$@"
    4.48 +
    4.49 +    WAYLAND_PROTOCOLS_DEPENDS="
    4.50 +$WAYLAND_CORE_PROTOCOL_SOURCE_DEPENDS
    4.51 +$WAYLAND_CORE_PROTOCOL_HEADER_DEPENDS
    4.52 +$WAYLAND_CORE_PROTOCOL_OBJECT
    4.53 +"
    4.54 +fi
    4.55 +
    4.56  OBJECTS=`echo $SOURCES`
    4.57  DEPENDS=`echo $SOURCES | tr ' ' '\n'`
    4.58  for EXT in asm cc m c S; do
    4.59 @@ -3490,6 +3519,8 @@
    4.60  	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
    4.61  done
    4.62  
    4.63 +GEN_OBJECTS=`echo "$GEN_SOURCES" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
    4.64 +
    4.65  VERSION_OBJECTS=`echo $VERSION_SOURCES`
    4.66  VERSION_DEPENDS=`echo $VERSION_SOURCES`
    4.67  VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
    4.68 @@ -3567,6 +3598,8 @@
    4.69  AC_SUBST(ac_aux_dir)
    4.70  AC_SUBST(INCLUDE)
    4.71  AC_SUBST(OBJECTS)
    4.72 +AC_SUBST(GEN_HEADERS)
    4.73 +AC_SUBST(GEN_OBJECTS)
    4.74  AC_SUBST(VERSION_OBJECTS)
    4.75  AC_SUBST(SDLMAIN_OBJECTS)
    4.76  AC_SUBST(SDLTEST_OBJECTS)
    4.77 @@ -3575,6 +3608,7 @@
    4.78  AC_SUBST(BUILD_LDFLAGS)
    4.79  AC_SUBST(EXTRA_LDFLAGS)
    4.80  AC_SUBST(WINDRES)
    4.81 +AC_SUBST(WAYLAND_SCANNER)
    4.82  
    4.83  cat >Makefile.rules <<__EOF__
    4.84  
    4.85 @@ -3587,6 +3621,7 @@
    4.86  $VERSION_DEPENDS
    4.87  $SDLMAIN_DEPENDS
    4.88  $SDLTEST_DEPENDS
    4.89 +$WAYLAND_PROTOCOLS_DEPENDS
    4.90  __EOF__
    4.91  
    4.92  AC_CONFIG_FILES([
     5.1 --- a/src/video/wayland/SDL_waylanddyn.h	Thu Sep 01 01:22:58 2016 -0700
     5.2 +++ b/src/video/wayland/SDL_waylanddyn.h	Thu Jun 23 18:39:05 2016 +0800
     5.3 @@ -94,7 +94,8 @@
     5.4  
     5.5  #endif /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
     5.6  
     5.7 -#include "wayland-client.h"
     5.8 +#include "wayland-client-core.h"
     5.9 +#include "wayland-client-protocol.h"
    5.10  #include "wayland-egl.h"
    5.11  
    5.12  #endif /* !defined _SDL_waylanddyn_h */