On 11/6/2026 7:58 AM, Peter Maydell wrote: > This reverts commit ab78ac76f44a1241e76fd32d248df62d83f1ea58. > > The change to create the version header in meson.build loses > the dependency needed for the header file to be built when > it doesn't exist. This means that: > > * if you delete the build/qemu-version.h file, an incremental > rebuild fails, rather than recreating it
That's not what I observe. From current master, file is correctly recreated. Do you still observe a problem with a clean build folder? > * if you do an incremental rebuild from a build tree that > pre-dates ab78ac76f44a, it doesn't have qemu-version.h, > and the rebuild fails > The problem seems to be crossing this commit, which we can't do anything about since it's there. > Revert the commit so we can think about how we want to address this. > > Signed-off-by: Peter Maydell <[email protected]> > --- > meson.build | 29 +++++++++-------------------- > include/qemu/version.h | 8 -------- > scripts/qemu-version.h.in | 1 - > scripts/qemu-version.sh | 25 +++++++++++++++++++++++++ > 4 files changed, 34 insertions(+), 29 deletions(-) > delete mode 100644 scripts/qemu-version.h.in > create mode 100755 scripts/qemu-version.sh > > diff --git a/meson.build b/meson.build > index d7bcb581c18..93da3e6f2bd 100644 > --- a/meson.build > +++ b/meson.build > @@ -78,7 +78,6 @@ have_user = have_linux_user or have_bsd_user > ############ > > sh = find_program('sh') > -git = find_program('git', required: false) > python = import('python').find_installation() > > cc = meson.get_compiler('c') > @@ -3561,25 +3560,15 @@ tracetool_depends = files( > 'scripts/tracetool/__init__.py', > ) > > -qemu_pkgversion = get_option('pkgversion') > -git_describe_version = [git, 'describe', '--match', 'v*', '--dirty'] > -if qemu_pkgversion == '' and git.found() and fs.exists('.git') and \ > - run_command(git_describe_version, check: false).returncode() == 0 > - # Refresh the version at build time, so that "make" after a commit updates > it. > - qemu_version = vcs_tag(input: 'scripts/qemu-version.h.in', > - output: 'qemu-version.h', > - command: git_describe_version, > - fallback: '') > -else > - # Unlike vcs_tag(), which always defines QEMU_PKGVERSION, leave it out if > - # empty. include/qemu/version.h then omits the parentheses from > - # QEMU_FULL_VERSION. > - qemu_version_data = configuration_data() > - if qemu_pkgversion != '' > - qemu_version_data.set_quoted('QEMU_PKGVERSION', qemu_pkgversion) > - endif > - qemu_version = configure_file(output: 'qemu-version.h', configuration: > qemu_version_data) > -endif > +qemu_version_cmd = [find_program('scripts/qemu-version.sh'), > + meson.current_source_dir(), > + get_option('pkgversion'), meson.project_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 > > hxdep = [] > diff --git a/include/qemu/version.h b/include/qemu/version.h > index dd0f937f30c..38405495c0e 100644 > --- a/include/qemu/version.h > +++ b/include/qemu/version.h > @@ -7,14 +7,6 @@ > #ifndef QEMU_VERSION_H > #define QEMU_VERSION_H > > -/* qemu-version.h defines QEMU_PKGVERSION only if it is not empty. */ > #include "qemu-version.h" > > -#ifdef QEMU_PKGVERSION > -#define QEMU_FULL_VERSION QEMU_VERSION " (" QEMU_PKGVERSION ")" > -#else > -#define QEMU_PKGVERSION "" > -#define QEMU_FULL_VERSION QEMU_VERSION > -#endif > - > #endif > diff --git a/scripts/qemu-version.h.in b/scripts/qemu-version.h.in > deleted file mode 100644 > index b62d4c22652..00000000000 > --- a/scripts/qemu-version.h.in > +++ /dev/null > @@ -1 +0,0 @@ > -#define QEMU_PKGVERSION "@VCS_TAG@" > diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh > new file mode 100755 > index 00000000000..3f6e7e6d41d > --- /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) || : > + 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
