Re: [PATCH libinput] tools: fake-build the measure touch-pressure/size sources

2018-06-26 Thread Emil Velikov
On 21 June 2018 at 05:56, Peter Hutterer  wrote:
> This way we can make them execute the list-quirks from the builddir.
>
> Signed-off-by: Peter Hutterer 
> ---
> If anyone has any good ideas for how to do something similar for C source
> file, I'd appreciate it.
>
Here is the approach used by git (with git-foo as an example)

a) stat `dirname git`../git-core/git-foo
b) stat (for each in $PATH)/git-foo
c) $(pwd)/git-foo

With the first one found, being executed.
So when installed a) kicks in (99% of the time), and while in builddir c) does.

HTH
Emil
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput] tools: fake-build the measure touch-pressure/size sources

2018-06-20 Thread Peter Hutterer
This way we can make them execute the list-quirks from the builddir.

Signed-off-by: Peter Hutterer 
---
If anyone has any good ideas for how to do something similar for C source
file, I'd appreciate it.

 meson.build  | 18 ++
 tools/libinput-measure-touch-size| 14 ++
 tools/libinput-measure-touchpad-pressure | 14 ++
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/meson.build b/meson.build
index b650bbde..c6ba982d 100644
--- a/meson.build
+++ b/meson.build
@@ -541,16 +541,34 @@ configure_file(input : 
'tools/libinput-measure-touchpad-tap.man',
   install_dir : join_paths(get_option('mandir'), 'man1')
   )
 
+config_builddir = configuration_data()
+config_builddir.set('BUILDDIR', meson.build_root())
+# libinput-measure-touchpad-pressure gets built but we install_data the
+# source instead. The built file is the one that uses the local list-quirks
+# and should be used for debugging.
 install_data('tools/libinput-measure-touchpad-pressure',
 install_dir : libinput_tool_path)
+configure_file(input: 'tools/libinput-measure-touchpad-pressure',
+  output: 'libinput-measure-touchpad-pressure',
+  configuration : config_builddir,
+  install_dir : '')
+
 configure_file(input : 'tools/libinput-measure-touchpad-pressure.man',
   output : 'libinput-measure-touchpad-pressure.1',
   configuration : man_config,
   install : true,
   install_dir : join_paths(get_option('mandir'), 'man1')
   )
+# libinput-measure-touch-size gets built but we install_data the source
+# instead. The built file is the one that uses the local list-quirks and
+# should be used for debugging.
 install_data('tools/libinput-measure-touch-size',
 install_dir : libinput_tool_path)
+configure_file(input: 'tools/libinput-measure-touch-size',
+  output: 'libinput-measure-touch-size',
+  configuration : config_builddir,
+  install_dir : '')
+
 configure_file(input : 'tools/libinput-measure-touch-size.man',
   output : 'libinput-measure-touch-size.1',
   configuration : man_config,
diff --git a/tools/libinput-measure-touch-size 
b/tools/libinput-measure-touch-size
index 9ff65eaa..f2ee0b31 100755
--- a/tools/libinput-measure-touch-size
+++ b/tools/libinput-measure-touch-size
@@ -24,6 +24,7 @@
 # DEALINGS IN THE SOFTWARE.
 #
 
+import os
 import sys
 import subprocess
 import argparse
@@ -221,10 +222,15 @@ class Device(object):
 sys.exit(1)
 
 def _init_thresholds_from_quirks(self):
-# FIXME: this uses the system-installed version
-# but we should really auto-detect when this is started
-# from the builddir
-command = ['libinput', 'list-quirks', self.path]
+# This is replaced for the version in builddir but left as-is for
+# the installed version. For the builddir one we need to run the
+# local list-quirks
+builddir = '@BUILDDIR@'
+if builddir != '@' + 'BUILDDIR' + '@':
+command = [os.path.join(builddir, 'libinput-list-quirks')]
+else:
+command = ['libinput', 'list-quirks']
+command.append(self.path)
 cmd = subprocess.run(command, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 if cmd.returncode != 0:
 print("Error querying quirks: 
{}".format(cmd.stderr.decode('utf-8')), file=sys.stderr)
diff --git a/tools/libinput-measure-touchpad-pressure 
b/tools/libinput-measure-touchpad-pressure
index 765e7997..4026e6ff 100755
--- a/tools/libinput-measure-touchpad-pressure
+++ b/tools/libinput-measure-touchpad-pressure
@@ -24,6 +24,7 @@
 # DEALINGS IN THE SOFTWARE.
 #
 
+import os
 import sys
 import subprocess
 import argparse
@@ -199,10 +200,15 @@ class Device(object):
 sys.exit(1)
 
 def _init_thresholds_from_quirks(self):
-# FIXME: this uses the system-installed version
-# but we should really auto-detect when this is started
-# from the builddir
-command = ['libinput', 'list-quirks', self.path]
+# This is replaced for the version in builddir but left as-is for
+# the installed version. For the builddir one we need to run the
+# local list-quirks
+builddir = '@BUILDDIR@'
+if builddir != '@' + 'BUILDDIR' + '@':
+command = [os.path.join(builddir, 'libinput-list-quirks')]
+else:
+command = ['libinput', 'list-quirks']
+command.append(self.path)
 cmd = subprocess.run(command, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 if cmd.returncode != 0:
 print("Error querying quirks: 
{}".format(cmd.stderr.decode('utf-8')), file=sys.stderr)
-- 
2.17.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org