2023-07-17 19:35:44 +00:00
|
|
|
SHELL = bash
|
2023-11-01 20:13:27 +00:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME), Linux)
|
2023-07-17 19:35:44 +00:00
|
|
|
CPU_CORES = $(shell N=$$(nproc); echo $$(( $$N > 4 ? 4 : $$N )))
|
2023-11-01 20:13:27 +00:00
|
|
|
else
|
|
|
|
CPU_CORES = $(shell N=$$(sysctl -n hw.physicalcpu); echo $$(( $$N > 4 ? 4 : $$N )))
|
|
|
|
endif
|
2023-07-17 19:35:44 +00:00
|
|
|
|
|
|
|
# Install
|
|
|
|
VENV = .venv
|
|
|
|
export POETRY_VIRTUALENVS_IN_PROJECT=true
|
|
|
|
|
|
|
|
$(VENV):
|
|
|
|
$(MAKE) install
|
|
|
|
|
|
|
|
install:
|
|
|
|
poetry install
|
|
|
|
poetry run pip install --no-deps --editable ../api
|
|
|
|
|
|
|
|
clean:
|
|
|
|
git clean -xdf .
|
|
|
|
|
|
|
|
# Sphinx
|
|
|
|
SPHINX_OPTS = -j $(CPU_CORES)
|
|
|
|
SOURCE_DIR = .
|
|
|
|
BUILD_DIR = _build
|
|
|
|
|
2023-11-01 13:15:49 +00:00
|
|
|
$(BUILD_DIR):
|
|
|
|
mkdir -p $(BUILD_DIR)
|
|
|
|
|
2023-07-17 19:35:44 +00:00
|
|
|
# Dev
|
|
|
|
dev: $(VENV)
|
2023-11-02 08:15:21 +00:00
|
|
|
poetry run sphinx-autobuild . /tmp/_build/ --port 8001
|
2023-07-17 19:35:44 +00:00
|
|
|
|
|
|
|
# I18n
|
|
|
|
LOCALES = en_GB en_US fr
|
|
|
|
|
|
|
|
locale-generate: $(VENV)
|
|
|
|
poetry run sphinx-build -b gettext $(SOURCE_DIR) locales/gettext $(SPHINX_OPTS)
|
|
|
|
|
|
|
|
locale-update: $(VENV)
|
|
|
|
poetry run sphinx-intl update -p locales/gettext $(foreach locale,$(LOCALES),-l $(locale))
|
|
|
|
|
|
|
|
locale-prune-untranslated: $(VENV)
|
|
|
|
poetry run _scripts/locale-prune-untranslated.py
|
|
|
|
|
|
|
|
# Swagger
|
|
|
|
SWAGGER_VERSION = 5.1.2
|
|
|
|
SWAGGER_RELEASE_URL = https://github.com/swagger-api/swagger-ui/archive/refs/tags/v$(SWAGGER_VERSION).tar.gz
|
|
|
|
SWAGGER_BUILD_DIR = swagger
|
|
|
|
|
|
|
|
swagger:
|
|
|
|
mkdir "$(SWAGGER_BUILD_DIR)"
|
|
|
|
curl -sSL "$(SWAGGER_RELEASE_URL)" | \
|
|
|
|
tar --extract \
|
|
|
|
--gzip \
|
|
|
|
--directory="$(SWAGGER_BUILD_DIR)" \
|
|
|
|
--strip-components=2 \
|
|
|
|
"swagger-ui-$(SWAGGER_VERSION)/dist"
|
|
|
|
|
|
|
|
sed -i \
|
|
|
|
"s#https://petstore.swagger.io/v2/swagger.json#schema.yml#g" \
|
|
|
|
"$(SWAGGER_BUILD_DIR)/swagger-initializer.js"
|
|
|
|
|
|
|
|
cp schema.yml "$(SWAGGER_BUILD_DIR)/schema.yml"
|
|
|
|
|
|
|
|
# Releases
|
2023-11-01 13:15:49 +00:00
|
|
|
$(BUILD_DIR)/releases.json: $(BUILD_DIR)
|
2023-07-17 19:35:44 +00:00
|
|
|
../scripts/releases.py > "$@"
|
|
|
|
|
2023-11-01 13:15:49 +00:00
|
|
|
$(BUILD_DIR)/latest.txt: $(BUILD_DIR)
|
2023-07-17 19:35:44 +00:00
|
|
|
../scripts/releases.py -r -q latest.id > "$@"
|
|
|
|
|
|
|
|
releases: $(BUILD_DIR)/releases.json $(BUILD_DIR)/latest.txt
|
|
|
|
|
|
|
|
# Build
|
|
|
|
build: $(VENV)
|
|
|
|
poetry run sphinx-build $(SOURCE_DIR) $(BUILD_DIR) $(SPHINX_OPTS)
|
|
|
|
|
|
|
|
build-translated: $(VENV) locale-prune-untranslated
|
|
|
|
for locale in $(LOCALES); do \
|
|
|
|
poetry run sphinx-build $(SOURCE_DIR) $(BUILD_DIR)/$$locale $(SPHINX_OPTS) -D language=$$locale; \
|
|
|
|
done
|
|
|
|
|
|
|
|
build-all: build build-translated releases swagger
|