Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 1 | QUIET_TEST := @ |
| 2 | |
| 3 | include Makefile.targets |
| 4 | |
| 5 | CC := ccache cc |
| 6 | MAKECMD := make |
| 7 | MAKEARGS := CONFIG_EVERYTHING=yes |
| 8 | |
| 9 | spc := |
| 10 | spc := $(spc) $(spc) |
| 11 | |
| 12 | stem = $(word 1,$(subst :,$(spc),$(subst \:,$(spc),$(1)))) |
| 13 | ident = $(subst :,_,$(subst \:,_,$(1))) |
| 14 | |
| 15 | include Makefile.anita |
| 16 | |
| 17 | define build_template |
| 18 | Dockerfile.$(call ident,$(1)): Dockerfile.$(call stem,$(1)) mani-wrapper.sh |
| 19 | $(QUIET_SETUP)sed -e 's|^FROM manibase|FROM $(2)/$(1)|' $$< >$$@ |
| 20 | |
| 21 | .INTERMEDIATE: Dockerfile.$(call ident,$(1)) |
| 22 | |
| 23 | $(1)-build: Dockerfile.$(call ident,$(1)) |
Nico Huber | fb433ba | 2023-03-04 19:09:47 +0000 | [diff] [blame^] | 24 | $(QUIET_SETUP)docker build . -f $$< -t mani/$(1) --build-arg IDENT=$(call ident,$(1)) $$(DOCKER_BUILD_ARGS) |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 25 | endef |
| 26 | |
| 27 | $(foreach tag,$(MULTIARCH_TAGS), \ |
| 28 | $(eval $(call build_template,$(tag),multiarch))) |
| 29 | |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 30 | djgpp\:6.1.0-build: %-build: Dockerfile.djgpp mani-wrapper.sh |
Nico Huber | fb433ba | 2023-03-04 19:09:47 +0000 | [diff] [blame^] | 31 | $(QUIET_SETUP)docker build . -f $< -t mani/$* --build-arg IDENT=$(call ident,$*) |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 32 | |
Nico Huber | fb9c18a | 2022-12-10 23:59:19 +0100 | [diff] [blame] | 33 | git-check-build $(addsuffix -check-build,$(ALL_TAGS)): %-check-build: |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 34 | $(QUIET_SETUP)\ |
| 35 | [ $$(docker image ls -q mani/$*) ] \ |
| 36 | || $(MAKE) $*-build $(if $(QUIET_SETUP),>/dev/null 2>/dev/null) |
| 37 | |
| 38 | $(filter centos%,$(MULTIARCH_TAGS)) anita\:7.1-sparc: CC=cc |
| 39 | djgpp\:6.1.0: CC=ccache i586-pc-msdosdjgpp-gcc |
| 40 | djgpp\:6.1.0: STRIP=i586-pc-msdosdjgpp-strip |
| 41 | djgpp\:6.1.0: LIBS_BASE=../ |
| 42 | djgpp\:6.1.0: MAKEARGS+=strip CONFIG_JLINK_SPI=no |
| 43 | $(ANITA_TAGS): MAKECMD=gmake |
| 44 | $(ANITA_TAGS): MAKEARGS+=CONFIG_JLINK_SPI=no WARNERROR=no |
| 45 | $(filter alpine% centos%,$(MULTIARCH_TAGS)): MAKEARGS+=CONFIG_JLINK_SPI=no |
| 46 | $(filter %-xenial %-stretch,$(MULTIARCH_TAGS)): MAKEARGS+=CONFIG_JLINK_SPI=no |
| 47 | $(filter centos%,$(MULTIARCH_TAGS)): MAKEARGS+=WARNERROR=no |
| 48 | $(ALL_TAGS): export QUIET_SETUP=$(QUIET_TEST) |
Nico Huber | 725a19e | 2022-12-11 00:01:04 +0100 | [diff] [blame] | 49 | $(ALL_TAGS): export TEST_REMOTE?=$(if $(TEST_LOCAL),\ |
| 50 | git://mani-git/flashrom.git,\ |
| 51 | origin) |
Nico Huber | 25ea717 | 2023-03-03 17:06:30 +0000 | [diff] [blame] | 52 | $(ALL_TAGS): export TEST_REVISION?=$(if $(TEST_LOCAL),HEAD,main) |
Nico Huber | 725a19e | 2022-12-11 00:01:04 +0100 | [diff] [blame] | 53 | $(ALL_TAGS): %: %-check-build mani-net $(if $(TEST_LOCAL),local-git) |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 54 | $(QUIET_TEST)docker rm -f mani_$(call ident,$*) >/dev/null 2>&1 || true |
| 55 | $(QUIET_TEST)\ |
| 56 | docker run \ |
Nico Huber | 48b1fde | 2022-12-11 17:15:27 +0000 | [diff] [blame] | 57 | $(MANI_DOCKER_ARGS) \ |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 58 | --env IDENT=$(call ident,$*) \ |
Nico Huber | fb433ba | 2023-03-04 19:09:47 +0000 | [diff] [blame^] | 59 | --volume manicache:/ccache \ |
Nico Huber | bfe6484 | 2022-12-10 23:54:24 +0100 | [diff] [blame] | 60 | --network=manibuilder \ |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 61 | --name mani_$(call ident,$*) mani/$* \ |
Nico Huber | aa359a7 | 2022-12-10 23:52:46 +0100 | [diff] [blame] | 62 | "git fetch $(TEST_REMOTE) $(TEST_REVISION) && \ |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 63 | git checkout FETCH_HEAD && \ |
| 64 | $(MAKECMD) clean && $(MAKECMD) -j$${CPUS:-1} CC='$(CC)' \ |
| 65 | $(if $(STRIP),STRIP='$(STRIP)') \ |
| 66 | $(if $(LIBS_BASE),LIBS_BASE='$(LIBS_BASE)') \ |
| 67 | $(MAKEARGS)" \ |
Nico Huber | d4fbbb4 | 2022-12-11 17:02:57 +0000 | [diff] [blame] | 68 | $(if $(QUIET_TEST),>/dev/null 2>&1) \ |
| 69 | || { RET=$$?; echo $*: $${RET}; exit $${RET}; } |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 70 | |
| 71 | $(addsuffix -shell,$(ALL_TAGS)): %-shell: %-check-build |
| 72 | $(QUIET_SETUP)\ |
| 73 | if [ $$(docker ps -a -q -f name=mani_$(call ident,$*)) ]; then \ |
| 74 | docker commit mani_$(call ident,$*) mani_run/$* && \ |
| 75 | docker run --rm -it \ |
Nico Huber | 48b1fde | 2022-12-11 17:15:27 +0000 | [diff] [blame] | 76 | $(MANI_DOCKER_ARGS) \ |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 77 | --env IDENT=$(call ident,$*) \ |
Nico Huber | fb433ba | 2023-03-04 19:09:47 +0000 | [diff] [blame^] | 78 | --volume manicache:/ccache \ |
Nico Huber | bfe6484 | 2022-12-10 23:54:24 +0100 | [diff] [blame] | 79 | --network=manibuilder \ |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 80 | --entrypoint /bin/sh mani_run/$* \ |
| 81 | /home/mani/mani-wrapper.sh \ |
| 82 | $(patsubst %,"%",$(SHELL_ARG)); \ |
| 83 | docker image rm mani_run/$*; \ |
| 84 | else \ |
| 85 | docker run --rm -it \ |
Nico Huber | 48b1fde | 2022-12-11 17:15:27 +0000 | [diff] [blame] | 86 | $(MANI_DOCKER_ARGS) \ |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 87 | --env IDENT=$(call ident,$*) \ |
Nico Huber | fb433ba | 2023-03-04 19:09:47 +0000 | [diff] [blame^] | 88 | --volume manicache:/ccache \ |
Nico Huber | bfe6484 | 2022-12-10 23:54:24 +0100 | [diff] [blame] | 89 | --network=manibuilder \ |
Nico Huber | c0b52db | 2022-12-15 12:42:32 +0000 | [diff] [blame] | 90 | mani/$* $(patsubst %,"%",$(SHELL_ARG)); \ |
| 91 | fi |
| 92 | |
| 93 | .PHONY: $(foreach s,-build -check-build -shell, $(addsuffix $(s),$(ALL_TAGS))) |
| 94 | |
| 95 | register: |
| 96 | docker build . \ |
| 97 | -f Dockerfile.qemu-user-static \ |
| 98 | -t mani/qemu-user-static:register |
| 99 | docker run --rm --privileged mani/qemu-user-static:register --reset |
| 100 | |
Nico Huber | bfe6484 | 2022-12-10 23:54:24 +0100 | [diff] [blame] | 101 | mani-net: |
| 102 | $(QUIET_SETUP)\ |
| 103 | if [ -z "$$(docker network ls -qf name=manibuilder)" ]; then \ |
| 104 | docker network create manibuilder \ |
| 105 | $(if $(QUIET_SETUP),>/dev/null); \ |
| 106 | fi |
| 107 | |
Nico Huber | fb9c18a | 2022-12-10 23:59:19 +0100 | [diff] [blame] | 108 | git-build: Dockerfile.git |
| 109 | $(QUIET_SETUP)docker build . -f $< -t mani/git |
| 110 | |
| 111 | local-git: TEST_LOCAL_GIT:=$(abspath $(wildcard \ |
| 112 | $(TEST_LOCAL)$(if $(filter %.git,$(TEST_LOCAL)),,/.git))) |
| 113 | local-git: git-check-build mani-net |
| 114 | $(QUIET_SETUP)\ |
| 115 | if [ -z "$(TEST_LOCAL_GIT)" ]; then \ |
| 116 | echo '$${TEST_LOCAL} should point to a Git repository.'; \ |
| 117 | exit 1; \ |
| 118 | fi; \ |
| 119 | if [ -n "$$(docker container ls -qf name=mani-git)" ]; then \ |
| 120 | if docker inspect -f '{{ .Mounts }}' mani-git | \ |
| 121 | grep -q ' $(TEST_LOCAL_GIT) '; then \ |
| 122 | exit 0; \ |
| 123 | else \ |
| 124 | docker stop mani-git >/dev/null; \ |
| 125 | fi; \ |
| 126 | fi; \ |
| 127 | docker run --rm --detach \ |
| 128 | --name mani-git \ |
| 129 | --volume=$(TEST_LOCAL_GIT):/git/flashrom.git:ro \ |
| 130 | --network=manibuilder \ |
| 131 | mani/git $(if $(QUIET_SETUP),>/dev/null) |
| 132 | |
| 133 | .PHONY: register mani-net git-build local-git |