All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v5 00/12] Convert over to use keycodemapdb
Date: Tue, 19 Sep 2017 12:55:11 +0100	[thread overview]
Message-ID: <20170919115511.GJ9536@redhat.com> (raw)
In-Reply-To: <20170919112055.GI9536@redhat.com>

On Tue, Sep 19, 2017 at 12:20:55PM +0100, Daniel P. Berrange wrote:
> On Tue, Sep 19, 2017 at 12:58:20PM +0200, Gerd Hoffmann wrote:
> >   Hi,
> > 
> > > > So I did the keymaps build with a recursive make call too, which
> > > > doesn't look that pretty ...
> > > 
> > > I don't think that's too ugly, but I wonder if there's some way to
> > > avoid
> > > the recursive make call.
> > > 
> > > It feels like this is a similar scenario to 'config-host.mak' being
> > > outdated. I don't entirely understand the logic yet, but we manage to
> > > automatically re-run configure and rebuild config-host.make, when
> > > configure changes, and that in turn affects which dependancies need
> > > rebuild.
> > 
> > Can't spot anything special in the Makefile.  Maybe make is clever
> > enough to figure that a rule updates a include file and starts over
> > then.
> > 
> > > I wonder if we can somehow integrate into that process, so
> > > that configure is responsible for checking out the git submodules,
> > > then make the re-running of configure trigger when .gitmodules
> > > changes content.
> > 
> > .gitmodules only has the repo links, not the checkout hashes.  So it
> > wouldn't be touched on updates.
> > 
> > I can't see an easy way for make to figure a submodule has changed,
> > other than running "git submodule update".
> 
> So I think I figured out the trick libvirt/gnulib uses for this. It
> runs an external script to check the submodule status. This runs
> 'git submodule' to get a list of expected hashes, and compares this
> to a file .git-submodule-status that it previously created (might be
> missing on fresh checkout). If the expected & stores hashes don't
> match this script runs an error.
> 
> The Makefile checks the output of this script, and if it indicates
> that an submodule update is required, it uses an ifeq() to add a
> dependancy between "Makefile" and a phony target that re-runs
> configure (which in turns updates the submodules). If no update was
> required, then no dependancy from Makefile gets added, so build runs
> normally.

Here is an example of integrating this approach with QEMU that seems
like it should work:

diff --git a/.gitmodules b/.gitmodules
index 84c54cdc49..f3bbc01f82 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -34,3 +34,6 @@
 [submodule "roms/QemuMacDrivers"]
 	path = roms/QemuMacDrivers
 	url = git://git.qemu.org/QemuMacDrivers.git
+[submodule "ui/keycodemapdb"]
+	path = ui/keycodemapdb
+	url = https://gitlab.com/keycodemap/keycodemapdb.git
diff --git a/Makefile b/Makefile
index b53fc69a60..62f17d2db5 100644
--- a/Makefile
+++ b/Makefile
@@ -803,6 +803,25 @@ Makefile: $(GENERATED_FILES)
 endif
 endif
 
+ifeq (0,$(MAKELEVEL))
+  git_module_status := $(shell \
+      cd '$(SRC_PATH)'; \
+      test -d .git || test -f .git || { echo 0; exit; }; \
+      ./scripts/git-submodule-status.sh; \
+      echo $$?; \
+  )
+
+ifeq (1,$(git_module_status))
+Makefile: reconfig
+
+.PHONY: reconfig
+
+reconfig:
+	@echo "GIT submodules out of date, re-running configure"
+	./config.status
+endif
+endif
+
 .SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
 	$(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
 	$(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
diff --git a/configure b/configure
index 94db2d103e..eb29a95ff9 100755
--- a/configure
+++ b/configure
@@ -3583,6 +3583,15 @@ fi
 libs_softmmu="$libs_softmmu $fdt_libs"
 
 ##########################################
+# initialize keycodemapdb module
+
+if test -d "${source_path}/.git"
+then
+    git submodule update --init ui/keycodemapdb
+    git submodule status ui/keycodemapdb | awk '{print $1 " " $2}' > .git-submodule-status
+fi
+
+##########################################
 # opengl probe (for sdl2, gtk, milkymist-tmu2)
 
 if test "$opengl" != "no" ; then
diff --git a/scripts/git-submodule-status.sh b/scripts/git-submodule-status.sh
new file mode 100755
index 0000000000..1a28118ee6
--- /dev/null
+++ b/scripts/git-submodule-status.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if ! test -f .git-submodule-status
+then
+   exit 1
+fi
+
+git submodule status ui/keycodemapdb | awk '{print $1 " " $2}' > .git-submodule-status.tmp
+
+diff .git-submodule-status .git-submodule-status.tmp >/dev/null
+
+ret=$?
+
+rm -f .git-submodule-status.tmp
+
+exit $ret
diff --git a/ui/keycodemapdb b/ui/keycodemapdb
new file mode 160000
index 0000000000..56ce5650d2
--- /dev/null
+++ b/ui/keycodemapdb
@@ -0,0 +1 @@
+Subproject commit 56ce5650d2c6ea216b4580df44b9a6dd3bc92c3b
-- 
2.13.5



Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2017-09-19 11:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 12:37 [Qemu-devel] [PATCH v5 00/12] Convert over to use keycodemapdb Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 01/12] ui: add keycodemapdb repository as a GIT submodule Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 02/12] ui: convert common input code to keycodemapdb Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 03/12] ui: convert key events to QKeyCodes immediately Daniel P. Berrange
2017-09-12 13:31   ` Gerd Hoffmann
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 04/12] ui: don't export qemu_input_event_new_key Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 05/12] input: convert virtio-input-hid device to keycodemapdb Daniel P. Berrange
2017-09-12 12:47   ` Daniel P. Berrange
2017-09-12 14:04     ` Gerd Hoffmann
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 06/12] input: convert ps2 " Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 07/12] input: convert the adb " Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 08/12] char: convert the escc " Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 09/12] ui: convert cocoa frontend " Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 10/12] ui: convert the SDL2 " Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 11/12] ui: convert GTK and SDL1 frontends " Daniel P. Berrange
2017-09-12 12:37 ` [Qemu-devel] [PATCH v5 12/12] display: convert XenInput keyboard " Daniel P. Berrange
2017-09-12 12:52 ` [Qemu-devel] [PATCH v5 00/12] Convert over to use keycodemapdb no-reply
2017-09-12 12:53 ` no-reply
2017-09-12 12:55 ` no-reply
2017-09-12 13:46 ` Gerd Hoffmann
2017-09-12 14:19   ` Daniel P. Berrange
2017-09-12 14:24     ` Peter Maydell
2017-09-12 14:30       ` Daniel P. Berrange
2017-09-14 11:55         ` Gerd Hoffmann
2017-09-14 11:58           ` Peter Maydell
2017-09-14 12:40             ` Daniel P. Berrange
2017-09-18 15:12               ` Gerd Hoffmann
2017-09-19 10:08                 ` Daniel P. Berrange
2017-09-19 10:58                   ` Gerd Hoffmann
2017-09-19 11:05                     ` Peter Maydell
2017-09-19 11:20                     ` Daniel P. Berrange
2017-09-19 11:55                       ` Daniel P. Berrange [this message]
2017-09-19 14:26                         ` Gerd Hoffmann
2017-09-19 14:43                           ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170919115511.GJ9536@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.