-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Makefile and Readme with new development experience (#89)
- Loading branch information
1 parent
bf37905
commit 8feda29
Showing
2 changed files
with
73 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,57 @@ | ||
.PHONY: all | ||
all: download-libraries help | ||
all: venv download-libraries pre-commit-install help | ||
|
||
.PHONY: help | ||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
##@ Development | ||
|
||
ACTIVATE_VENV := . venv/bin/activate; | ||
BOARD_MOUNT_POINT ?= /Volumes/PYSQUARED | ||
|
||
venv: | ||
@echo "Creating virtual environment..." | ||
@python3 -m venv venv | ||
@$(ACTIVATE_VENV) pip install --upgrade pip --quiet | ||
@$(ACTIVATE_VENV) pip install --requirement requirements.txt --quiet | ||
|
||
.PHONY: download-libraries | ||
download-libraries: venv ## Download the required libraries | ||
@echo "Downloading libraries..." | ||
@$(ACTIVATE_VENV) pip install --requirement lib/requirements.txt --target lib --no-deps --upgrade --quiet | ||
@rm -rf lib/*.dist-info | ||
|
||
.PHONY: pre-commit-install | ||
pre-commit-install: venv | ||
@echo "Installing pre-commit hooks..." | ||
@$(ACTIVATE_VENV) pre-commit install > /dev/null | ||
|
||
.PHONY: fmt | ||
fmt: ## Lint and format files | ||
pre-commit run --all-files | ||
fmt: pre-commit-install ## Lint and format files | ||
$(ACTIVATE_VENV) pre-commit run --all-files | ||
|
||
.PHONY: test | ||
test: ## Run tests | ||
python3 -m pytest tests/unit | ||
test: venv ## Run tests | ||
$(ACTIVATE_VENV) python3 -m pytest tests/unit | ||
|
||
.PHONY: install | ||
install: build ## Install the project onto a connected PROVES Kit use `BOARD_MOUNT_POINT` to specify the mount point | ||
rsync -avh artifacts/proves/ $(BOARD_MOUNT_POINT) --delete | ||
|
||
.PHONY: clean | ||
clean: ## Remove all gitignored files such as downloaded libraries and artifacts | ||
git clean -dfX | ||
|
||
##@ Build | ||
|
||
.PHONY: build | ||
build: download-libraries ## Build the project, store the result in the artifacts directory | ||
rm -rf artifacts/proves/ | ||
mkdir -p artifacts/proves | ||
cp config.json artifacts/proves/ | ||
cp ./*.py artifacts/proves/ | ||
find ./lib -type d -name '__pycache__' -prune -o -type f -print | cpio -pdm artifacts/proves/ | ||
zip -r artifacts/proves.zip artifacts/proves | ||
|
||
##@ Library Management | ||
|
||
download-libraries: ## Download the required libraries | ||
@echo "Downloading libraries..." | ||
@pip3 install --requirement lib/requirements.txt --target lib --no-deps --upgrade --quiet | ||
@rm -rf lib/*.dist-info | ||
@echo "Creating artifacts/proves" | ||
@rm -rf artifacts/proves/ | ||
@mkdir -p artifacts/proves | ||
@cp config.json artifacts/proves/ | ||
@cp ./*.py artifacts/proves/ | ||
@find ./lib -type d -name '__pycache__' -prune -o -type f -print | cpio -pdm artifacts/proves/ | ||
@echo "Creating artifacts/proves.zip" | ||
@zip -r artifacts/proves.zip artifacts/proves > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters