Update build process to use mpy-cross
This commit is contained in:
parent
6aa2d756c6
commit
d1199575ff
1
pico/.gitignore
vendored
1
pico/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
build
|
||||||
.venv
|
.venv
|
||||||
typings
|
typings
|
||||||
src/secret.py
|
src/secret.py
|
@ -1,6 +1,27 @@
|
|||||||
|
SRC_DIR := src
|
||||||
|
BUILD_DIR := build
|
||||||
|
|
||||||
|
SRC_FILES := $(wildcard $(SRC_DIR)/*.py) $(wildcard $(SRC_DIR)/**/*.py)
|
||||||
|
BUILD_FILES := $(patsubst $(SRC_DIR)/%.py,$(BUILD_DIR)/%.mpy, $(SRC_FILES))
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.mpy: $(SRC_DIR)/%.py
|
||||||
|
@mkdir -p `dirname $@`
|
||||||
|
mpy-cross $< -o $@
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: $(BUILD_FILES)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
.PHONY: deploy
|
.PHONY: deploy
|
||||||
deploy:
|
deploy: $(BUILD_FILES)
|
||||||
mpremote fs cp src/* :
|
mpremote fs cp -r $(BUILD_DIR)/* :
|
||||||
|
|
||||||
|
.PHONY: purge
|
||||||
|
purge:
|
||||||
|
mpremote run purge.py
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: deploy
|
run: deploy
|
||||||
|
@ -1,6 +1,20 @@
|
|||||||
# Setup:
|
# Setup:
|
||||||
```
|
1. Set up the virtual environment:
|
||||||
$ python -m venv .venv
|
```
|
||||||
$ source .venv/bin/activate
|
$ python -m venv .venv
|
||||||
$ pip install -U micropython-rp2-pico_w-stubs --no-user --target typings
|
$ source .venv/bin/activate
|
||||||
```
|
```
|
||||||
|
|
||||||
|
2. Install the type stubs:
|
||||||
|
```
|
||||||
|
$ pip install -U micropython-rp2-pico_w-stubs --no-user --target typings
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Ensure `mpy-cross` is available:
|
||||||
|
```
|
||||||
|
$ git clone https://github.com/micropython/micropython.git /tmp/micropython
|
||||||
|
$ pushd /tmp/micropython/mpy-cross
|
||||||
|
$ make
|
||||||
|
$ mv build/mpy-cross ~/.local/bin/
|
||||||
|
$ popd
|
||||||
|
```
|
14
pico/purge.py
Normal file
14
pico/purge.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
def rm(p: str, cwd: str = "/"):
|
||||||
|
path = cwd+p
|
||||||
|
print(f"rm {path=}")
|
||||||
|
try:
|
||||||
|
os.unlink(path)
|
||||||
|
except OSError:
|
||||||
|
for f in os.listdir(path): # pyright: ignore[reportAny]
|
||||||
|
rm(f, path+"/") # pyright: ignore[reportAny]
|
||||||
|
os.unlink(path)
|
||||||
|
|
||||||
|
for f in os.listdir(): # pyright: ignore[reportAny]
|
||||||
|
rm(f) # pyright: ignore[reportAny]
|
Loading…
Reference in New Issue
Block a user