-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
142 lines (116 loc) · 3.1 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
#
# Directories
#
WORKDIR ?= $(CURDIR)
#
# Parameters
#
KRAFT_TOKEN ?=
#
# General configuration
#
REG ?= ghcr.io
ORG ?= project-flexos
EXPS ?= fig-06_nginx-redis-perm \
fig-07_nginx-redis-normalized \
fig-08_config-poset \
fig-09_iperf-throughput \
fig-10_sqlite-exec-time \
fig-11_flexos-alloc-latency \
tab-01_porting-effort
IMAGES ?= flexos-base \
nginx \
redis \
flexos-ae-plot \
flexos-ae-base
TARGETS ?= prepare \
run \
plot \
clean \
properclean
ifeq ($(KRAFT_TOKEN),)
define ERROR_MISSING_TOKEN
<!> Missing `KRAFT_TOKEN` environmental variable <!>
This variable is used to connect the command-line utility `kraft` to the GitHub
API and download additional Unikraft repositories. To generate a new token,
go to https://github.com/settings/tokens/new and select permission:
- repo:public_repo
Once you have generated this token, simply export it in your command-line, like
so:
$$ export KRAFT_TOKEN=ghp_...
Once this is done, please re-run your command:
$$ $(MAKE) $(MAKECMDGOALS)
endef
$(error $(ERROR_MISSING_TOKEN))
endif
#
# Utility vars
#
# Prefix each docker image with `docker-` so it has a unique phony target
DIMAGES := $(addprefix docker-,$(IMAGES))
Q ?= @
#
# Tools
#
DOCKER ?= docker
CURL ?= curl
#
# Find shortname for experiment
#
# Params:
# $1: The canonical name of the experiment, e.g. `fig-XX_short-desc`
# $2: The desired returning element, 1 for `fig-XX` and 2 for `short-desc`
#
underscore = $(word $(2),$(subst _, ,$(1)))
#
# Create a new experiment target
#
# Params:
# $1: The common API target, e.g. `prepare`
# $2: The canonical name of the experiment, e.g. `fig-XX_short-name`
#
define create-exp-target
.PHONY: $(1)
$(1): $(1)-$(2)
.PHONY: $(2)
$(2): $(1)
.PHONY: $(1)-$(2)
$$(call underscore,$(2),1): $(1)-$(2)
$(1)-$$(call underscore,$(2),1): $(1)-$(2)
$(1)-$(2):
$(Q)$(MAKE) -C $(WORKDIR)/experiments/$(2) $(1)
endef
#
# Targets
#
.PHONY: all
all: prepare run plot
.PHONY: prepare
prepare: docker
# Iterate over all experiments and all targets and provide an entrypoint for
# each, e.g. `prepare-fig-XX_short-desc` and `prepare-fig-XX`.
$(foreach EXP,$(EXPS), \
$(foreach TARGET,$(TARGETS),$(eval $(call create-exp-target,$(TARGET),$(EXP))) \
))
.PHONY: docker
docker: $(DIMAGES)
.PHONY: $(DIMAGES)
$(DIMAGES): TAG ?= latest
$(DIMAGES):
$(Q)$(DOCKER) build \
--tag $(REG)/$(ORG)/$(@:docker-%=%):$(TAG) \
--build-arg UK_KRAFT_GITHUB_TOKEN="$(KRAFT_TOKEN)" \
--file $(WORKDIR)/support/dockerfiles/Dockerfile.$(@:docker-%=%) \
$(WORKDIR)/support
# Prepare the final Zenodo archive
zenodo:
mkdir -p $(WORKDIR)/repositories
# clone all repos in the flexos organization
cd $(WORKDIR)/repositories && \
$(CURL) -s https://github.com:@api.github.com/orgs/${ORG}/repos?per_page=200 | \
jq .[].ssh_url | xargs -n 1 git clone
# remove this one otherwise we'd be duplicate
rm -rf repositories/asplos22-ae
tar -czf $(WORKDIR)/../flexos-asplos22-ae.tar.gz $(WORKDIR)
dependencies: docker
apt install time jq