[CRIU] [PATCH 2/2] Always re-build version.h

Tycho Andersen tycho.andersen at canonical.com
Thu Apr 16 07:14:58 PDT 2015


On Thu, Apr 16, 2015 at 03:23:44PM +0300, Cyrill Gorcunov wrote:
> On Thu, Apr 16, 2015 at 12:24:48PM +0300, Pavel Emelyanov wrote:
> > On 04/15/2015 08:46 PM, Tycho Andersen wrote:
> > > This might be a slightly controversial change since it always causes crtools.h
> > > to be rebuilt, which may be annoying. However, right now version.h is only
> > > generated on the initial git build and never again touched, which is also
> > > incorrect.
> > > 
> > > We could potentially do something fancy by monitoring .git/HEAD for changes,
> > > but since it may not always exist if building from a tarball, it is a little
> > > sticky.
> > > 
> > > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > 
> > Well, "make" on freshly built tree re-build several files. This is indeed
> > annoying. Is there anything better that can be done about it?
> 
> Guys, what about attached? It should work for both git and non-git sources.

Cool, I didn't know you could do conditional PHONYness, this seems
much nicer:

Acked-by: Tycho Andersen <tycho.andersen at canonical.com>

> From 96a05698659c05241e0ba1973d320c97ffd5f803 Mon Sep 17 00:00:00 2001
> From: Cyrill Gorcunov <gorcunov at openvz.org>
> Date: Thu, 16 Apr 2015 15:13:26 +0300
> Subject: [PATCH] make: Rebuild version if git commit id is changed
> 
> CC: Andersen <tycho.andersen at canonical.com>
> CC: Pavel Emelyanov <xemul at parallels.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  .gitignore               |  1 +
>  scripts/Makefile.version | 13 ++++++++++++-
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/.gitignore b/.gitignore
> index 3f284972a4c4..b97a96e8f277 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -30,3 +30,4 @@ include/config.h
>  protobuf-desc-gen.h
>  criu.pc
>  build
> +.gitid
> diff --git a/scripts/Makefile.version b/scripts/Makefile.version
> index 53ee53753db1..91d2112a9b0b 100644
> --- a/scripts/Makefile.version
> +++ b/scripts/Makefile.version
> @@ -1,12 +1,23 @@
>  CRTOOLSVERSION		:= $(VERSION_MAJOR)$(if $(VERSION_MINOR),.$(VERSION_MINOR))$(if $(VERSION_SUBLEVEL),.$(VERSION_SUBLEVEL))
>  
>  VERSION_HEADER := include/version.h
> +GITID_FILE := .gitid
>  GITID := $(shell if [ -d ".git" ]; then git describe; fi)
> +
>  ifeq ($(GITID),)
>  	GITID := 0
> +else
> +        GITID_FILE_VALUE := $(shell if [ `cat .gitid` = $(GITID) ]; then echo y; fi)
> +        ifneq ($(GITID_FILE_VALUE),y)
> +                .PHONY: $(GITID_FILE)
> +        endif
>  endif
>  
> -$(VERSION_HEADER): Makefile scripts/Makefile.version
> +$(GITID_FILE):
> +	$(E) "  GEN     " $@
> +	$(Q) echo "$(GITID)" > $(GITID_FILE)
> +
> +$(VERSION_HEADER): Makefile scripts/Makefile.version $(GITID_FILE)
>  	$(E) "  GEN     " $@
>  	$(Q) echo "/* Autogenerated, do not edit */"			 > $(VERSION_HEADER)
>  	$(Q) echo "#ifndef __CR_VERSION_H__"				>> $(VERSION_HEADER)
> -- 
> 1.9.3
> 



More information about the CRIU mailing list