aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2019-07-15 17:10:19 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2020-08-21 06:30:14 -0400
commit2c273f32d3489a54010c70b4065222ff4dda3f49 (patch)
treeb7a6db93e402a8acd9baddf0e180fa83123cdb10
parent2d78b56e7abe327fc411d4c96ce0b3cffc0d9282 (diff)
downloadqemu-2c273f32d3489a54010c70b4065222ff4dda3f49.zip
qemu-2c273f32d3489a54010c70b4065222ff4dda3f49.tar.gz
qemu-2c273f32d3489a54010c70b4065222ff4dda3f49.tar.bz2
meson: generate qemu-version.h
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--Makefile27
-rw-r--r--meson.build14
-rwxr-xr-xscripts/qemu-version.sh25
3 files changed, 38 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index c07b6bb..0b86e3a 100644
--- a/Makefile
+++ b/Makefile
@@ -121,21 +121,7 @@ include $(SRC_PATH)/rules.mak
# lor is defined in rules.mak
CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
-# Create QEMU_PKGVERSION and FULL_VERSION strings
-# If PKGVERSION is set, use that; otherwise get version and -dirty status from git
-QEMU_PKGVERSION := $(if $(PKGVERSION),$(PKGVERSION),$(shell \
- cd $(SRC_PATH); \
- if test -e .git; then \
- git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
- if ! git diff-index --quiet HEAD &>/dev/null; then \
- echo "-dirty"; \
- fi; \
- fi))
-
-# Either "version (pkgversion)", or just "version" if pkgversion not set
-FULL_VERSION := $(if $(QEMU_PKGVERSION),$(VERSION) ($(QEMU_PKGVERSION)),$(VERSION))
-
-generated-files-y = qemu-version.h config-host.h qemu-options.def
+generated-files-y = config-host.h qemu-options.def
generated-files-y += module_block.h
@@ -275,17 +261,6 @@ include $(SRC_PATH)/tests/Makefile.include
all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules
-qemu-version.h: FORCE
- $(call quiet-command, \
- (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
- printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
- ) > $@.tmp)
- $(call quiet-command, if ! cmp -s $@ $@.tmp; then \
- mv $@.tmp $@; \
- else \
- rm $@.tmp; \
- fi)
-
config-host.h: config-host.h-timestamp
config-host.h-timestamp: config-host.mak
qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
diff --git a/meson.build b/meson.build
index b4a2f9d..e8df2a6 100644
--- a/meson.build
+++ b/meson.build
@@ -158,6 +158,7 @@ have_block = have_system or have_tools
# Generators
+genh = []
qapi_gen = find_program('scripts/qapi-gen.py')
qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py',
meson.source_root() / 'scripts/qapi/commands.py',
@@ -183,6 +184,17 @@ tracetool = [
'--backend=' + config_host['TRACE_BACKENDS']
]
+qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
+ meson.current_source_dir(),
+ config_host['PKGVERSION'], config_host['VERSION']]
+qemu_version = custom_target('qemu-version.h',
+ output: 'qemu-version.h',
+ command: qemu_version_cmd,
+ capture: true,
+ build_by_default: true,
+ build_always_stale: true)
+genh += qemu_version
+
# Collect sourcesets.
util_ss = ss.source_set()
@@ -283,8 +295,6 @@ trace_events_subdirs += [
'util',
]
-genh = []
-
subdir('qapi')
subdir('qobject')
subdir('stubs')
diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh
new file mode 100755
index 0000000..4847385
--- /dev/null
+++ b/scripts/qemu-version.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -eu
+
+dir="$1"
+pkgversion="$2"
+version="$3"
+
+if [ -z "$pkgversion"]; then
+ cd "$dir"
+ if [ -e .git ]; then
+ pkgversion=$(git describe --match 'v*' --dirty | echo "")
+ fi
+fi
+
+if [ -n "$pkgversion" ]; then
+ fullversion="$version ($pkgversion)"
+else
+ fullversion="$version"
+fi
+
+cat <<EOF
+#define QEMU_PKGVERSION "$pkgversion"
+#define QEMU_FULL_VERSION "$fullversion"
+EOF