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