mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:51 +00:00
Various aspects of the development workflow are complicated by the need to set env variables ahead of time, or use specific paths. Meson provides a 'devenv' command that can be used to launch a command with a number of appropriate project specific environment variables preset. By default it will modify $PATH to point to any build directory that contains a binary built by the project. This further augments that to replicate the venv 'activate' script: * Add $BUILD_DIR/pyvenv/bin to $PATH * Set VIRTUAL_ENV to $BUILD_DIR/pyvenv And then makes functional tests more easily executable * Add $SRC_DIR/tests/functional and $SRC_DIR/python to $PYTHONPATH To see the benefits of this consider this command: $ source ./build/pyvenv/bin/activate $ ./scripts/qmp/qmp-shell-wrap ./build/qemu-system-x86_64 which is now simplified to $ ./build/run ./scripts/qmp/qmp-shell-wrap qemu-system-x86_64 [args..] This avoids the need repeat './build' several times and avoids polluting the current terminal's environment and/or avoids errors from forgetting to source the venv settings. As another example running functional tests $ export PYTHONPATH=./python:./tests/functional $ export QEMU_TEST_QEMU_BINARY=./build/qemu-system-x86_64 $ build/pyvenv/bin/python3 ./tests/functional/x86_64/test_virtio_version.py which is now simplified to $ export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64 $ ./build/run ./tests/functional/x86_64/test_virtio_version.py This usefulness of this will be further enhanced with the pending removal of the QEMU python APIs from git, as that will require the use of the python venv in even more scenarios that today. The 'run' script does not let 'meson devenv' directly launch the command to be run because it always requires $BUILD_DIR as the current working directory. It is desired that 'run' script always honour the current working directory of the terminal that invokes is. Thus the '--dump' flag is used to export the devenv variables into the 'run' script's shell. This takes the liberty to assign 'run.in' to the "Build system" section in the MAINTAINERS file, given that it leverages meson's 'devenv' feature. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Link: https://lore.kernel.org/r/20251222113859.182395-1-berrange@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
24 KiB
24 KiB