make lint target
This commit is contained in:
55
Makefile
55
Makefile
@@ -16,6 +16,9 @@ ASSETS_LUA = inc/meta/meta.assets.lua
|
|||||||
ASSETS_DIR = assets
|
ASSETS_DIR = assets
|
||||||
ASSET_TYPES = tiles sprites sfx music
|
ASSET_TYPES = tiles sprites sfx music
|
||||||
|
|
||||||
|
LINT_TMP_LUA := /tmp/_lint_combined.lua
|
||||||
|
LINT_TMP_MAP := /tmp/_lint_map.txt
|
||||||
|
|
||||||
# CI/CD variables
|
# CI/CD variables
|
||||||
VERSION_FILE = .version
|
VERSION_FILE = .version
|
||||||
GAME_LANG ?= lua
|
GAME_LANG ?= lua
|
||||||
@@ -76,6 +79,56 @@ define f_export_asset_awk
|
|||||||
cat $(2) | awk '/-- <$(1)>/,/<\/$(1)>/' >> $(3)
|
cat $(2) | awk '/-- <$(1)>/,/<\/$(1)>/' >> $(3)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
lint:
|
||||||
|
@echo "==> Merging..."
|
||||||
|
@rm -f $(LINT_TMP_LUA) $(LINT_TMP_MAP)
|
||||||
|
@line=1; \
|
||||||
|
while IFS= read -r f || [ -n "$$f" ]; do \
|
||||||
|
[ -z "$$f" ] && continue; \
|
||||||
|
linecount=$$(awk 'END{print NR}' "$(SRC_DIR)/$$f"); \
|
||||||
|
echo "$$line $$linecount $(SRC_DIR)/$$f" >> $(LINT_TMP_MAP); \
|
||||||
|
cat "$(SRC_DIR)/$$f" >> $(LINT_TMP_LUA); \
|
||||||
|
echo "" >> $(LINT_TMP_LUA); \
|
||||||
|
line=$$((line + linecount + 1)); \
|
||||||
|
done < $(ORDER)
|
||||||
|
@echo "==> luacheck..."
|
||||||
|
@luacheck $(LINT_TMP_LUA) 2>&1 | awk -v map=$(LINT_TMP_MAP) ' \
|
||||||
|
BEGIN { \
|
||||||
|
NR_map = 0; \
|
||||||
|
while ((getline line < map) > 0) { \
|
||||||
|
n = split(line, a, " "); \
|
||||||
|
start[NR_map] = a[1]+0; \
|
||||||
|
count[NR_map] = a[2]+0; \
|
||||||
|
fname[NR_map] = a[3]; \
|
||||||
|
NR_map++; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
/^[^:]+:[0-9]+:[0-9]+:/ { \
|
||||||
|
colon1 = index($$0, ":"); \
|
||||||
|
rest1 = substr($$0, colon1+1); \
|
||||||
|
colon2 = index(rest1, ":"); \
|
||||||
|
absline = substr(rest1, 1, colon2-1) + 0; \
|
||||||
|
rest2 = substr(rest1, colon2+1); \
|
||||||
|
colon3 = index(rest2, ":"); \
|
||||||
|
col = substr(rest2, 1, colon3-1); \
|
||||||
|
rest = substr(rest2, colon3); \
|
||||||
|
found = 0; \
|
||||||
|
for (i = 0; i < NR_map; i++) { \
|
||||||
|
end_line = start[i] + count[i]; \
|
||||||
|
if (absline >= start[i] && absline <= end_line) { \
|
||||||
|
relline = absline - start[i] + 1; \
|
||||||
|
print fname[i] ":" relline ":" col ":" rest; \
|
||||||
|
found = 1; \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
if (!found) print $$0; \
|
||||||
|
next; \
|
||||||
|
} \
|
||||||
|
{ print } \
|
||||||
|
'; true
|
||||||
|
@rm -f $(LINT_TMP_LUA) $(LINT_TMP_MAP)
|
||||||
|
|
||||||
export_assets:
|
export_assets:
|
||||||
# $(OUTPUT) would be a circular dependency
|
# $(OUTPUT) would be a circular dependency
|
||||||
@test -e $(OUTPUT)
|
@test -e $(OUTPUT)
|
||||||
@@ -125,7 +178,7 @@ ci-update:
|
|||||||
echo "==> Triggering update for version $$VERSION"; \
|
echo "==> Triggering update for version $$VERSION"; \
|
||||||
curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=tic80&version=$$VERSION"
|
curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=tic80&version=$$VERSION"
|
||||||
|
|
||||||
.PHONY: all build export watch import_assets export_assets clean ci-version ci-export ci-upload ci-update
|
.PHONY: all build export watch import_assets export_assets clean lint ci-version ci-export ci-upload ci-update
|
||||||
|
|
||||||
#-- <WAVES>
|
#-- <WAVES>
|
||||||
#-- 000:224578acdeeeeddcba95434567653100
|
#-- 000:224578acdeeeeddcba95434567653100
|
||||||
|
|||||||
Reference in New Issue
Block a user