-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (64 loc) · 2.32 KB
/
Makefile
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
default: build/universal-robots
# format the source code
format:
ls src/*.*pp main.cpp | xargs clang-format-15 -i --style=file
build:
mkdir build logs
SANITIZE ?= OFF
build/universal-robots: format build
cd build && \
cmake -G Ninja -DENABLE_SANITIZER=$(SANITIZE) .. && \
ninja all -j 4
clean:
rm -rf build logs
clean-all:
git clean -fxd
# Docker
BUILD_CMD = docker buildx build --pull $(BUILD_PUSH) --force-rm --build-arg MAIN_TAG=$(MAIN_TAG) \
--build-arg BASE_TAG=$(BUILD_TAG) --platform linux/$(BUILD_TAG) -f $(BUILD_FILE) -t '$(MAIN_TAG):$(BUILD_TAG)' .
BUILD_PUSH = --load
BUILD_FILE = Dockerfile
docker: docker-build docker-upload
docker-build: docker-amd64
docker-amd64: MAIN_TAG = ghcr.io/viam-modules/universal-robots
docker-amd64: BUILD_TAG = amd64
docker-amd64:
$(BUILD_CMD)
docker-upload:
docker push 'ghcr.io/viam-modules/universal-robots:amd64'
# CI targets that automatically push, avoid for local test-first-then-push workflows
docker-arm64-ci: MAIN_TAG = ghcr.io/viam-modules/universal-robots
docker-arm64-ci: BUILD_TAG = arm64
docker-arm64-ci: BUILD_PUSH = --push
docker-arm64-ci:
$(BUILD_CMD)
docker-amd64-ci: MAIN_TAG = ghcr.io/viam-modules/universal-robots
docker-amd64-ci: BUILD_TAG = amd64
docker-amd64-ci: BUILD_PUSH = --push
docker-amd64-ci:
$(BUILD_CMD)
# Define a function for building AppImages
TAG_VERSION?=latest
define BUILD_APPIMAGE
export TAG_NAME=$(TAG_VERSION); \
cd packaging/appimages && \
mkdir -p deploy && \
rm -f deploy/*$(2)* && \
appimage-builder --recipe $(1)-$(2).yml
endef
# Targets for building AppImages
appimage-arm64: export OUTPUT_NAME = universal-robots
appimage-arm64: export ARCH = aarch64
appimage-arm64: build/universal-robots
$(call BUILD_APPIMAGE,$(OUTPUT_NAME),$(ARCH))
mv ./packaging/appimages/$(OUTPUT_NAME)-*-$(ARCH).AppImage* ./packaging/appimages/deploy/
appimage-amd64: export OUTPUT_NAME = universal-robots
appimage-amd64: export ARCH = x86_64
appimage-amd64: build/universal-robots
$(call BUILD_APPIMAGE,$(OUTPUT_NAME),$(ARCH))
mv ./packaging/appimages/$(OUTPUT_NAME)-*-$(ARCH).AppImage* ./packaging/appimages/deploy/
appimages: appimage-amd64 appimage-arm64
.PHONY: module.tar.gz
module.tar.gz: meta.json run.sh
cp ./packaging/appimages/deploy/universal-robots-latest-$(ARCH).AppImage universal-robots.AppImage
tar czf $@ $^ universal-robots.AppImage