mirror of
https://github.com/daylinmorgan/yartsu.git
synced 2024-12-21 20:10:45 -06:00
build: update makefile
This commit is contained in:
parent
4a3d2cc76a
commit
ff7d561ed8
1 changed files with 93 additions and 65 deletions
158
Makefile
158
Makefile
|
@ -1,16 +1,97 @@
|
|||
SRC_FILES := $(wildcard yartsu/*)
|
||||
VERSION := $(shell pdm show | grep "Installed" | awk -F ":" 'gsub(/ /, ""){print $$2}')
|
||||
|
||||
.PHONY: list lint build typing format dist check-tag release-asset
|
||||
.PHONY: lint typecheck build format
|
||||
|
||||
lint: format typing
|
||||
## apply formatting, linting and typechecking (default)
|
||||
check: lint typecheck
|
||||
|
||||
typing:
|
||||
## perform typechecking
|
||||
typcheck:
|
||||
pdm run mypy yartsu
|
||||
|
||||
format:
|
||||
## format/lint with pre-commit(black,isort,flake8)
|
||||
lint:
|
||||
pdm run pre-commit run --all
|
||||
|
||||
.PHONY: dist release release.assets dist build
|
||||
|
||||
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
|
||||
|
||||
## create github release and attach gzipped binary
|
||||
release: check-tag release-assets
|
||||
gh release create $(TAG) build/yartsu-$(VERSION)-x86_64-linux.tar.gz -p -d
|
||||
|
||||
## publish to pypi with twine
|
||||
publish: check-version dist
|
||||
twine upload dist/*
|
||||
|
||||
## build wheel/targz with pdm
|
||||
dist:
|
||||
pdm build
|
||||
|
||||
## build with pyoxidizer
|
||||
build: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
|
||||
|
||||
build/shiv/yartsu: $(SRC_FILES)
|
||||
@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)
|
||||
@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
|
||||
|
||||
## install shiv binary
|
||||
install.shiv: build/shiv/yartsu
|
||||
@echo "==> Installing yartsu to ~/bin <=="
|
||||
@cp ./build/shiv/yartsu ~/bin
|
||||
|
||||
DOCS_RECIPES := $(patsubst %,docs.%,theme diff svg demo)
|
||||
|
||||
.PHONY: docs $(DOCS_RECIPES)
|
||||
|
||||
## generate docs/svg
|
||||
docs: $(DOCS_RECIPES)
|
||||
|
||||
docs.theme:
|
||||
@./scripts/theme-showcase-gen
|
||||
|
||||
docs.diff:
|
||||
@./scripts/rich-diff > docs/rich-diff.md
|
||||
|
||||
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
|
||||
|
||||
docs.demo:
|
||||
@python -c \
|
||||
"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
|
||||
|
||||
## cleanup build and loose files
|
||||
clean:
|
||||
@rm -rf build dist capture.svg
|
||||
|
||||
# conditionals
|
||||
check-tag:
|
||||
@[ "${TAG}" ] || ( echo ">> TAG is not set"; exit 1 )
|
||||
@git describe HEAD --tags --exact-match
|
||||
|
@ -22,65 +103,12 @@ check-version:
|
|||
exit 1; \
|
||||
fi
|
||||
|
||||
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
|
||||
.PHONY: help list
|
||||
|
||||
release: check-tag release-assets
|
||||
gh release create $(TAG) build/yartsu-$(VERSION)-x86_64-linux.tar.gz -p -d
|
||||
|
||||
publish: check-version dist
|
||||
twine upload dist/*
|
||||
|
||||
dist:
|
||||
pdm build
|
||||
|
||||
build: build/yartsu
|
||||
|
||||
build/shiv/yartsu: $(SRC_FILES)
|
||||
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)
|
||||
pdm install
|
||||
pyoxidizer build --release
|
||||
|
||||
install-bin: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
|
||||
cp ./build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu ~/bin
|
||||
|
||||
install-shiv: build/shiv/yartsu
|
||||
cp ./build/shiv/yartsu ~/bin
|
||||
|
||||
.PHONY: svg-docs theme-docs diff-docs demo-docs docs
|
||||
|
||||
docs: svg-docs theme-docs demo-docs diff-docs
|
||||
|
||||
theme-docs:
|
||||
./scripts/theme-showcase-gen
|
||||
|
||||
diff-docs:
|
||||
./scripts/rich-diff > docs/rich-diff.md
|
||||
|
||||
svg-docs:
|
||||
lolcat -F .5 -S 9 -f assets/logo.txt | yartsu -o assets/logo.svg
|
||||
yartsu -o assets/help.svg -t "yartsu --help" -- yartsu -h
|
||||
|
||||
demo-docs:
|
||||
python -c \
|
||||
"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
|
||||
|
||||
clean:
|
||||
rm -rf build dist capture.svg
|
||||
|
||||
# https://stackoverflow.com/a/26339924
|
||||
list:
|
||||
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue