-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (40 loc) · 1.43 KB
/
Makefile
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
LUAC_CROSS ?= /opt/luac.cross
NODEMCU_UPLOADER ?= nodemcu-uploader
SRC_FOLDER ?= src
LFS_SRC_FOLDER ?= lfs-src
MAIN_FILE ?= init
NODEMCU_PORT ?= /dev/ttyUSB0
SRC_FILES := $(wildcard $(SRC_FOLDER)/*.lua)
LFS_FILES := $(wildcard $(LFS_SRC_FOLDER)/*.lua)
LC_FILES := $(SRC_FILES:.lua=.lc)
.PHONY: default
default: run
%.lc: %.lua
@echo "Compiling Lua file:" $@
$(LUAC_CROSS) -s -o $@ $<
upload:
@echo "Uploading lua files"
$(NODEMCU_UPLOADER) --port $(NODEMCU_PORT) upload $(join $(addsuffix :, $(SRC_FILES)), $(notdir $(SRC_FILES)))
upload-release: $(LC_FILES)
@echo "Uploading compiled Lua files"
$(NODEMCU_UPLOADER) --port $(NODEMCU_PORT) upload $(join $(addsuffix :, $(LC_FILES)), $(notdir $(LC_FILES)))
run:
@echo "Running main file"
$(NODEMCU_UPLOADER) --port $(NODEMCU_PORT) file do $(MAIN_FILE).lua
run-release:
@echo "Running main file"
$(NODEMCU_UPLOADER) --port $(NODEMCU_PORT) file do $(MAIN_FILE).lc
build-lfs-image:
@echo "Building LFS image"
$(LUAC_CROSS) -f $(LFS_FILES)
flash-lfs-image:
@echo "Installing LFS image"
$(NODEMCU_UPLOADER) --port $(NODEMCU_PORT) upload luac.cross.out
# Workaround to https://github.com/kmpm/nodemcu-uploader/issues/76
$(NODEMCU_UPLOADER) --port $(NODEMCU_PORT) upload flashreload.lua
$(NODEMCU_UPLOADER) --port $(NODEMCU_PORT) file do flashreload.lua
clean:
rm luac.cross.out $(LC_FILES)
lfs: build-lfs-image flash-lfs-image
all: upload lfs run
all-release: upload-release lfs run-release