Skip to contentSkip to conversation

makefile fixes/cleanups

PATCH In review Paolo Bonzini 4 participants 9 messages May 25, 2023

lore
Share & tools
lore
#0 lore raw

cover makefile fixes/cleanups

A few fixes for things that have gotten inconsistent or redundant over many changes to Makefile.

Paolo

Paolo Bonzini (3):
tests/docker: simplify HOST_ARCH definition
tests/vm: fix and simplify HOST_ARCH definition
Makefile: remove $(TESTS_PYTHON)

 tests/Makefile.include        | 8 +++-----
 tests/docker/Makefile.include | 2 +-
 tests/vm/Makefile.include     | 7 +++----
 3 files changed, 7 insertions(+), 10 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/3 tests/docker: simplify HOST_ARCH definition

ARCH is always empty, so just define HOST_ARCH as the result of uname.

---
 tests/docker/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/docker/Makefile.include +1 -1
index 94015253254c..142e8605eee9 100644
@@ -6,7 +6,7 @@ NULL :=
 SPACE := $(NULL) #
 COMMA := ,
 
-HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m))
+HOST_ARCH = $(shell uname -m)
 USER = $(if $(NOUSER),,$(shell id -un))
 UID = $(if $(NOUSER),,$(shell id -u))
 
Signature · 1 line
2.40.1
#4 lore raw

PATCH 2/3 tests/vm: fix and simplify HOST_ARCH definition

In reply to Paolo Bonzini

ARCH is always empty, so just define HOST_ARCH as the result of uname. The incorrect definition was not being used because the "ifeq" statement is wrong; replace it with the same idiom based on $(realpath) that the main Makefile uses.

With this change, vm-build-netbsd in a configured tree will not use the PYTHONPATH hack.

---
 tests/vm/Makefile.include | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tests/vm/Makefile.include +2 -3
index 2cc2203d0916..c2a8ca1c175a 100644
@@ -1,14 +1,12 @@
 # Makefile for VM tests
 
 # Hack to allow running in an unconfigured build tree
-ifeq ($(wildcard $(SRC_PATH)/config-host.mak),)
+ifeq ($(realpath $(SRC_PATH)),$(realpath .))
 VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3
 VM_VENV =
-HOST_ARCH := $(shell uname -m)
 else
 VM_PYTHON = $(TESTS_PYTHON)
 VM_VENV = check-venv
-HOST_ARCH = $(ARCH)
 endif
 
 .PHONY: vm-build-all vm-clean-all
@@ -23,6 +21,7 @@ ARM64_IMAGES += ubuntu.aarch64 centos.aarch64
 endif
 endif
 
+HOST_ARCH = $(shell uname -m)
 ifeq ($(HOST_ARCH),x86_64)
 IMAGES=$(X86_IMAGES) $(if $(USE_TCG),$(ARM64_IMAGES))
 else ifeq ($(HOST_ARCH),aarch64)
Signature · 1 line
2.40.1
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] tests/vm: fix and simplify HOST_ARCH definition

Quoted 10 lines · Paolo Bonzini

ARCH is always empty, so just define HOST_ARCH as the result of uname. The incorrect definition was not being used because the "ifeq" statement is wrong; replace it with the same idiom based on $(realpath) that the main Makefile uses.

With this change, vm-build-netbsd in a configured tree will not use the PYTHONPATH hack.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#6 lore raw

PATCH 3/3 Makefile: remove $(TESTS_PYTHON)

In reply to Paolo Bonzini

It is now the same as $(PYTHON), since the latter always points at pyvenv/bin/python3.

---
 tests/Makefile.include    | 8 +++-----
 tests/vm/Makefile.include | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)
tests/Makefile.include +3 -5
index 5b838ec438b0..0184ef223737 100644
@@ -89,11 +89,9 @@ distclean-tcg: $(DISTCLEAN_TCG_TARGET_RULES)
 # Build up our target list from the filtered list of ninja targets
 TARGETS=$(patsubst libqemu-%.fa, %, $(filter libqemu-%.fa, $(ninja-targets)))
 
-TESTS_VENV_DIR=$(BUILD_DIR)/pyvenv
 TESTS_VENV_TOKEN=$(BUILD_DIR)/pyvenv/tests.group
 TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
 TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
-TESTS_PYTHON=$(TESTS_VENV_DIR)/bin/python3
 ifndef AVOCADO_TESTS
 	AVOCADO_TESTS=tests/avocado
 endif
@@ -109,7 +107,7 @@ else
 endif
 
 quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
-    $(TESTS_PYTHON) -m pip -q --disable-pip-version-check $1, \
+    $(PYTHON) -m pip -q --disable-pip-version-check $1, \
     "VENVPIP","$1")
 
 $(TESTS_VENV_TOKEN): $(TESTS_VENV_REQ)
@@ -131,7 +129,7 @@ FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES))
 # download one specific Fedora 31 image
 get-vm-image-fedora-31-%: check-venv
 	$(call quiet-command, \
-             $(TESTS_PYTHON) -m avocado vmimage get \
+             $(PYTHON) -m avocado vmimage get \
              --distro=fedora --distro-version=31 --arch=$*, \
 	"AVOCADO", "Downloading avocado tests VM image for $*")
 
@@ -142,7 +140,7 @@ JOBS_OPTION=$(lastword -j1 $(filter-out -j, $(filter -j%,$(MAKEFLAGS))))
 
 check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images
 	$(call quiet-command, 							\
-            $(TESTS_PYTHON) -m avocado 						\
+            $(PYTHON) -m avocado 						\
             --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) 	\
             $(if $(AVOCADO_TAGS),, 						\
 			--filter-by-tags-include-empty 				\
tests/vm/Makefile.include +1 -1
index c2a8ca1c175a..f0f5d32fb0f0 100644
@@ -5,7 +5,7 @@ ifeq ($(realpath $(SRC_PATH)),$(realpath .))
 VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3
 VM_VENV =
 else
-VM_PYTHON = $(TESTS_PYTHON)
+VM_PYTHON = $(PYTHON)
 VM_VENV = check-venv
 endif
 
Signature · 1 line
2.40.1
Reviewed-by on v1 3/3
#8 lore raw

Re: [PATCH 3/3] Makefile: remove $(TESTS_PYTHON)

In reply to Paolo Bonzini
Quoted 2 lines · Paolo Bonzini

It is now the same as $(PYTHON), since the latter always points at pyvenv/bin/python3.

Good point!

Quoted 2 lines
Quoted 64 lines
---
 tests/Makefile.include    | 8 +++-----
 tests/vm/Makefile.include | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)
tests/Makefile.include +3 -5
index 5b838ec438b0..0184ef223737 100644
@@ -89,11 +89,9 @@ distclean-tcg: $(DISTCLEAN_TCG_TARGET_RULES)
 # Build up our target list from the filtered list of ninja targets
 TARGETS=$(patsubst libqemu-%.fa, %, $(filter libqemu-%.fa, $(ninja-targets)))
 
-TESTS_VENV_DIR=$(BUILD_DIR)/pyvenv
 TESTS_VENV_TOKEN=$(BUILD_DIR)/pyvenv/tests.group
 TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
 TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
-TESTS_PYTHON=$(TESTS_VENV_DIR)/bin/python3
 ifndef AVOCADO_TESTS
        AVOCADO_TESTS=tests/avocado
 endif
@@ -109,7 +107,7 @@ else
 endif
 
 quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
-    $(TESTS_PYTHON) -m pip -q --disable-pip-version-check $1, \
+    $(PYTHON) -m pip -q --disable-pip-version-check $1, \
     "VENVPIP","$1")
 
 $(TESTS_VENV_TOKEN): $(TESTS_VENV_REQ)
@@ -131,7 +129,7 @@ FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES))
 # download one specific Fedora 31 image
 get-vm-image-fedora-31-%: check-venv
        $(call quiet-command, \
-             $(TESTS_PYTHON) -m avocado vmimage get \
+             $(PYTHON) -m avocado vmimage get \
              --distro=fedora --distro-version=31 --arch=$*, \
        "AVOCADO", "Downloading avocado tests VM image for $*")
 
@@ -142,7 +140,7 @@ JOBS_OPTION=$(lastword -j1 $(filter-out -j, $(filter -j%,$(MAKEFLAGS))))
 
 check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images
        $(call quiet-command,                                                   \
-            $(TESTS_PYTHON) -m avocado                                                 \
+            $(PYTHON) -m avocado                                               \
             --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR)  \
             $(if $(AVOCADO_TAGS),,                                             \
                        --filter-by-tags-include-empty                          \
tests/vm/Makefile.include +1 -2
index c2a8ca1c175a..f0f5d32fb0f0 100644
@@ -5,7 +5,7 @@ ifeq ($(realpath $(SRC_PATH)),$(realpath .))
 VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3
 VM_VENV =
 else
-VM_PYTHON = $(TESTS_PYTHON)
+VM_PYTHON = $(PYTHON)
 VM_VENV = check-venv
 endif
 
--

2.40.1