yartsu/Makefile

115 lines
3 KiB
Makefile
Raw Normal View History

SRC_FILES := $(wildcard yartsu/*)
VERSION := $(shell pdm show | grep "Installed" | awk -F ":" 'gsub(/ /, ""){print $$2}')
2022-06-14 18:35:47 -05:00
2022-06-25 18:34:56 -05:00
.PHONY: lint typecheck build format
2022-06-15 13:38:45 -05:00
2022-06-25 18:34:56 -05:00
## apply formatting, linting and typechecking (default)
check: lint typecheck
2022-06-14 18:35:47 -05:00
2022-06-25 18:34:56 -05:00
## perform typechecking
typcheck:
2022-06-14 18:35:47 -05:00
pdm run mypy yartsu
2022-06-25 18:34:56 -05:00
## format/lint with pre-commit(black,isort,flake8)
lint:
2022-06-14 18:35:47 -05:00
pdm run pre-commit run --all
2022-06-25 18:34:56 -05:00
.PHONY: dist release release.assets dist build
2022-06-16 01:47:31 -05:00
2022-06-25 18:34:56 -05:00
release.assets: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu check-version
tar czf build/yartsu-$(VERSION)-x86_64-linux.tar.gz \
build/x86_64-unknown-linux-gnu/release/install/yartsu
2022-06-25 18:34:56 -05:00
## create github release and attach gzipped binary
2022-06-16 01:29:10 -05:00
release: check-tag release-assets
gh release create $(TAG) build/yartsu-$(VERSION)-x86_64-linux.tar.gz -p -d
2022-06-15 13:38:45 -05:00
2022-06-25 18:34:56 -05:00
## publish to pypi with twine
2022-06-16 01:52:53 -05:00
publish: check-version dist
2022-06-15 13:38:45 -05:00
twine upload dist/*
2022-06-25 18:34:56 -05:00
## build wheel/targz with pdm
2022-06-15 13:38:45 -05:00
dist:
pdm build
2022-06-25 18:34:56 -05:00
## build with pyoxidizer
build: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
2022-06-14 18:35:47 -05:00
build/shiv/yartsu: $(SRC_FILES)
2022-06-25 18:34:56 -05:00
@echo "==> Building yartsu w/ shiv <=="
@mkdir -p build/shiv
@shiv \
-c yartsu \
-o ./build/shiv/yartsu \
--preamble scripts/preamble.py \
--reproducible \
.
build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu: $(SRC_FILES)
2022-06-25 18:34:56 -05:00
@echo "==> Building yartsu w/ shiv <=="
@pdm install
@pyoxidizer build --release
.PHONY: install.bin install.shiv
## install pyoxidizer binary
install.bin: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
@echo "==> Installing yartsu to ~/bin <=="
@cp ./build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu ~/bin
2022-06-25 18:34:56 -05:00
## install shiv binary
install.shiv: build/shiv/yartsu
@echo "==> Installing yartsu to ~/bin <=="
@cp ./build/shiv/yartsu ~/bin
2022-06-14 18:35:47 -05:00
2022-06-25 18:34:56 -05:00
DOCS_RECIPES := $(patsubst %,docs.%,theme diff svg demo)
2022-06-14 18:35:47 -05:00
2022-06-25 18:34:56 -05:00
.PHONY: docs $(DOCS_RECIPES)
2022-06-25 18:34:56 -05:00
## generate docs/svg
docs: $(DOCS_RECIPES)
2022-06-14 18:35:47 -05:00
2022-06-25 18:34:56 -05:00
docs.theme:
@./scripts/theme-showcase-gen
2022-06-14 18:35:47 -05:00
2022-06-25 18:34:56 -05:00
docs.diff:
@./scripts/rich-diff > docs/rich-diff.md
2022-06-25 18:34:56 -05:00
docs.svg:
@lolcat -F .5 -S 9 -f assets/logo.txt | yartsu -o assets/logo.svg
@yartsu -o assets/help.svg -t "yartsu --help" -- yartsu -h
2022-06-14 18:35:47 -05:00
2022-06-25 18:34:56 -05:00
docs.demo:
@python -c \
2022-06-15 02:11:32 -05:00
"from rich.console import Console; \
console = Console(force_terminal=True); \
console.print('\n:snake: [b i]Emoji\'s!'); \
console.print(' [cyan]Nerd Fonts!');" | \
yartsu -w 25 -o assets/demo.svg
2022-06-25 18:34:56 -05:00
## cleanup build and loose files
2022-06-15 13:38:45 -05:00
clean:
2022-06-25 18:34:56 -05:00
@rm -rf build dist capture.svg
# conditionals
check-tag:
@[ "${TAG}" ] || ( echo ">> TAG is not set"; exit 1 )
@git describe HEAD --tags --exact-match
check-version:
@if [[ "${VERSION}" == *"+"* ]]; then \
echo ">> VERSION is dev"; \
echo ">> $(VERSION)"; \
exit 1; \
fi
.PHONY: help list
2022-06-15 02:11:32 -05:00
2022-06-25 18:34:56 -05:00
FILL = 15
## Display this help screen
help: ## try `make help`
@awk '/^[a-z.A-Z_-]+:/ { helpMessage = match(lastLine, /^##(.*)/); \
if (helpMessage) { helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); printf "\033[36m%-$(FILL)s\033[0m%s\n"\
, helpCommand, helpMessage;}} { lastLine = $$0 }' $(MAKEFILE_LIST)