2018-04-06 18:08:37 +08:00
|
|
|
# -*- Mode: makefile -*-
|
|
|
|
#
|
|
|
|
# TCG tests (per-target rules)
|
|
|
|
#
|
2019-08-07 22:35:22 +08:00
|
|
|
# This Makefile fragment is included from the build-tcg target, once
|
|
|
|
# for each target we build. We have two options for compiling, either
|
|
|
|
# using a configured guest compiler or calling one of our docker images
|
|
|
|
# to do it for us.
|
2018-04-06 18:08:37 +08:00
|
|
|
#
|
|
|
|
|
2019-08-07 22:35:23 +08:00
|
|
|
# The configure script fills in extra information about
|
2018-04-06 18:08:37 +08:00
|
|
|
# useful docker images or alternative compiler flags.
|
|
|
|
|
2020-09-21 22:34:47 +08:00
|
|
|
# Usage: $(call quiet-command,command and args,"NAME","args to print")
|
|
|
|
# This will run "command and args", and either:
|
|
|
|
# if V=1 just print the whole command and args
|
|
|
|
# otherwise print the 'quiet' output in the format " NAME args to print"
|
|
|
|
# NAME should be a short name of the command, 7 letters or fewer.
|
|
|
|
# If called with only a single argument, will print nothing in quiet mode.
|
|
|
|
quiet-command-run = $(if $(V),,$(if $2,printf " %-7s %s\n" $2 $3 && ))$1
|
|
|
|
quiet-@ = $(if $(V),,@)
|
|
|
|
quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
|
|
|
|
|
2019-08-07 22:35:23 +08:00
|
|
|
CROSS_CC_GUEST:=
|
|
|
|
DOCKER_IMAGE:=
|
2020-09-21 22:34:47 +08:00
|
|
|
|
|
|
|
-include tests/tcg/config-$(TARGET).mak
|
2018-04-06 18:08:37 +08:00
|
|
|
|
|
|
|
GUEST_BUILD=
|
2019-08-07 22:35:22 +08:00
|
|
|
TCG_MAKE=../Makefile.target
|
2019-08-07 22:35:23 +08:00
|
|
|
|
|
|
|
# We also need the Docker make rules to depend on
|
|
|
|
SKIP_DOCKER_BUILD=1
|
|
|
|
include $(SRC_PATH)/tests/docker/Makefile.include
|
|
|
|
|
2018-04-06 18:08:37 +08:00
|
|
|
# Support installed Cross Compilers
|
|
|
|
|
|
|
|
ifdef CROSS_CC_GUEST
|
|
|
|
|
|
|
|
.PHONY: cross-build-guest-tests
|
|
|
|
cross-build-guest-tests:
|
|
|
|
$(call quiet-command, \
|
2019-08-07 22:35:23 +08:00
|
|
|
(mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
|
|
|
|
$(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
|
2019-08-07 22:35:22 +08:00
|
|
|
SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
|
2019-08-07 22:35:23 +08:00
|
|
|
EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
|
|
|
|
"BUILD","$(TARGET) guest-tests with $(CROSS_CC_GUEST)")
|
2018-04-06 18:08:37 +08:00
|
|
|
|
|
|
|
GUEST_BUILD=cross-build-guest-tests
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Support building with Docker
|
|
|
|
|
|
|
|
ifneq ($(DOCKER_IMAGE),)
|
|
|
|
|
2019-09-04 17:07:17 +08:00
|
|
|
DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
|
2019-08-07 22:35:23 +08:00
|
|
|
--cc $(DOCKER_CROSS_CC_GUEST) \
|
2020-07-01 21:56:29 +08:00
|
|
|
-i qemu/$(DOCKER_IMAGE) \
|
2018-04-06 18:08:37 +08:00
|
|
|
-s $(SRC_PATH) -- "
|
|
|
|
|
|
|
|
.PHONY: docker-build-guest-tests
|
2019-08-07 22:35:22 +08:00
|
|
|
docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
|
2018-04-06 18:08:37 +08:00
|
|
|
$(call quiet-command, \
|
2019-08-07 22:35:23 +08:00
|
|
|
(mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
|
|
|
|
$(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
|
2019-08-07 22:35:22 +08:00
|
|
|
SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
|
2019-08-07 22:35:23 +08:00
|
|
|
EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
|
2020-07-01 21:56:29 +08:00
|
|
|
"BUILD","$(TARGET) guest-tests with docker qemu/$(DOCKER_IMAGE)")
|
2018-04-06 18:08:37 +08:00
|
|
|
|
|
|
|
GUEST_BUILD=docker-build-guest-tests
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Final targets
|
2019-08-07 22:35:22 +08:00
|
|
|
all:
|
|
|
|
@echo "Do not invoke this Makefile directly"; exit 1
|
|
|
|
|
2018-04-06 18:08:37 +08:00
|
|
|
.PHONY: guest-tests
|
|
|
|
|
|
|
|
ifneq ($(GUEST_BUILD),)
|
|
|
|
guest-tests: $(GUEST_BUILD)
|
|
|
|
|
2019-08-07 22:35:22 +08:00
|
|
|
run-guest-tests: guest-tests
|
2018-04-06 18:08:37 +08:00
|
|
|
$(call quiet-command, \
|
2019-08-07 22:35:23 +08:00
|
|
|
(cd tests/tcg/$(TARGET) && \
|
|
|
|
$(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" \
|
2019-08-07 22:35:22 +08:00
|
|
|
SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
|
2018-04-06 18:08:37 +08:00
|
|
|
"RUN", "tests for $(TARGET_NAME)")
|
|
|
|
|
|
|
|
else
|
|
|
|
guest-tests:
|
2021-02-02 21:39:56 +08:00
|
|
|
$(call quiet-command, true, "BUILD", \
|
2019-08-07 22:35:23 +08:00
|
|
|
"$(TARGET) guest-tests SKIPPED")
|
2018-04-06 18:08:37 +08:00
|
|
|
|
|
|
|
run-guest-tests:
|
2021-02-02 21:39:56 +08:00
|
|
|
$(call quiet-command, true, "RUN", \
|
2019-08-07 22:35:23 +08:00
|
|
|
"tests for $(TARGET) SKIPPED")
|
2018-04-06 18:08:37 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# It doesn't matter if these don't exits
|
|
|
|
.PHONY: clean-guest-tests
|
|
|
|
clean-guest-tests:
|
2019-08-07 22:35:23 +08:00
|
|
|
rm -rf tests/tcg/$(TARGET)
|