On 8/18/17 11:30 AM, Quentin Glidic wrote:
From: Quentin Glidic <[email protected]>

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 <[email protected]>
---

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
+    ], [])
+])
+
+# 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], [
+        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}])
+])



--

Quentin “Sardem FF7” Glidic
_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to