-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
61 lines (51 loc) · 1.52 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
# This file is just a porcelaine for devbox commands.
# Devbox is a tool to manage development environment dependencies.
# See https://www.jetpack.io/devbox for more information.
# You can install devbox with the following command:
# make bootstrap
# It also installs direnv to automatically load devbox environment.
# If you don't want to use devbox, you can use a containerized version of devbox
# with all the necessary dependencies. To do so, you need to install docker (or podman, etc)
# and run the targets with DOCKER=1 prefix. For example:
# make DOCKER=1 build
bootstrap:
curl -fsSL https://get.jetpack.io/devbox | bash
curl -sfL https://direnv.net/install.sh | bash
.PHONY: format
ifndef DOCKER
format: check_devbox
devbox run format
else
format: $(DOCKER_BUILDER)
$(call docker_builder_devbox,run format)
endif
.PHONY: build
ifndef DOCKER
build: check_devbox
devbox run build
else
build: $(DOCKER_BUILDER)
$(call docker_builder_devbox,run build)
endif
.PHONY: generate
ifndef DOCKER
generate: check_devbox
devbox run generate
else
generate: $(DOCKER_BUILDER)
$(call docker_builder_devbox,run generate)
endif
check_%:
@command -v $* >/dev/null || (echo "missing required tool $*" ; false)
CMD_DOCKER ?= docker
DOCKER_BUILDER ?= parca-dev/testdata-builder
.PHONY: $(DOCKER_BUILDER)
$(DOCKER_BUILDER): Dockerfile | check_$(CMD_DOCKER)
$(CMD_DOCKER) build -t $(DOCKER_BUILDER):latest .
define docker_builder_devbox
$(CMD_DOCKER) run --rm \
-w /code \
-v $(PWD):/code \
--entrypoint devbox \
$(DOCKER_BUILDER) $(1)
endef