anki/rspy/Makefile

99 lines
2.4 KiB
Makefile
Raw Normal View History

SHELL := /bin/bash
ifndef SHELLFLAGS
SHELLFLAGS :=
endif
.SHELLFLAGS := -eu -o pipefail ${SHELLFLAGS} -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
ifndef OS
OS := unknown
endif
ifeq (${OS},Windows_NT)
ifndef PYTHON_FILE
PYTHON_FILE := $(shell which python)
USE_CYGPATH_COMMAND := case "$$(uname -s)" in CYGWIN*|MINGW*|MSYS*) printf "yes";; esac;
USE_CYGPATH := $(shell ${USE_CYGPATH_COMMAND})
ifneq (,${USE_CYGPATH})
PYTHON_FILE := $(shell cygpath -w "${PYTHON_FILE}")
endif
endif
else
ifndef PYTHON_FILE
PYTHON_FILE := $(shell which python3)
endif
endif
.DELETE_ON_ERROR:
2020-01-03 05:32:26 +01:00
$(shell mkdir -p .build ../dist)
2020-01-03 05:32:26 +01:00
OUTDIR := ../dist
BUILDFLAGS := --release --strip
2020-03-06 00:33:53 +01:00
DEVFLAGS :=
RSPY_TARGET_DIR ?= target
QT_FTL_TEMPLATES := ../qt/ftl
QT_FTL_LOCALES := ../qt/ftl/repo/desktop
2020-02-23 09:00:13 +01:00
.PHONY: all develop build check fix clean
all: develop
2020-02-23 09:00:13 +01:00
develop: .build/develop
DEPS := .build/tools .build/vernum ../meta/buildhash \
$(wildcard $(QT_FTL_TEMPLATES)/*.ftl) \
$(wildcard $(QT_FTL_LOCALES)/*/*.ftl) \
$(shell "${FIND}" ../rslib/src -name '*.rs') $(wildcard ../proto/*) \
$(shell "${FIND}" ../rslib/ftl -type f) \
$(shell "${FIND}" ./src -type f)
.build/develop: $(DEPS)
2020-02-23 09:00:13 +01:00
touch ../proto/backend.proto
FTL_TEMPLATE_DIRS="$(QT_FTL_TEMPLATES)" FTL_LOCALE_DIRS="$(QT_FTL_LOCALES)" \
2020-03-06 00:33:53 +01:00
CARGO_TARGET_DIR="$(RSPY_TARGET_DIR)" maturin develop $(DEVFLAGS)
2020-02-23 09:00:13 +01:00
touch $@
2020-04-07 02:56:41 +02:00
build: .build/build
.build/build: $(DEPS)
2020-02-23 09:00:13 +01:00
touch ../proto/backend.proto
FTL_TEMPLATE_DIRS="$(QT_FTL_TEMPLATES)" FTL_LOCALE_DIRS="$(QT_FTL_LOCALES)" \
CARGO_TARGET_DIR="$(RSPY_TARGET_DIR)" maturin build -i "${PYTHON_FILE}" -o "$(OUTDIR)" $(BUILDFLAGS)
2020-04-07 02:56:41 +02:00
touch $@
check: .build/check
fix:
cargo fmt
clean:
rm -rf .build target
# nightly currently required for ignoring files in rustfmt.toml
RUST_TOOLCHAIN := $(shell cat rust-toolchain)
.build/tools: requirements.txt rust-toolchain
python -m pip install -r requirements.txt
rustup toolchain install $(RUST_TOOLCHAIN)
rustup component add rustfmt-preview --toolchain $(RUST_TOOLCHAIN)
rustup component add clippy-preview --toolchain $(RUST_TOOLCHAIN)
@touch $@
.build/check: build
cargo fmt -- --check
cargo clippy -- -D warnings
@touch $@
VER := $(shell cat ../meta/version)
.build/vernum: ../meta/version
sed -i.bak 's/.*automatically updated.*/version = "$(VER)" # automatically updated/' Cargo.toml
2020-01-03 07:02:06 +01:00
rm Cargo.toml.bak
@touch $@