From: Alexandros Frantzis alexandros.frantzis@collabora.com
Wayland protocol descriptions are distributed as source XML files that need to be transformed to C source and header files with a version of the wayland-scanner tool compatible with the used libwayland library.
This commit enhances the makedep build tool to support building such Wayland protocol XML files. Components can use the WAYLAND_PROTOCOL_SRCS build variable to add protocol XML files to their build.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- configure | 99 +++++++++++++++++++++++++++++++++++++-- configure.ac | 11 ++++- tools/gitlab/image.docker | 1 + tools/makedep.c | 83 ++++++++++++++++++++++++++++++++ 4 files changed, 189 insertions(+), 5 deletions(-)
diff --git a/configure b/configure index 027fe05f418..2aee02db587 100755 --- a/configure +++ b/configure @@ -702,6 +702,10 @@ INOTIFY_LIBS INOTIFY_CFLAGS PCSCLITE_LIBS PCAP_LIBS +WAYLAND_SCANNER +WAYLAND_PROTOCOLS_DATADIR +WAYLAND_PROTOCOLS_LIBS +WAYLAND_PROTOCOLS_CFLAGS WAYLAND_CLIENT_LIBS WAYLAND_CLIENT_CFLAGS X_EXTRA_LIBS @@ -1750,6 +1754,8 @@ XMKMF CPP WAYLAND_CLIENT_CFLAGS WAYLAND_CLIENT_LIBS +WAYLAND_PROTOCOLS_CFLAGS +WAYLAND_PROTOCOLS_LIBS INOTIFY_CFLAGS INOTIFY_LIBS DBUS_CFLAGS @@ -2554,6 +2560,10 @@ Some influential environment variables: C compiler flags for wayland-client, overriding pkg-config WAYLAND_CLIENT_LIBS Linker flags for wayland-client, overriding pkg-config + WAYLAND_PROTOCOLS_CFLAGS + C compiler flags for wayland-protocols, overriding pkg-config + WAYLAND_PROTOCOLS_LIBS + Linker flags for wayland-protocols, overriding pkg-config INOTIFY_CFLAGS C compiler flags for libinotify, overriding pkg-config INOTIFY_LIBS @@ -15763,13 +15773,92 @@ fi
CPPFLAGS=$ac_save_CPPFLAGS
+ rm -f conftest.err +if ${WAYLAND_PROTOCOLS_CFLAGS:+false} : +then : + if test ${PKG_CONFIG+y} +then : + WAYLAND_PROTOCOLS_CFLAGS=`$PKG_CONFIG --cflags wayland-protocols 2>conftest.err` +fi +fi + +if ${WAYLAND_PROTOCOLS_LIBS:+false} : +then : + if test ${PKG_CONFIG+y} +then : + WAYLAND_PROTOCOLS_LIBS=`$PKG_CONFIG --libs wayland-protocols 2>/dev/null` +fi +fi + + +printf "%s\n" "$as_me:${as_lineno-$LINENO}: wayland-protocols cflags: $WAYLAND_PROTOCOLS_CFLAGS" >&5 +printf "%s\n" "$as_me:${as_lineno-$LINENO}: wayland-protocols libs: $WAYLAND_PROTOCOLS_LIBS" >&5 +if test -s conftest.err; then + printf %s "$as_me:${as_lineno-$LINENO}: wayland-protocols errors: " >&5 + cat conftest.err >&5 +fi +rm -f conftest.err +ac_save_CPPFLAGS=$CPPFLAGS +CPPFLAGS="$CPPFLAGS $WAYLAND_PROTOCOLS_CFLAGS" +WAYLAND_PROTOCOLS_DATADIR=`$PKG_CONFIG --atleast-version=1.14 wayland-protocols && $PKG_CONFIG --variable=pkgdatadir wayland-protocols` + +CPPFLAGS=$ac_save_CPPFLAGS + + # Extract the first word of "wayland-scanner", so it can be a program name with args. +set dummy wayland-scanner; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_WAYLAND_SCANNER+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $WAYLAND_SCANNER in + [\/]* | ?:[\/]*) + ac_cv_path_WAYLAND_SCANNER="$WAYLAND_SCANNER" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_WAYLAND_SCANNER="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_WAYLAND_SCANNER" && ac_cv_path_WAYLAND_SCANNER="`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`" + ;; +esac +fi +WAYLAND_SCANNER=$ac_cv_path_WAYLAND_SCANNER +if test -n "$WAYLAND_SCANNER"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $WAYLAND_SCANNER" >&5 +printf "%s\n" "$WAYLAND_SCANNER" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + fi -if test -z "$WAYLAND_CLIENT_LIBS" +if test -z "$WAYLAND_CLIENT_LIBS" || + test -z "$WAYLAND_PROTOCOLS_DATADIR" || + test -z "$WAYLAND_SCANNER" then : case "x$with_wayland" in - x) as_fn_append wine_notices "|Wayland ${notice_platform}development files not found, the Wayland driver won't be supported." ;; + x) as_fn_append wine_notices "|Wayland ${notice_platform}development files not found or not new enough, the Wayland driver won't be supported." ;; xno) ;; - *) as_fn_error $? "Wayland ${notice_platform}development files not found, the Wayland driver won't be supported. + *) as_fn_error $? "Wayland ${notice_platform}development files not found or not new enough, the Wayland driver won't be supported. This is an error since --with-wayland was requested." "$LINENO" 5 ;; esac enable_winewayland_drv=${enable_winewayland_drv:-no} @@ -23270,6 +23359,10 @@ X_LIBS = $X_LIBS X_EXTRA_LIBS = $X_EXTRA_LIBS WAYLAND_CLIENT_CFLAGS = $WAYLAND_CLIENT_CFLAGS WAYLAND_CLIENT_LIBS = $WAYLAND_CLIENT_LIBS +WAYLAND_PROTOCOLS_CFLAGS = $WAYLAND_PROTOCOLS_CFLAGS +WAYLAND_PROTOCOLS_LIBS = $WAYLAND_PROTOCOLS_LIBS +WAYLAND_PROTOCOLS_DATADIR = $WAYLAND_PROTOCOLS_DATADIR +WAYLAND_SCANNER = $WAYLAND_SCANNER PCAP_LIBS = $PCAP_LIBS PCSCLITE_LIBS = $PCSCLITE_LIBS INOTIFY_CFLAGS = $INOTIFY_CFLAGS diff --git a/configure.ac b/configure.ac index 4f88a5f96c0..7723fce22f1 100644 --- a/configure.ac +++ b/configure.ac @@ -1370,9 +1370,16 @@ else [AC_CHECK_HEADERS([wayland-client.h]) AC_CHECK_LIB(wayland-client,wl_display_connect,[:], [WAYLAND_CLIENT_LIBS=""],[$WAYLAND_CLIENT_LIBS])]) + WINE_PACKAGE_FLAGS(WAYLAND_PROTOCOLS, [wayland-protocols],,,, + [AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, + `$PKG_CONFIG --atleast-version=1.14 wayland-protocols && $PKG_CONFIG --variable=pkgdatadir wayland-protocols`)]) + AC_PATH_PROG(WAYLAND_SCANNER,wayland-scanner, + [`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`]) fi -WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS"], - [Wayland ${notice_platform}development files not found, the Wayland driver won't be supported.], +WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS" || + test -z "$WAYLAND_PROTOCOLS_DATADIR" || + test -z "$WAYLAND_SCANNER"], + [Wayland ${notice_platform}development files not found or not new enough, the Wayland driver won't be supported.], [enable_winewayland_drv])
dnl **** Check for OpenCL **** diff --git a/tools/gitlab/image.docker b/tools/gitlab/image.docker index cf16ed49c95..7e8d69170c1 100644 --- a/tools/gitlab/image.docker +++ b/tools/gitlab/image.docker @@ -51,6 +51,7 @@ RUN export DEBIAN_FRONTEND=noninteractive; \ ocl-icd-opencl-dev:amd64 ocl-icd-opencl-dev:i386 \ samba-dev:amd64 \ unixodbc-dev:amd64 unixodbc-dev:i386 \ + wayland-protocols \ x11proto-dev && \ apt-get install -y ccache netbase curl ca-certificates xserver-xorg-video-dummy xserver-xorg xfonts-base xinit fvwm \ winbind fonts-liberation2 fonts-noto-core fonts-noto-cjk pulseaudio libasound2-plugins:amd64 libasound2-plugins:i386 \ diff --git a/tools/makedep.c b/tools/makedep.c index b94a221854d..b632cb68978 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -157,6 +157,7 @@ static const char *icotool; static const char *msgfmt; static const char *ln_s; static const char *sed_cmd; +static const char *wayland_scanner; /* per-architecture global variables */ static const char *arch_dirs[MAX_ARCHS]; static const char *arch_pe_dirs[MAX_ARCHS]; @@ -471,6 +472,15 @@ static char *replace_filename( const char *path, const char *name ) return ret; }
+/******************************************************************* + * get_filename + */ +static char *get_filename( const char *name ) +{ + char *filename = strrchr( name, '/' ); + if (!filename) return xstrdup( name ); + return xstrdup( filename + 1 ); +}
/******************************************************************* * replace_substr @@ -1390,6 +1400,35 @@ static struct file *open_src_file( const struct makefile *make, struct incl_file return file; }
+/******************************************************************* + * open_wayland_protocol_file + */ +static struct file *open_wayland_protocol_file( const struct makefile *make, + struct incl_file *pFile ) +{ + char *proto_filename; + struct incl_file *incl_file; + struct file *ret_file = NULL; + + if (!strendswith( pFile->name, "-client-protocol.h" )) return NULL; + + proto_filename = replace_extension( pFile->name, "-client-protocol.h", ".xml" ); + + LIST_FOR_EACH_ENTRY( incl_file, &make->sources, struct incl_file, entry ) + { + if (strendswith( incl_file->name, proto_filename )) + { + pFile->sourcename = incl_file->filename; + pFile->filename = obj_dir_path( make, pFile->name ); + ret_file = incl_file->file; + break; + } + } + + free( proto_filename ); + + return ret_file; +}
/******************************************************************* * find_importlib_module @@ -1429,6 +1468,7 @@ static struct file *open_include_file( const struct makefile *make, struct incl_ if ((file = open_local_generated_file( make, pFile, ".cur", ".svg" ))) return file; if ((file = open_local_generated_file( make, pFile, ".ico", ".svg" ))) return file; } + if ((file = open_wayland_protocol_file( make, pFile ))) return file;
/* check for extra targets */ if (strarray_exists( &make->extra_targets, pFile->name )) @@ -1803,6 +1843,15 @@ static struct makefile *parse_makefile( const char *path ) return make; }
+/******************************************************************* + * is_wayland_protocol + */ +static int is_wayland_protocol( struct incl_file *source ) +{ + return strendswith( source->name, ".xml" ) && + (strstr( source->name, "stable/" ) || strstr( source->name, "unstable/" ) || + strstr( source->name, "staging/" )); +}
/******************************************************************* * add_generated_sources @@ -1916,6 +1965,23 @@ static void add_generated_sources( struct makefile *make ) strarray_addall_uniq( &make->extra_imports, get_expanded_file_local_var( make, obj, "IMPORTS" )); } + if (is_wayland_protocol( source )) + { + char *filename = get_filename( source->name ); + char *code_filename = replace_extension ( filename , ".xml", "-protocol.c" ); + char *header_filename = replace_extension ( filename , ".xml", "-client-protocol.h" ); + + file = add_generated_source( make, code_filename, NULL, 0 ); + file->file->flags |= FLAG_C_UNIX; + file->use_msvcrt = 0; + file = add_generated_source( make, header_filename, NULL, 0 ); + file->file->flags |= FLAG_C_UNIX; + file->use_msvcrt = 0; + + free( filename ); + free( code_filename ); + free( header_filename ); + } } if (make->testdll) { @@ -3125,6 +3191,19 @@ static void output_source_spec( struct makefile *make, struct incl_file *source, } }
+static void output_source_xml( struct makefile *make, struct incl_file *source, const char *obj ) +{ + char *base; + + if (!is_wayland_protocol( source )) return; + + base = get_filename( obj ); + output( "%s-protocol.c: %s\n", obj_dir_path( make, base ), source->filename ); + output( "\t%s%s private-code $< $@\n", cmd_prefix( "WAYLAND_SCANNER" ), wayland_scanner ); + output( "%s-client-protocol.h: %s\n", obj_dir_path( make, base ), source->filename ); + output( "\t%s%s client-header $< $@\n", cmd_prefix( "WAYLAND_SCANNER" ), wayland_scanner); + free( base ); +}
/******************************************************************* * output_source_one_arch @@ -3264,6 +3343,7 @@ static const struct { "in", output_source_in }, { "x", output_source_x }, { "spec", output_source_spec }, + { "xml", output_source_xml }, { NULL, output_source_default } };
@@ -4121,6 +4201,7 @@ static void output_silent_rules(void) "MSG", "SED", "TEST", + "WAYLAND_SCANNER", "WIDL", "WMC", "WRC" @@ -4220,6 +4301,7 @@ static void load_sources( struct makefile *make ) "IN_SRCS", "PO_SRCS", "MANPAGES", + "WAYLAND_PROTOCOL_SRCS", NULL }; const char **var; @@ -4451,6 +4533,7 @@ int main( int argc, char *argv[] ) msgfmt = get_expanded_make_variable( top_makefile, "MSGFMT" ); sed_cmd = get_expanded_make_variable( top_makefile, "SED_CMD" ); ln_s = get_expanded_make_variable( top_makefile, "LN_S" ); + wayland_scanner = get_expanded_make_variable( top_makefile, "WAYLAND_SCANNER" );
if (root_src_dir && !strcmp( root_src_dir, "." )) root_src_dir = NULL; if (tools_dir && !strcmp( tools_dir, "." )) tools_dir = NULL;