OSDN Git Service

i965_drv_video: add git commit id to VA driver version string.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 2 Sep 2014 08:10:21 +0000 (10:10 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 9 Sep 2014 13:22:31 +0000 (15:22 +0200)
v2: renamed i965_drv_version.h to intel_version.h, changed macro
  definition to INTEL_DRIVER_GIT_VERSION, and displayed the git
  version string only in "pre" version modes.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
configure.ac
src/Makefile.am
src/i965_drv_video.c
src/intel_version.h.in [new file with mode: 0644]

index 86c2b40..7feb074 100644 (file)
@@ -80,6 +80,11 @@ PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.5], [gen4asm=yes], [gen4asm=no])
 AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
 AC_PATH_PROG([GEN4ASM], [intel-gen4asm])
 
+dnl Check for git
+AC_ARG_VAR([GIT], [Path to git program, if any])
+AC_PATH_PROG([GIT], [git])
+AM_CONDITIONAL([HAVE_GIT], [test -n "$GIT"])
+
 dnl Check for VA-API
 PKG_CHECK_MODULES(LIBVA_DEPS,     [libva >= va_api_version])
 
index b35d1ac..acfa849 100755 (executable)
 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-SUBDIRS = shaders
+SUBDIRS                = shaders
+DIST_SUBDIRS   = $(SUBDIRS)
+EXTRA_DIST     =
+BUILT_SOURCES  =
 
 AM_CPPFLAGS = \
        -DPTHREADS              \
@@ -120,6 +123,7 @@ source_h = \
        intel_driver.h          \
        intel_media.h           \
        intel_memman.h          \
+       intel_version.h         \
        object_heap.h           \
        sysdeps.h               \
        va_backend_compat.h     \
@@ -145,12 +149,43 @@ source_h                  += i965_output_wayland.h
 driver_cflags                  += $(WAYLAND_CFLAGS)
 endif
 
+# git version
+VERSION_FILE                   = .VERSION
+OLD_VERSION_FILE               = $(VERSION_FILE).old
+NEW_VERSION_FILE               = $(VERSION_FILE).new
+PKG_VERSION_FILE               = $(VERSION_FILE).pkg
+
+intel_version.h: gen-version
+       $(AM_V_GEN)                                                      \
+       OV=`[ -f $(OLD_VERSION_FILE) ] && cat $(OLD_VERSION_FILE) || :`; \
+       NV=`cat $(NEW_VERSION_FILE)`;                                    \
+       if [ "$$OV" != "$$NV" -o ! -f intel_version.h ]; then            \
+               cp -f $(NEW_VERSION_FILE) $(OLD_VERSION_FILE);           \
+               $(SED) -e "s|\@INTEL_DRIVER_GIT_VERSION\@|$${NV}|"       \
+                       $(srcdir)/intel_version.h.in > intel_version.h;  \
+       fi
+
+gen-version:
+       @echo $(VERSION) > $(NEW_VERSION_FILE)
+if HAVE_GIT
+       @[ -d $(top_srcdir)/.git ] && \
+       (cd $(top_srcdir) && $(GIT) describe --tags) > $(NEW_VERSION_FILE) || :
+endif
+       @[ -f $(srcdir)/$(PKG_VERSION_FILE) ] && \
+       cp -f $(srcdir)/$(PKG_VERSION_FILE) $(NEW_VERSION_FILE) || :
+
+$(PKG_VERSION_FILE): $(NEW_VERSION_FILE)
+       @cp -f $< $@
+
+BUILT_SOURCES  += intel_version.h
+EXTRA_DIST     += intel_version.h.in $(PKG_VERSION_FILE)
+
 # Wayland protocol
 protocol_source_h = wayland-drm-client-protocol.h
 i965_output_wayland.c: $(protocol_source_h)
 @wayland_scanner_rules@
 
-DIST_SUBDIRS = $(SUBDIRS) wayland
+DIST_SUBDIRS   += wayland
 
 # Extra clean files so that maintainer-clean removes *everything*
 MAINTAINERCLEANFILES = Makefile.in config.h.in
index dec218f..2b9f6ec 100644 (file)
@@ -38,6 +38,7 @@
 # include "i965_output_wayland.h"
 #endif
 
+#include "intel_version.h"
 #include "intel_driver.h"
 #include "intel_memman.h"
 #include "intel_batchbuffer.h"
@@ -5630,6 +5631,12 @@ ensure_vendor_string(struct i965_driver_data *i965, const char *chipset)
         if (ret < 0 || ret >= sizeof(i965->va_vendor))
             goto error;
         len += ret;
+
+        ret = snprintf(&i965->va_vendor[len], sizeof(i965->va_vendor) - len,
+            " (%s)", INTEL_DRIVER_GIT_VERSION);
+        if (ret < 0 || ret >= sizeof(i965->va_vendor))
+            goto error;
+        len += ret;
     }
     return true;
 
diff --git a/src/intel_version.h.in b/src/intel_version.h.in
new file mode 100644 (file)
index 0000000..050e834
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef INTEL_VERSION_H
+#define INTEL_VERSION_H
+
+/**
+ * INTEL_DRIVER_GIT_VERSION:
+ *
+ * The full version identifier of libva-intel-driver, from a git
+ * repository, in string form (suitable for string concatenation).
+ */
+#define INTEL_DRIVER_GIT_VERSION "@INTEL_DRIVER_GIT_VERSION@"
+
+#endif /* INTEL_VERSION_H */