-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.mk
121 lines (106 loc) · 4.3 KB
/
utils.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
BULLSEYE_32_IMAGE = balenalib/raspberry-pi:bullseye-run-20240508
BULLSEYE_64_IMAGE = balenalib/raspberrypi3-64:bullseye-run-20240429
BOOKWORM_32_IMAGE = balenalib/raspberry-pi:bookworm-run-20240527
BOOKWORM_64_IMAGE = balenalib/raspberrypi3-64:bookworm-run-20240429
help:
@echo "usage: make [action]"
@echo ""
@echo "available actions:"
@echo ""
@echo " build build binaries for all architectures"
@echo " build_32 build binaries for 32-bit architectures"
@echo " build_64 build binaries for 64-bit architectures"
@echo " test_bullseye_32 test binaries on Raspberry Pi OS Bullseye 32-bit"
@echo " test_bullseye_64 test binaries on Raspberry Pi OS Bullseye 64-bit"
@echo " test_bookworm_32 test binaries on Raspberry Pi OS Bookworm 32-bit"
@echo " test_bookworm_64 test binaries on Raspberry Pi OS Bookworm 64-bit"
@echo ""
build: build_32 build_64
enable_multiarch:
docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes
define DOCKERFILE_BUILD_32
FROM multiarch/qemu-user-static:x86_64-arm AS qemu
FROM $(BULLSEYE_32_IMAGE) AS build
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
RUN apt update && apt install -y --no-install-recommends \
g++ \
xxd \
wget \
git \
cmake \
meson \
pkg-config \
python3-jinja2 \
python3-yaml \
python3-ply
WORKDIR /s
COPY . .
RUN meson setup build && DESTDIR=./prefix ninja -C build install
endef
export DOCKERFILE_BUILD_32
build_32: enable_multiarch
echo "$$DOCKERFILE_BUILD_32" | docker build . -f - -t build32
mkdir -p build
docker run --rm -v $(PWD):/o build32 sh -c "rm -rf /o/build/mtxrpicam_32 && mv /s/build/mtxrpicam_32 /o/build/"
define DOCKERFILE_BUILD_64
FROM multiarch/qemu-user-static:x86_64-aarch64 AS qemu
FROM $(BULLSEYE_64_IMAGE) AS build
COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static
RUN apt update && apt install -y --no-install-recommends \
g++ \
make \
xxd \
wget \
git \
cmake \
meson \
patch \
pkg-config \
python3-jinja2 \
python3-yaml \
python3-ply
WORKDIR /s
COPY . .
RUN meson setup build && DESTDIR=./prefix ninja -C build install
endef
export DOCKERFILE_BUILD_64
build_64: enable_multiarch
echo "$$DOCKERFILE_BUILD_64" | docker build . -f - -t build64
mkdir -p build
docker run --rm -v $(PWD):/o build64 sh -c "rm -rf /o/build/mtxrpicam_64 && mv /s/build/mtxrpicam_64 /o/build/"
define DOCKERFILE_TEST_BULLSEYE_32
FROM multiarch/qemu-user-static:x86_64-arm AS qemu
FROM $(BULLSEYE_32_IMAGE) AS build
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
endef
export DOCKERFILE_TEST_BULLSEYE_32
test_bullseye_32: enable_multiarch
echo "$$DOCKERFILE_TEST_BULLSEYE_32" | docker build . -f - -t test_bullseye_32
docker run --rm --platform=linux/arm/v6 -v $(PWD):/s -w /s/build/mtxrpicam_32 test_bullseye_32 bash -c "LD_LIBRARY_PATH=. TEST=1 ./mtxrpicam"
define DOCKERFILE_TEST_BULLSEYE_64
FROM multiarch/qemu-user-static:x86_64-aarch64 AS qemu
FROM $(BULLSEYE_64_IMAGE) AS build
COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static
endef
export DOCKERFILE_TEST_BULLSEYE_64
test_bullseye_64: enable_multiarch
echo "$$DOCKERFILE_TEST_BULLSEYE_64" | docker build . -f - -t test_bullseye_64
docker run --rm --platform=linux/arm64/v8 -v $(PWD):/s -w /s/build/mtxrpicam_64 test_bullseye_64 bash -c "LD_LIBRARY_PATH=. TEST=1 ./mtxrpicam"
define DOCKERFILE_TEST_BOOKWORM_32
FROM multiarch/qemu-user-static:x86_64-arm AS qemu
FROM $(BOOKWORM_32_IMAGE) AS build
COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
endef
export DOCKERFILE_TEST_BOOKWORM_32
test_bookworm_32: enable_multiarch
echo "$$DOCKERFILE_TEST_BOOKWORM_32" | docker build . -f - -t test_bookworm_32
docker run --rm --platform=linux/arm/v6 -v $(PWD):/s -w /s/build/mtxrpicam_32 test_bookworm_32 bash -c "LD_LIBRARY_PATH=. TEST=1 ./mtxrpicam"
define DOCKERFILE_TEST_BOOKWORM_64
FROM multiarch/qemu-user-static:x86_64-aarch64 AS qemu
FROM $(BOOKWORM_64_IMAGE) AS build
COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static
endef
export DOCKERFILE_TEST_BOOKWORM_64
test_bookworm_64: enable_multiarch
echo "$$DOCKERFILE_TEST_BOOKWORM_64" | docker build . -f - -t test_bookworm_64
docker run --rm --platform=linux/arm64/v8 -v $(PWD):/s -w /s/build/mtxrpicam_64 test_bookworm_64 bash -c "LD_LIBRARY_PATH=. TEST=1 ./mtxrpicam"