-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (41 loc) · 1.66 KB
/
Makefile
File metadata and controls
57 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
FLASH_SPEED = 230400
ESP_PORT ?= $$(ls /dev/tty*usbserial*)
DOCKER_IMAGE ?= ghcr.io/homebots/xtensa-gcc:latest
.PHONY: build flash asm sym test examples run-examples compiler
EXAMPLES := $(shell find ./examples -type f -name '*.js')
BINS = $(EXAMPLES:.js=.bin)
# Node.js compiler setup
NODE_MODULES = grammar/node_modules
PARSER = grammar/v1.js
COMPILER = grammar/compiler
build:
mkdir -p build/ firmware/
chmod a+w firmware build
docker run --rm -e VERBOSE -e LIBS -e WIFI_SSID -e WIFI_PASSWORD -v$$(pwd):/home/project:rw $(DOCKER_IMAGE) make
flash:
esptool.py --after hard_reset --baud $(FLASH_SPEED) --port $(ESP_PORT) write_flash --compress --flash_freq 80m -fm qio -fs 1MB 0x00000 firmware/0x00000.bin 0x10000 firmware/0x10000.bin
test:
mkdir -p bin
clang++ -std=gnu++11 -Wno-int-to-void-pointer-cast -Wno-deprecated-declarations -I src/include test/test.cpp -o bin/vm
./bin/vm ./examples/basics/debug.bin ./examples/basics/hello-world.bin
./bin/vm ./examples/basics/blinky.bin
asm:
docker run --rm -v$$(pwd)/:/home/project $(DOCKER_IMAGE) make disassemble
sym:
docker run --rm -v$$(pwd)/:/home/project $(DOCKER_IMAGE) make symboldump
inspect:
docker run --rm -it --entrypoint=/bin/bash -v$$(pwd):/home/project $(DOCKER_IMAGE)
compiler: $(NODE_MODULES) $(PARSER) $(COMPILER)
chmod +x $(COMPILER)
$(NODE_MODULES):
cd grammar && npm install
PEGJS_FILES = $(shell find ./grammar/src -type f -name '*.pegjs')
$(PARSER): $(NODE_MODULES) $(PEGJS_FILES)
cd grammar && npm run build && npm run build-trace
examples: compiler $(BINS)
%.bin: %.js $(COMPILER)
./grammar/compiler $< $@
run-examples: examples
for f in $(BINS); do \
./bin/vm $$f; \
done