forked from isovalent/ebpf-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (40 loc) · 2.06 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
# Obtain an absolute path to the directory of the Makefile.
# Assume the Makefile is in the root of the repository.
REPODIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
UIDGID := $(shell stat -c '%u:%g' ${REPODIR})
# Prefer podman if installed, otherwise use docker.
# Note: Setting the var at runtime will always override.
CONTAINER_ENGINE ?= $(if $(shell command -v podman), podman, docker)
CONTAINER_RUN_ARGS ?= $(if $(filter ${CONTAINER_ENGINE}, podman), --log-driver=none, --user "${UIDGID}")
IMAGE := ebpf-mkdocs
VERSION := latest
PROD := false
GH_TOKEN := ""
.DEFAULT_TARGET = build-container
.PHONY: build-container
build-container:
${CONTAINER_ENGINE} build -f ${REPODIR}/tools/Dockerfile \
--build-arg="UID=$$(id -u $${USER})" --build-arg="GID=$$(id -g $${USER})" -t ${IMAGE}:${VERSION} ${REPODIR}
.PHONY: container-shell
container-shell: build-container
${CONTAINER_ENGINE} run --rm -it -v "${REPODIR}:/docs" -e "GH_TOKEN=${GH_TOKEN}" -u $$(id -u $${USER}):$$(id -g $${USER}) -w /docs "${IMAGE}:${VERSION}"
.PHONY: html
html: build-container
${CONTAINER_ENGINE} run --rm -it -v "${REPODIR}:/docs" \
-e "PROD=${PROD}" -e "GH_TOKEN=${GH_TOKEN}" \
-w /docs -u $$(id -u $${USER}):$$(id -g $${USER}) --entrypoint "bash" "${IMAGE}:${VERSION}" -c "mkdocs build -d /docs/out"
.PHONY: clear-html
clear-html:
rm -r out/*
.PHONY: serve
serve: build-container
${CONTAINER_ENGINE} run --rm -it -p 8000:8000 -v "${REPODIR}:/docs" \
-e "PROD=${PROD}" -e "GH_TOKEN=${GH_TOKEN}" \
-w /docs -u $$(id -u $${USER}):$$(id -g $${USER}) --entrypoint "bash" "${IMAGE}:${VERSION}" -c "mkdocs serve -a 0.0.0.0:8000 --watch /docs/docs"
.PHONY: generate-docs
generate-docs:
cd ${REPODIR}/tools/helper-ref-gen; go run main.go --project-root "${REPODIR}"
cd ${REPODIR}/tools/feature-tag-gen; go run main.go --project-root "${REPODIR}"
cd ${REPODIR}/tools/kfunc-gen; go run main.go --project-root "${REPODIR}"
cd ${REPODIR}/tools/mtu-calc; go run . --project-root "${REPODIR}"
cd ${REPODIR}/tools/helper-def-scraper; go run main.go --helper-path "${REPODIR}/docs/linux/helper-function"