Skip to content

Commit

Permalink
scripts: Convert qemu-version.sh to qemu-version.py
Browse files Browse the repository at this point in the history
The sh script are harder to maintain for compatible different
xsh environment so convert it to python script
Also incorporate the fixes in
https://patchew.org/QEMU/[email protected]/

According to msys2/MSYS2-packages#2176
We need use CYGWIN=noglob and MSYS=noglob in the environment variable
for disable wildcard expanding in msys or cygwin git, and setting the shell=False

Signed-off-by: Yonggang Luo <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
lygstate committed Mar 21, 2021
1 parent 0c54716 commit 34967a1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ tracetool_depends = files(
'scripts/tracetool/vcpu.py'
)

qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
qemu_version_cmd = [find_program('scripts/qemu-version.py'),
meson.current_source_dir(),
config_host['PKGVERSION'], meson.project_version()]
qemu_version = custom_target('qemu-version.h',
Expand Down
37 changes: 37 additions & 0 deletions scripts/qemu-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3

#
# Script for retrieve qemu git version information
#
# Authors:
# Yonggang Luo <[email protected]>
#
# This work is licensed under the terms of the GNU GPL, version 2.1
# or, at your option, any later version. See the COPYING file in
# the top-level directory.

import sys
import subprocess
import os
import os.path

def main(_program, dir, pkgversion, version, *unused):
os.chdir(dir)
if not pkgversion and os.path.exists('.git'):
pc = subprocess.run(
['git', 'describe', '--match', 'v*', '--dirty', '--always'],
env=dict(os.environ, CYGWIN="noglob", MSYS='noglob'),
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
encoding='utf8', shell=False)
if pc.returncode == 0:
pkgversion = pc.stdout.strip()

fullversion = version
if pkgversion:
fullversion = "{} ({})".format(version, pkgversion)

print('#define QEMU_PKGVERSION "%s"' % pkgversion)
print('#define QEMU_FULL_VERSION "%s"' % fullversion)

if __name__ == "__main__":
main(*sys.argv)
25 changes: 0 additions & 25 deletions scripts/qemu-version.sh

This file was deleted.

0 comments on commit 34967a1

Please sign in to comment.