[PATCH wayland] scanner: Add autoconf macro to check for the proper scanner
Pekka Paalanen
ppaalanen at gmail.com
Fri Aug 18 11:27:11 UTC 2017
On Fri, 18 Aug 2017 11:36:17 +0200
Quentin Glidic <sardemff7+wayland at sardemff7.net> wrote:
> On 8/18/17 11:30 AM, Quentin Glidic wrote:
> > From: Quentin Glidic <sardemff7+git at sardemff7.net>
> >
> > Projects have been using various ways to check for the wayland-scanner,
> > mostly based on their developper own use case, and often not allowing
> > others use cases to work without a workaround.
> >
> > Hopefully this macro will support all use cases without needing user
> > action.
> >
> > Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
> > ---
> >
> > Everyone should test this macro for their own project and use cases.
> > Using the ${WAYLAND_SCANNER} variable should just work (assuming you have the proper
> > wayland package built in the expected env). In very very rare cases, setting the
> > WAYLAND_SCANNER variable as a ./configure argument may be needed, but nothing else.
> >
> > Please let me know with enough details if your use case is not working with it.
>
> Forgot the CCs while sending the patch.
>
>
> > wayland-scanner.m4 | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 54 insertions(+)
> >
> > diff --git a/wayland-scanner.m4 b/wayland-scanner.m4
> > index 4e4222a..37e0548 100644
> > --- a/wayland-scanner.m4
> > +++ b/wayland-scanner.m4
> > @@ -1,3 +1,5 @@
> > +#serial 2
> > +
> > AC_DEFUN([WAYLAND_SCANNER_RULES], [
> > PKG_PROG_PKG_CONFIG
> >
> > @@ -11,3 +13,55 @@ AC_DEFUN([WAYLAND_SCANNER_RULES], [
> >
> > AC_SUBST([wayland_protocoldir], [$1])
> > ])
> > +
> > +
> > +AC_DEFUN([_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK], [
> > + wl_cv_scanner_version=`${WAYLAND_SCANNER} --version 2>&1 | sed 's/^wayland-scanner //'`
> > + AS_VERSION_COMPARE([${wl_cv_scanner_version}], [${wl_cv_scanner_wanted_version}], [], [
> > + wl_cv_scanner_found=yes
> > + ], [])
> > +])
> > +
Hi Quentin,
this is nice, but I think it should also have a comment explaining how
it roughly finds a scanner. This is how I understood it:
1. If WAYLAND_SCANNER env var is set and compatible, use it. Otherwise,
2. if cross-compiling and the build pkg-config is found, use the scanner
found via the build pkg-config if compatible. Otherwise,
3. use the scanner found via the default pkg-config if compatible.
Otherwise,
4. use the scanner found in PATH if compatible. Otherwise,
5. fail.
"Compatible" means that the scanner version must be the same as the
libwayland version found for the host via default pkg-config. So we
also depend on the user projects using default pkg-config to find the
wayland-client and wayland-server libs.
It's also good that it is executing wayland-scanner to find out its
version, meaning that if that file is not actually executable on the
build machine, it will automatically not match.
> > +# WL_PROG_WAYLAND_SCANNER()
> > +AC_DEFUN([WL_PROG_WAYLAND_SCANNER], [
> > + AC_REQUIRE([AC_CANONICAL_BUILD])
> > + AC_REQUIRE([PKG_PROG_PKG_CONFIG])
> > + wl_cv_native_pkg_config=
> > + AS_IF([test x${cross_compiling} = xyes], [
> > + wl_cv_native_pkg_config=${build}-pkg-config
> > + AC_PATH_PROGS([wl_cv_native_pkg_config], [${build}-pkg-config])
> > + ])
> > + AC_ARG_VAR([WAYLAND_SCANNER], [wayland-scanner executable])
> > + wl_cv_scanner_found=no
> > + wl_cv_scanner_wanted_version=`${PKG_CONFIG} --modversion wayland-server`
> > + AC_MSG_CHECKING([that wayland-client and wayland-server versions are the same])
> > + AS_IF([test ${wl_cv_scanner_wanted_version} = `${PKG_CONFIG} --modversion wayland-client`], [
> > + AC_MSG_RESULT([ok])
> > + ], [
> > + AC_MSG_ERROR([mismatch])
> > + ])
> > + AC_MSG_CHECKING([for wayland-scanner ${wl_cv_scanner_wanted_version}])
> > + AS_IF([test x${ac_cv_env_WAYLAND_SCANNER_set} = xset], [
> > + _WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
> > + ])
> > + AS_IF([test x${cross_compiling} = xyes -a x${wl_cv_native_pkg_config} != xno], [
Should this line also test that wl_cv_scanner_found==no? Does it not
overwrite the env var setting otherwise?
> > + AS_IF([AC_RUN_LOG([${wl_cv_native_pkg_config} --exists --print-errors wayland-scanner = ${wl_cv_scanner_wanted_version}])], [
> > + WAYLAND_SCANNER=`${wl_cv_native_pkg_config} --variable=wayland_scanner wayland-scanner = ${wl_cv_scanner_wanted_version}`
> > + _WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
> > + ])
> > + ])
> > + AS_IF([test x${wl_cv_scanner_found} = xno], [
> > + AS_IF([AC_RUN_LOG([${PKG_CONFIG} --exists --print-errors wayland-scanner = ${wl_cv_scanner_wanted_version}])], [
> > + WAYLAND_SCANNER=`${PKG_CONFIG} --variable=wayland_scanner wayland-scanner = ${wl_cv_scanner_wanted_version}`
> > + _WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
> > + ])
> > + ])
> > + AS_IF([test x${wl_cv_scanner_found} = xno], [
> > + AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner])
> > + _WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
> > + ])
> > + AS_IF([test x${wl_cv_scanner_found} = xno], [
> > + AC_MSG_ERROR([no usable wayland-scanner executable version ${wl_cv_scanner_wanted_version}])
> > + ])
> > + AC_MSG_RESULT([${WAYLAND_SCANNER}])
> > +])
> >
The idea looks fine to me, so:
Acked-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20170818/4fa208e6/attachment.sig>
More information about the wayland-devel
mailing list