-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
88 lines (75 loc) · 2.31 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
82
83
84
85
86
87
88
IMAGE_NAME=android
-include $(FLAVOUR)/.env
.PHONY: help
help:
@echo "Android Docker image builder"
@echo "Available flavours: sdk, tools, ndk"
@echo ""
@echo "Usage:"
@echo " [FLAVOUR=flavour] make env: Update versions in .env"
@echo " [FLAVOUR=flavour] make build: Build Docker image"
@echo " [FLAVOUR=flavour] make test: Runs Docker image tests"
@echo " [FLAVOUR=flavour] make clean: Kills and deletes all instances of Docker image"
@echo " [FLAVOUR=flavour DOCKER_REGISTRY=registry] make push: Push the Docker image registry"
@echo ""
# Make env rules
env:
ifdef FLAVOUR
sh "$(FLAVOUR)/update_env.sh" > "$(FLAVOUR)/.env"
else
# We need the base image to be built before the rest
(export FLAVOUR=sdk; rm -f "sdk/.env" && make env && make build)
(export FLAVOUR=tools; rm -f "tools/.env" && make env)
(export FLAVOUR=ndk; rm -f "ndk/.env" && make env)
endif
build:
ifdef FLAVOUR
docker build $(FLAVOUR) \
$(DOCKER_BUILD_OPTS) \
--build-arg ANDROID_SDK_VERSION="$(ANDROID_SDK_VERSION)" \
--build-arg BUILD_TOOLS_VERSION="$(BUILD_TOOLS_VERSION)" \
--build-arg PLATFORM_VERSION="$(PLATFORM_VERSION)" \
--build-arg NDK_VERSION="$(NDK_VERSION)" \
--build-arg CMAKE_VERSION="$(CMAKE_VERSION)" \
--tag "$(IMAGE_NAME):$(FLAVOUR)" \
--tag "$(IMAGE_NAME):$(IMAGE_VERSION)"
else
FLAVOUR=sdk make build
FLAVOUR=tools make build
FLAVOUR=ndk make build
docker tag $(IMAGE_NAME):sdk $(IMAGE_NAME):latest
endif
test:
ifdef FLAVOUR
$(FLAVOUR)/test.sh
else
FLAVOUR=sdk make test
FLAVOUR=tools make test
FLAVOUR=ndk make test
test.sh
endif
clean:
ifdef FLAVOUR
rm -f $(FLAVOUR)/.env
docker rmi -f "$(IMAGE_NAME):$(FLAVOUR)" || true
docker rmi -f "$(IMAGE_NAME):$(IMAGE_VERSION)" || true
else
FLAVOUR=sdk make clean
FLAVOUR=tools make clean
FLAVOUR=ndk make clean
docker rmi -f "$(IMAGE_NAME):latest" || true
docker system prune -af
endif
push:
ifndef FLAVOUR
@echo "FLAVOUR env variable required for push"
exit 1
endif
ifndef DOCKER_REGISTRY
@echo "DOCKER_REGISTRY env variable required for push"
exit 1
endif
docker tag "$(IMAGE_NAME):$(FLAVOUR)" "$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(FLAVOUR)"
docker tag "$(IMAGE_NAME):$(FLAVOUR)" "$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION)"
docker push "$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(FLAVOUR)"
docker push "$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION)"