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
|
|
|
include $(SRC_PATH)/rules.mak
|
|
|
|
|
|
|
|
# The configure script fills in extra information about
|
2018-04-06 18:08:37 +08:00
|
|
|
# useful docker images or alternative compiler flags.
|
|
|
|
|
2019-08-07 22:35:23 +08:00
|
|
|
CROSS_CC_GUEST:=
|
|
|
|
DOCKER_IMAGE:=
|
|
|
|
-include $(BUILD_DIR)/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) \
|
2018-04-06 18:08:37 +08:00
|
|
|
-i qemu:$(DOCKER_IMAGE) \
|
|
|
|
-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)"), \
|
|
|
|
"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:
|
|
|
|
$(call quiet-command, /bin/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:
|
|
|
|
$(call quiet-command, /bin/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)
|