forked from rabbitmq/tgir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
200 lines (175 loc) · 4.41 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
SHELL := bash# we want bash behaviour in all shell invocations
PLATFORM := $(shell uname)
#
# https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
RED := \033[1;31m
GREEN := \033[1;32m
YELLOW := \033[1;33m
BOLD := \033[1m
NORMAL := \033[0m
XDG_CONFIG_HOME := $(CURDIR)/.config
export XDG_CONFIG_HOME
### DEPS ###
#
ifeq ($(PLATFORM),Darwin)
DOCKER ?= /usr/local/bin/docker
COMPOSE ?= $(DOCKER)-compose
$(DOCKER) $(COMPOSE):
brew cask install docker
else
DOCKER ?= /usr/bin/docker
$(DOCKER):
$(error Please install docker: https://docs.docker.com/install/linux/docker-ce/ubuntu/)
COMPOSE ?= $(DOCKER)-compose
$(COMPOSE):
$(error Please install docker-compose: https://docs.docker.com/compose/install/)
endif
ifeq ($(PLATFORM),Darwin)
FFMPEG := /usr/local/bin/ffmpeg
$(FFMPEG):
brew install ffmpeg
else
FFMPEG ?= /usr/bin/ffmpeg
$(FFMPEG):
$(error Please install ffmpeg)
endif
CURL ?= /usr/bin/curl
ifneq ($(PLATFORM),Darwin)
$(CURL):
$(error Please install curl)
endif
ifeq ($(PLATFORM),Darwin)
OPEN := open
else
OPEN := xdg-open
endif
ifeq ($(PLATFORM),Darwin)
GCLOUD := /usr/local/bin/gcloud
$(GCLOUD):
brew cask install google-cloud-sdk
else
GCLOUD ?= /usr/bin/gcloud
$(GCLOUD):
$(error Please install gcloud: https://cloud.google.com/sdk/docs/downloads-apt-get)
endif
ifeq ($(PLATFORM),Darwin)
YQ ?= /usr/local/bin/yq
$(YQ):
brew install yq
else
YQ ?= /usr/bin/yq
$(YQ):
$(error Please install yq: https://github.com/mikefarah/yq#install)
endif
.PHONY: yq
yq: $(YQ)
ifeq ($(PLATFORM),Darwin)
BAT ?= /usr/local/bin/bat
$(BAT):
brew install bat
else
BAT ?= /usr/bin/bat
$(BAT):
$(error Please install bat: https://github.com/sharkdp/bat)
endif
.PHONY: bat
bat: $(BAT)
ifeq ($(PLATFORM),Darwin)
K9S ?= /usr/local/bin/k9s
$(K9S):
brew install derailed/k9s/k9s
else
K9S ?= /usr/bin/k9s
$(K9S):
$(error Please install k9s: https://github.com/derailed/k9s#installation)
endif
ifeq ($(PLATFORM),Darwin)
# Do not use kubectl installed by Docker for Desktop, this will typically be an older version than kubernetes-cli
# Use the latest installed kubernetes-cli
KUBECTL ?= $(lastword $(wildcard /usr/local/Cellar/kubernetes-cli/*/bin/kubectl))
$(KUBECTL):
brew install kubernetes-cli
else
KUBECTL ?= /usr/bin/kubectl
$(KUBECTL):
$(error Please install kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl)
endif
.PHONY: kubectl
kubectl: $(KUBECTL)
### TARGETS ###
#
.DEFAULT_GOAL = help
.PHONY: help
help:
@awk -F':+ |##' '/^[^\.][0-9a-zA-Z\._\-%]+:+.+##.+$$/ { printf "\033[36m%-26s\033[0m %s\n", $$1, $$3 }' $(MAKEFILE_LIST) \
| sort
define MAKE_TARGETS
awk -F':+' '/^[^\.%\t\_][0-9a-zA-Z\._\-\%]*:+.*$$/ { printf "%s\n", $$1 }' $(MAKEFILE_LIST)
endef
define BASH_AUTOCOMPLETE
complete -W \"$$($(MAKE_TARGETS) | sort | uniq)\" make gmake m
endef
.PHONY: bash-autocomplete
bash-autocomplete:
@echo "$(BASH_AUTOCOMPLETE)"
.PHONY: bac
bac: bash-autocomplete
ifneq ($(GITHUB_USER),)
GRIP_USER := --user $(GITHUB_USER)
endif
ifneq ($(GITHUB_PERSONAL_ACCESS_TOKEN),)
GRIP_PASS := --pass $(GITHUB_PERSONAL_ACCESS_TOKEN)
endif
.PHONY: readme
readme: $(DOCKER)
$(DOCKER) run --interactive --tty --rm \
--volume $(CURDIR):/data \
--volume $(HOME)/.grip:/.grip \
--expose 5000 --publish 5000:5000 \
--name readme \
mbentley/grip --context=. 0.0.0.0:5000 $(GRIP_USER) $(GRIP_PASS)
# https://www.bugcodemaster.com/article/convert-video-animated-gif-using-ffmpeg
# https://trac.ffmpeg.org/wiki/Scaling
.PHONY: gif
gif: $(FFMPEG)
ifndef MP4
$(error MP4 variable must reference a valid mov file path)
endif
time $(FFMPEG) -i $(MP4) \
-hide_banner \
-vf "fps=1" \
$(subst .mp4,-1fps.gif,$(MP4))
.env:
ln -sf ../../.env .env
.PHONY: env
env::
@true
FPS ?= 30
FFMPEG_VF = -vf "fps=$(FPS)
MP4_APPEND = -$(FPS)fps
# Scale for videos, use in SCALE=
1080p = scale='min(1920,iw)':'min(1080,ih)'
720p = scale='min(1280,iw)':'min(720,ih)'
ifneq ($($(SCALE)),)
FFMPEG_VF := $(FFMPEG_VF),$($(SCALE))
MP4_APPEND := -$(SCALE)$(MP4_APPEND)
endif
FFMPEG_VF := $(FFMPEG_VF)"
.PHONY: mp4
mp4: $(FFMPEG)
ifndef MOV
$(error MOV variable must reference a valid mov file path)
endif
time $(FFMPEG) -i $(MOV) \
-vcodec h264 $(FFMPEG_VF) \
$(subst .mov,$(MP4_APPEND).mp4,$(MOV))
.PHONY: mp4-concat
mp4-concat: $(FFMPEG)
ifndef DIR
$(error DIR variable must reference the dir where multiple mp4 files are stored)
endif
$(FFMPEG) -f concat \
-safe 0 \
-i <(for f in $(DIR)/*.mp4; do echo "file '$$f'"; done) \
-c copy \
$(DIR)/concat.mp4